-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Move constructor helpers to EAMixins #21845
Conversation
Codecov Report
@@ 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
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. 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) |
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.
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): |
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.
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: |
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.
future doc-string & comments
|
||
|
||
def _range_from_fields(year=None, month=None, quarter=None, day=None, | ||
hour=None, minute=None, second=None, freq=None): |
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.
future doc-string & comments
return np.array(ordinals, dtype=np.int64), freq | ||
|
||
|
||
def _make_field_arrays(*fields): |
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.
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): |
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.
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 |
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.
future doc-string
Will do. |
…arrays-constructors
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. |
This caused some failures, reverted it until the next pass. |
yes this is ok (separate PR) |
hmm, ok sure |
thanks ! |
Takes the place of #21843, porting constructor helpers. While this is in review I'm going to start porting tests in earnest.