-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Some code cleanups #31792
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
Some code cleanups #31792
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,8 +85,6 @@ | |
import pandas.core.missing as missing | ||
from pandas.core.nanops import nanpercentile | ||
|
||
from pandas.io.formats.printing import pprint_thing | ||
|
||
|
||
class Block(PandasObject): | ||
""" | ||
|
@@ -159,7 +157,8 @@ def _check_ndim(self, values, ndim): | |
|
||
@property | ||
def _holder(self): | ||
"""The array-like that can hold the underlying values. | ||
""" | ||
The array-like that can hold the underlying values. | ||
|
||
None for 'Block', overridden by subclasses that don't | ||
use an ndarray. | ||
|
@@ -284,16 +283,11 @@ def __repr__(self) -> str: | |
# don't want to print out all of the items here | ||
name = type(self).__name__ | ||
if self._is_single_block: | ||
|
||
result = f"{name}: {len(self)} dtype: {self.dtype}" | ||
|
||
else: | ||
|
||
shape = " x ".join(pprint_thing(s) for s in self.shape) | ||
result = ( | ||
f"{name}: {pprint_thing(self.mgr_locs.indexer)}, " | ||
f"{shape}, dtype: {self.dtype}" | ||
) | ||
shape = " x ".join(str(s) for s in self.shape) | ||
result = f"{name}: {self.mgr_locs.indexer}, {shape}, dtype: {self.dtype}" | ||
|
||
return result | ||
|
||
|
@@ -319,10 +313,7 @@ def getitem_block(self, slicer, new_mgr_locs=None): | |
As of now, only supports slices that preserve dimensionality. | ||
""" | ||
if new_mgr_locs is None: | ||
if isinstance(slicer, tuple): | ||
axis0_slicer = slicer[0] | ||
else: | ||
axis0_slicer = slicer | ||
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. i tend to like this version because i can see in coverage output whether both cases are reached 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. @jbrockmendel I can see your point, I like the one-liner version because it's making less noise (IMO). Anyway I am fine with reverting this one and also others. Can we open a discussion for it (in a separate issue)? so we will put it in Pandas code style guide 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. @jbrockmendel are you sticking on this one? +/- 0 on 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. not a deal breaker |
||
axis0_slicer = slicer[0] if isinstance(slicer, tuple) else slicer | ||
new_mgr_locs = self.mgr_locs[axis0_slicer] | ||
|
||
new_values = self._slice(slicer) | ||
|
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.
AFICT the
pprint_thing
is just a python2 thing.@jbrockmendel can you please confirm or explain what it is?
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.
Yes - shouldn’t be needed now py3 only. Worth checking though
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 think it might matter if you were dealing with nested objects, but for these i think it is just a leftover py2 thing