-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
REF: be stricter about what we pass to _simple_new #31055
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
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 |
---|---|---|
|
@@ -177,12 +177,13 @@ def __new__( | |
tdarr = TimedeltaArray._from_sequence( | ||
data, freq=freq, unit=unit, dtype=dtype, copy=copy | ||
) | ||
return cls._simple_new(tdarr._data, freq=tdarr.freq, name=name) | ||
return cls._simple_new(tdarr, name=name) | ||
|
||
@classmethod | ||
def _simple_new(cls, values, name=None, freq=None, dtype=_TD_DTYPE): | ||
# `dtype` is passed by _shallow_copy in corner cases, should always | ||
# be timedelta64[ns] if present | ||
|
||
if not isinstance(values, TimedeltaArray): | ||
values = TimedeltaArray._simple_new(values, dtype=dtype, freq=freq) | ||
else: | ||
|
@@ -420,7 +421,8 @@ def insert(self, loc, item): | |
new_i8s = np.concatenate( | ||
(self[:loc].asi8, [item.view(np.int64)], self[loc:].asi8) | ||
) | ||
return self._shallow_copy(new_i8s, freq=freq) | ||
tda = type(self._data)._simple_new(new_i8s, freq=freq) | ||
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. doen't this copy twice? 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. no, simple_new doesnt make a copy 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. k, that's what i thought, can you (followup ok), document this loudly in the _simple_new |
||
return self._shallow_copy(tda) | ||
except (AttributeError, TypeError): | ||
|
||
# fall back to object index | ||
|
@@ -507,4 +509,4 @@ def timedelta_range( | |
|
||
freq, freq_infer = dtl.maybe_infer_freq(freq) | ||
tdarr = TimedeltaArray._generate_range(start, end, periods, freq, closed=closed) | ||
return TimedeltaIndex._simple_new(tdarr._data, freq=tdarr.freq, name=name) | ||
return TimedeltaIndex._simple_new(tdarr, name=name) |
Uh oh!
There was an error while loading. Please reload this page.