Skip to content

CLN: remove no-longer-used #43200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 1 addition & 44 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ def construction_error(
# -----------------------------------------------------------------------


def _grouping_func(tup):
def _grouping_func(tup: tuple[int, ArrayLike]) -> tuple[bool, DtypeObj]:
# compat for numpy<1.21, in which comparing a np.dtype with an ExtensionDtype
# raises instead of returning False. Once earlier numpy versions are dropped,
# this can be simplified to `return tup[1].dtype`
Expand Down Expand Up @@ -1911,49 +1911,6 @@ def _form_blocks(arrays: list[ArrayLike], consolidate: bool) -> list[Block]:
return nbs


def simple_blockify(tuples, dtype, consolidate: bool) -> list[Block]:
"""
return a single array of a block that has a single dtype; if dtype is
not None, coerce to this dtype
"""
if not consolidate:
return _tuples_to_blocks_no_consolidate(tuples, dtype=dtype)

values, placement = _stack_arrays(tuples, dtype)

# TODO: CHECK DTYPE?
if dtype is not None and values.dtype != dtype: # pragma: no cover
values = values.astype(dtype)

block = new_block(values, placement=BlockPlacement(placement), ndim=2)
return [block]


def multi_blockify(tuples, dtype: DtypeObj | None = None, consolidate: bool = True):
"""return an array of blocks that potentially have different dtypes"""

if not consolidate:
return _tuples_to_blocks_no_consolidate(tuples, dtype=dtype)

# group by dtype
grouper = itertools.groupby(tuples, lambda x: x[1].dtype)

new_blocks = []
for dtype, tup_block in grouper:

# error: Argument 2 to "_stack_arrays" has incompatible type
# "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], Type[int],
# Type[complex], Type[bool], Type[object], None]"; expected "dtype[Any]"
values, placement = _stack_arrays(
list(tup_block), dtype # type: ignore[arg-type]
)

block = new_block(values, placement=BlockPlacement(placement), ndim=2)
new_blocks.append(block)

return new_blocks


def _tuples_to_blocks_no_consolidate(tuples, dtype: DtypeObj | None) -> list[Block]:
# tuples produced within _form_blocks are of the form (placement, array)
if dtype is not None:
Expand Down