-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
CLN: datetimelike arrays: isort, small reorg #23587
CLN: datetimelike arrays: isort, small reorg #23587
Conversation
…range things that got shuffled in rebasing
Hello @jbrockmendel! Thanks for submitting the PR.
|
Codecov Report
@@ Coverage Diff @@
## master #23587 +/- ##
=========================================
Coverage ? 92.24%
=========================================
Files ? 161
Lines ? 51316
Branches ? 0
=========================================
Hits ? 47337
Misses ? 3979
Partials ? 0
Continue to review full report at Codecov.
|
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.
LGTM at a glance. What's the motivation for aliasing DatetimeArrayMixin to DatetimeArray, rather than doing the rename all at once?
In several branches where I have tried doing it all-at-once the diffs become difficult for even me to read. Getting this out of the way early saves some trouble. |
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.
Some minor comments
@@ -286,10 +282,6 @@ def _ndarray_values(self): | |||
# Ordinals | |||
return self._data | |||
|
|||
@property | |||
def asi8(self): | |||
return self._data |
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.
but for datetimes the _data
is not integer?
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 inherited implementation returns self._data.view('i8')
. The view is redundant for PeriodArray, but still correct
pandas/core/indexes/datetimes.py
Outdated
microsecond = wrap_field_accessor(DatetimeArrayMixin.microsecond) | ||
nanosecond = wrap_field_accessor(DatetimeArrayMixin.nanosecond) | ||
weekofyear = wrap_field_accessor(DatetimeArrayMixin.weekofyear) | ||
# override DatetimeLikeArrayMixin.__repr__ |
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 add a "TODO remove" ?
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.
Sure, but FWIW that's the point of collecting things in this section
@@ -256,8 +256,15 @@ def _simple_new(cls, values, name=None, freq=None, **kwargs): | |||
result._reset_identity() | |||
return result | |||
|
|||
# ------------------------------------------------------------------------ | |||
# Wrapping PeriodArray |
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 is this section for?
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.
Collecting things that will soon be changed by the inheritance/composition in one place. For PeriodIndex its a pretty small set
|
||
|
||
class TestDatetimeArray(object): | ||
def test_repr(self): |
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.
Do we want to put this in a class? Or do like in PeriodArray tests?
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.
It would be more idiomatic to use functions, unless we need the class org for a particular reason. The same goes for all of the other add tests.
Are we OK with merging this and then shortly thereafter getting rid of the |
I'm going to revert the repr changes if that's OK. We'll need to change them eventually, when the name changes from ArrayMixin to just Array, and since they aren't inheriting from ExtensionArray yet the formatting on #23601 won't quite work.. |
Converted the new array repr tests to xfails. We'll need to be a bit careful with those once we DatetimeArrayMixin inherits from DatetimeArray. I may not have gotten the future formatting 100% correct. |
Sounds good, thanks. |
Fixed I sort that broke travis, hopefully got all of them |
Travis fail is Hypothesis |
I didn't add this, has existed for a while. No idea what the original reasoning was. Maybe just an alias? |
@jbrockmendel #23587 (comment) ok. can you create an issue about seeing what that is about. it seems pretty confusing (though its actually a nice name). |
lgtm. ping on green (circle seems to have failed <:) |
pandas/core/indexes/period.py
Outdated
# Wrapping PeriodArray | ||
|
||
# override DatetimeLikeArrayMixin.__repr__ | ||
__repr__ = Index.__repr__ |
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.
This can be removed now I think? (now the repr changes are reversed?)
Thanks @jbrockmendel ! |
* upstream/master: BUG: Don't over-optimize memory with jagged CSV (pandas-dev#23527) DEPR: Deprecate usecols as int in read_excel (pandas-dev#23635) More helpful Stata string length error. (pandas-dev#23629) BUG: astype fill_value for SparseArray.astype (pandas-dev#23547) CLN: datetimelike arrays: isort, small reorg (pandas-dev#23587) CI: Check in the CI that assert_raises_regex is not being used (pandas-dev#23627) CLN:Remove unused **kwargs from user facing methods (pandas-dev#23249) DOC: Enhancing pivot / reshape docs (pandas-dev#21038) TST: Fix xfailing DataFrame arithmetic tests by transposing (pandas-dev#23620)
…fixed * upstream/master: DOC: avoid SparseArray.take error (pandas-dev#23637) CLN: remove incorrect usages of com.AbstractMethodError (pandas-dev#23625) DOC: Adding validation of the section order in docstrings (pandas-dev#23607) BUG: Don't over-optimize memory with jagged CSV (pandas-dev#23527) DEPR: Deprecate usecols as int in read_excel (pandas-dev#23635) More helpful Stata string length error. (pandas-dev#23629) BUG: astype fill_value for SparseArray.astype (pandas-dev#23547) CLN: datetimelike arrays: isort, small reorg (pandas-dev#23587) CI: Check in the CI that assert_raises_regex is not being used (pandas-dev#23627) CLN:Remove unused **kwargs from user facing methods (pandas-dev#23249)
Big diff, few real changes.
Implement
__repr__
for DTA/TDA. Shared with PeriodArray implementation. Added truncation so we don't print all N elements. Adds tests for all three subclasses. Creates dedicated test files for test_datetimes and test_timedeltasSome PeriodArray methods got shuffled into weird places, so this puts them back.
Collects wrapping-properties in DatetimeIndex.
isort on indexes/datetimelike, datetimes, timedeltas