-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: remove fill_tuple kludge #33310
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1299,14 +1299,14 @@ def reindex_indexer( | |
raise IndexError("Requested axis not found in manager") | ||
|
||
if axis == 0: | ||
new_blocks = self._slice_take_blocks_ax0(indexer, fill_tuple=(fill_value,)) | ||
new_blocks = self._slice_take_blocks_ax0(indexer, fill_value=fill_value) | ||
else: | ||
new_blocks = [ | ||
blk.take_nd( | ||
indexer, | ||
axis=axis, | ||
fill_tuple=( | ||
fill_value if fill_value is not None else blk.fill_value, | ||
fill_value=( | ||
fill_value if fill_value is not None else blk.fill_value | ||
), | ||
) | ||
for blk in self.blocks | ||
|
@@ -1317,7 +1317,7 @@ def reindex_indexer( | |
|
||
return type(self).from_blocks(new_blocks, new_axes) | ||
|
||
def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None): | ||
def _slice_take_blocks_ax0(self, slice_or_indexer, fill_value=lib.no_default): | ||
""" | ||
Slice/take blocks along axis=0. | ||
|
||
|
@@ -1327,7 +1327,7 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None): | |
------- | ||
new_blocks : list of Block | ||
""" | ||
allow_fill = fill_tuple is not None | ||
allow_fill = fill_value is not lib.no_default | ||
|
||
sl_type, slobj, sllen = _preprocess_slice_or_indexer( | ||
slice_or_indexer, self.shape[0], allow_fill=allow_fill | ||
|
@@ -1339,16 +1339,15 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None): | |
if sl_type in ("slice", "mask"): | ||
return [blk.getitem_block(slobj, new_mgr_locs=slice(0, sllen))] | ||
elif not allow_fill or self.ndim == 1: | ||
if allow_fill and fill_tuple[0] is None: | ||
if allow_fill and fill_value is None: | ||
_, fill_value = maybe_promote(blk.dtype) | ||
fill_tuple = (fill_value,) | ||
|
||
return [ | ||
blk.take_nd( | ||
slobj, | ||
axis=0, | ||
new_mgr_locs=slice(0, sllen), | ||
fill_tuple=fill_tuple, | ||
fill_value=fill_value, | ||
) | ||
] | ||
|
||
|
@@ -1371,8 +1370,7 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None): | |
blocks = [] | ||
for blkno, mgr_locs in libinternals.get_blkno_placements(blknos, group=True): | ||
if blkno == -1: | ||
# If we've got here, fill_tuple was not None. | ||
fill_value = fill_tuple[0] | ||
# If we've got here, fill_value was not lib.no_default | ||
|
||
blocks.append( | ||
self._make_na_block(placement=mgr_locs, fill_value=fill_value) | ||
|
@@ -1396,7 +1394,7 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None): | |
blklocs[mgr_locs.indexer], | ||
axis=0, | ||
new_mgr_locs=mgr_locs, | ||
fill_tuple=None, | ||
fill_value=lib.no_default, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be removed? isn't it an anti-pattern to explicitly pass this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea |
||
) | ||
) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is allow_fill now redundant here?
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.
allow_fill is tricky to remove (but this is a start to 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.
The
allow_fill
is from checkingfill_value is not lib.default
. Sofill_value is None
is still a different check I think.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.
what @jorisvandenbossche said
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.
if
fill_value is None
, isn'tallow_fill
, by definition,True
. soallow_fill
is redundant here andif fill_value is None:
would be the same? nbd though, i must be missing something. will look again. We no longer need the guard, that was previously required with thefill_tuple
__getitem__ call.