Skip to content

Move constructor helpers to EAMixins #21845

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 5 commits into from
Jul 12, 2018

Conversation

jbrockmendel
Copy link
Member

Takes the place of #21843, porting constructor helpers. While this is in review I'm going to start porting tests in earnest.

@codecov
Copy link

codecov bot commented Jul 10, 2018

Codecov Report

Merging #21845 into master will decrease coverage by 0.01%.
The diff coverage is 89.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #21845      +/-   ##
==========================================
- Coverage   91.92%   91.91%   -0.02%     
==========================================
  Files         160      160              
  Lines       49906    49920      +14     
==========================================
+ Hits        45875    45882       +7     
- Misses       4031     4038       +7
Flag Coverage Δ
#multiple 90.29% <89.56%> (-0.02%) ⬇️
#single 42.1% <41.2%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/period.py 93.2% <ø> (-1.04%) ⬇️
pandas/core/indexes/timedeltas.py 92.17% <100%> (+1.09%) ⬆️
pandas/core/arrays/period.py 91.35% <100%> (+3.52%) ⬆️
pandas/core/indexes/datetimes.py 95.33% <100%> (+0.12%) ⬆️
pandas/core/arrays/timedelta.py 85.36% <76.71%> (-7.11%) ⬇️
pandas/core/arrays/datetimes.py 95.45% <91.66%> (-0.4%) ⬇️

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 5d0daa0...36f93c2. Read the comment docs.

@jreback jreback added Refactor Internal refactoring of code Datetime Datetime data dtype ExtensionArray Extending pandas with custom dtypes or arrays. labels Jul 10, 2018
@jreback jreback added this to the 0.24.0 milestone Jul 10, 2018
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. the only thing is rename _generate -> _generate_range, everything else can be future things

@@ -8,7 +8,7 @@
from pandas._libs.tslib import NaT, iNaT
from pandas._libs.tslibs.period import (
Period, IncompatibleFrequency, DIFFERENT_FREQ_INDEX,
get_period_field_arr, period_asfreq_arr)
get_period_field_arr, period_asfreq_arr, _quarter_to_myear)
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit on using privatized cython functions here (later PR)

@@ -157,6 +160,25 @@ def _from_ordinals(cls, values, freq=None):
result._freq = Period._maybe_convert_freq(freq)
return result

@classmethod
def _generate_range(cls, start, end, periods, freq, fields):
Copy link
Contributor

Choose a reason for hiding this comment

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

future pls add doc-string

# Constructor Helpers

def _get_ordinal_range(start, end, periods, freq, mult=1):
if com._count_not_none(start, end, periods) != 2:
Copy link
Contributor

Choose a reason for hiding this comment

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

future doc-string & comments



def _range_from_fields(year=None, month=None, quarter=None, day=None,
hour=None, minute=None, second=None, freq=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

future doc-string & comments

return np.array(ordinals, dtype=np.int64), freq


def _make_field_arrays(*fields):
Copy link
Contributor

Choose a reason for hiding this comment

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

doc-string

@@ -83,6 +101,52 @@ def __new__(cls, values, freq=None):

return result

@classmethod
def _generate(cls, start, end, periods, freq, closed=None, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

we call this _generate_range above, maybe in future can share some code in base class

# Constructor Helpers

def _generate_regular_range(start, end, periods, offset):
stride = offset.nanos
Copy link
Contributor

Choose a reason for hiding this comment

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

future doc-string

@jbrockmendel
Copy link
Member Author

rename _generate -> _generate_range, everything else can be future things

Will do.

@jbrockmendel
Copy link
Member Author

Thoughts on renaming (not this PR) arrays.period --> arrays.periods and arrays.timedelta --> arrays.timedeltas? For the core.indexes files datetimes and timedeltas are plural, period is not.

@jbrockmendel
Copy link
Member Author

rename _generate -> _generate_range, everything else can be future things

This caused some failures, reverted it until the next pass.

@jreback
Copy link
Contributor

jreback commented Jul 12, 2018

Thoughts on renaming (not this PR) arrays.period --> arrays.periods and arrays.timedelta --> arrays.timedeltas? For the core.indexes files datetimes and timedeltas are plural, period is not.

yes this is ok (separate PR)

@jreback
Copy link
Contributor

jreback commented Jul 12, 2018

This caused some failures, reverted it until the next pass.

hmm, ok sure

@jreback jreback merged commit 9d94a95 into pandas-dev:master Jul 12, 2018
@jreback
Copy link
Contributor

jreback commented Jul 12, 2018

thanks !

@jbrockmendel jbrockmendel deleted the dtarrays-constructors branch July 12, 2018 00:44
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype ExtensionArray Extending pandas with custom dtypes or arrays. Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants