Skip to content

Commit 7e7cecc

Browse files
WIP commit before merge
Underlying numba chnages has broken my local testing. Preparing to resync with main branch to resolve. Signed-off-by: Michael Tiemann <[email protected]>
1 parent 0c64095 commit 7e7cecc

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

pandas/core/arrays/base.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,17 @@ def _from_sequence(cls, scalars, *, dtype: Dtype | None = None, copy: bool = Fal
292292
raise AbstractMethodError(cls)
293293

294294
@classmethod
295-
def _from_scalars(cls, scalars, *, dtype: DtypeObj) -> Self:
295+
def _from_scalars(cls, scalars, *, dtype: DtypeObj | None = None) -> Self:
296296
"""
297297
Strict analogue to _from_sequence, allowing only sequences of scalars
298298
that should be specifically inferred to the given dtype.
299299
Parameters
300300
----------
301301
scalars : sequence
302-
dtype : ExtensionDtype
302+
dtype : ExtensionDtype, optional
303+
This could be a Dtype competible with the ExtensionArray,
304+
but it is up to _from_scalars to choose (from scalars,
305+
dtype, or however) the ultimate dtype for the return value.
303306
Raises
304307
------
305308
TypeError or ValueError

pandas/core/internals/managers.py

+9-17
Original file line numberDiff line numberDiff line change
@@ -971,30 +971,22 @@ def fast_xs(self, loc: int) -> SingleBlockManager:
971971

972972
if isinstance(dtype, ExtensionDtype) and not immutable_ea:
973973
cls = dtype.construct_array_type()
974-
else:
975-
cls = None
976-
977-
if hasattr(cls, "_from_scalars"):
978-
obj = self.blocks[0].iget((slice(None), loc))
979974
result = cls._from_scalars(
980975
[
981976
blk.iget((i, loc))
982977
for blk in self.blocks
983-
for i, rl in enumerate(blk.mgr_locs)
978+
for i, _ in enumerate(blk.mgr_locs)
984979
],
985-
dtype=obj.dtype,
980+
dtype=dtype,
986981
)
987982
else:
988-
if cls is not None:
989-
result = cls._empty((n,), dtype=dtype)
990-
else:
991-
# error: Argument "dtype" to "empty" has incompatible type
992-
# "Union[Type[object], dtype[Any], ExtensionDtype, None]"; expected
993-
# "None"
994-
result = np.empty(
995-
n, dtype=object if immutable_ea else dtype # type: ignore[arg-type]
996-
)
997-
result = ensure_wrapped_if_datetimelike(result)
983+
# error: Argument "dtype" to "empty" has incompatible type
984+
# "Union[Type[object], dtype[Any], ExtensionDtype, None]"; expected
985+
# "None"
986+
result = np.empty(
987+
n, dtype=object if immutable_ea else dtype # type: ignore[arg-type]
988+
)
989+
result = ensure_wrapped_if_datetimelike(result)
998990

999991
for blk in self.blocks:
1000992
# Such assignment may incorrectly coerce NaT to None

0 commit comments

Comments
 (0)