Skip to content

[REF] Move comparison methods to EAMixins, share code #21872

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 17 commits into from
Jul 14, 2018

Conversation

jbrockmendel
Copy link
Member

Changes an old usage numpy's C API that is deprecated. This won't get rid of the warnings because cython hasn't changed it, but still.

Also stops making copies of offsets since they are now immutable.

Handles a handful of changes requested in the last pass: de-privatizes _quarter_to_myear (plus bonus docstring), renames _generate --> _generate_range, comments in is_list_like

renames arrays.timedelta --> arrays.timedeltas to match core.indexes

Implements comparison methods in DatetimeArray and TimedeltaArray, cleans up some Index code that is no longer needed as a result.

Makes some progress on sharing code between TDI and DTI constructors (most of which we want to move up to the array classes)

@gfyoung gfyoung added Internals Related to non-user accessible pandas implementation Clean labels Jul 12, 2018
@@ -1877,6 +1897,8 @@ def _quarter_to_myear(year, quarter, freq):
year -= 1

return year, month
# FIXME: if quarter is None then `month` won't be defined here.
# just disallow quarter == None?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return result

name = '__{name}__'.format(name=op.__name__)
# TODO: docstring?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you can.

def _evaluate_compare(self, other, op):
"""
We have been called because a comparison between
8 aware arrays. numpy >= 1.11 will
Copy link
Member

@gfyoung gfyoung Jul 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"8 aware arrays" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the existing docstring in indexes.datetimelike. I'm open to suggestions.

# -------------------------------------------------------------------
# Shared Constructor Helpers

def validate_periods(periods):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring

@codecov
Copy link

codecov bot commented Jul 12, 2018

Codecov Report

Merging #21872 into master will increase coverage by <.01%.
The diff coverage is 98.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #21872      +/-   ##
==========================================
+ Coverage   91.91%   91.92%   +<.01%     
==========================================
  Files         164      164              
  Lines       49992    50040      +48     
==========================================
+ Hits        45952    46001      +49     
+ Misses       4040     4039       -1
Flag Coverage Δ
#multiple 90.31% <98.23%> (+0.01%) ⬆️
#single 42.22% <79.41%> (+0.06%) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.4% <ø> (-0.18%) ⬇️
pandas/core/dtypes/inference.py 98.41% <ø> (ø) ⬆️
pandas/core/arrays/__init__.py 100% <100%> (ø) ⬆️
pandas/tseries/frequencies.py 95.9% <100%> (ø) ⬆️
pandas/core/arrays/period.py 91.35% <100%> (ø) ⬆️
pandas/core/indexes/datetimelike.py 97.35% <100%> (+0.41%) ⬆️
pandas/core/indexes/timedeltas.py 91.53% <100%> (-0.65%) ⬇️
pandas/core/indexes/datetimes.py 95.16% <100%> (-0.18%) ⬇️
pandas/core/arrays/datetimes.py 96.12% <100%> (+0.67%) ⬆️
pandas/core/arrays/datetimelike.py 94.06% <95.65%> (+0.38%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdb6168...935ac7b. Read the comment docs.


return period_ordinal(year, month, day, hour,
minute, second, 0, 0, base)


def _quarter_to_myear(year, quarter, freq):
def quarter_to_myear(year, quarter, freq):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally type these, where is quarter passed as None?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used once in period.pyx and once in arrays.period, always with quarter non-None. I'll make that required.

@@ -21,6 +21,19 @@
from pandas.tseries.frequencies import to_offset

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change to absolute imports, I think we are moving away from the relative ones fro readability.

# Comparison Methods

@classmethod
def _add_comparison_methods(cls):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I would define the comparison methods on the class itself, then this should be trivial to change to use the EAMixins

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should move in this direction, but prefer to do it separately. ATM the PR still broadly resembles cut/paste.

@jbrockmendel
Copy link
Member Author

Ping. I’d like to get a move on #21907 and the caching issues that will come up with this.

@jreback jreback added this to the 0.24.0 milestone Jul 14, 2018
@jreback jreback merged commit fac8196 into pandas-dev:master Jul 14, 2018
@jreback
Copy link
Contributor

jreback commented Jul 14, 2018

thanks @jbrockmendel

Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
@jbrockmendel jbrockmendel deleted the dtmore branch April 5, 2020 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants