-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: SingleBlockManager dont subclass BlockManager #40625
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
Conversation
pandas/core/internals/managers.py
Outdated
|
||
|
||
class BlockManager(DataManager): | ||
class _BlockManager(DataManager): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you indicate that this is an abstract class (alt put ABC in the name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated + green
pandas/core/internals/managers.py
Outdated
@@ -1474,21 +1387,123 @@ def take(self: T, indexer, axis: int = 1, verify: bool = True) -> T: | |||
consolidate=False, | |||
) | |||
|
|||
def _equal_values(self: T, other: T) -> bool: | |||
|
|||
class BlockManager(_BlockManager): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we actually name it Block2DManager then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bc (to my chagrin) downstream packages access it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WAT, gawd. ok
# Populate known_consolidate, blknos, and blklocs lazily | ||
self._known_consolidated = False | ||
# error: Incompatible types in assignment (expression has type "None", | ||
# variable has type "ndarray") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need all these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the attributes or the "type ignore"s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the type ignores, but certainly can be in a followup
self._blklocs = None # type: ignore[assignment] | ||
|
||
@classmethod | ||
def _simple_new(cls, blocks: tuple[Block, ...], axes: list[Index]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you have an abc for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing in the base class uses _simple_new, so no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess that is the question, why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of comments, but certailnly can be in followups
Instead, most of BlockManager becomes _BlockManager which is subclassed by SingleBlockManager and BlockManager, the latter holding only the 2d-specific BM methods.
Motivation: putting BlockManager constructor in cython gives a much bigger gain if we can define
__cinit__
, and we can't do that with the two subclasses having mismatched__init__
signatures.