Skip to content
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

REF: Pieces broken off of #24024 #24364

Merged
merged 4 commits into from
Dec 23, 2018
Merged

Conversation

jbrockmendel
Copy link
Member

cc @TomAugspurger

If I did this right, this shouldn't cause rebasing headaches. LMK if I messed up on that and I'll try to fix.

Nearly everything here is verbatim from #24024. I'll comment inline with pieces that are not.

@@ -983,7 +983,7 @@ def dt64arr_to_periodarr(data, freq, tz=None):

"""
if data.dtype != np.dtype('M8[ns]'):
raise ValueError('Wrong dtype: %s' % data.dtype)
raise ValueError('Wrong dtype: {dtype}'.format(dtype=data.dtype))
Copy link
Member Author

Choose a reason for hiding this comment

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

Not from #24024, but @jreback commented there asking for this change.

start, end, periods,
freq=freq, tz=tz, normalize=normalize,
closed=closed, ambiguous=ambiguous)
return cls(dtarr, name=name)
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 think in #24024 this becomes cls._simple_new(dtarr, name=name). That isn't possible yet here.

Copy link
Member Author

Choose a reason for hiding this comment

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

ditto below and for TimedeltaIndex

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth doing this now then, when we'll just need to change it again?

Copy link
Member Author

Choose a reason for hiding this comment

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

The upside is that it means the diff in 24024 is just one line. I'm OK with this either way.


arr = TimedeltaArray(data, copy=True)
assert arr._data is not data
assert arr._data.base is not data
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 last line is not present in the test in #24024.

@@ -246,6 +247,17 @@ def test_to_datetime_parse_timezone_keeps_name(self):


class TestToDatetime(object):
def test_to_datetime_dtarr(self):
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 test is not in #24024, but this tests the changes in core.tools.datetimes

@jbrockmendel
Copy link
Member Author

In terms of LOC this shaves about 5% off of 24024. Not huge, but along with searchsorted, repeat, and reductions getting broken off, these add up

@codecov
Copy link

codecov bot commented Dec 19, 2018

Codecov Report

Merging #24364 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24364      +/-   ##
==========================================
+ Coverage   92.29%   92.29%   +<.01%     
==========================================
  Files         162      162              
  Lines       51832    51834       +2     
==========================================
+ Hits        47839    47841       +2     
  Misses       3993     3993
Flag Coverage Δ
#multiple 90.7% <100%> (ø) ⬆️
#single 42.99% <59.52%> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/core/arrays/datetimelike.py 96.46% <100%> (+0.01%) ⬆️
pandas/core/indexes/datetimelike.py 97.3% <100%> (ø) ⬆️
pandas/core/arrays/timedeltas.py 87.38% <100%> (+0.22%) ⬆️
pandas/core/arrays/datetimes.py 98.24% <100%> (ø) ⬆️
pandas/core/indexes/timedeltas.py 90.39% <100%> (-0.03%) ⬇️
pandas/core/arrays/period.py 98.5% <100%> (ø) ⬆️
pandas/core/reshape/merge.py 94.3% <100%> (ø) ⬆️
pandas/core/indexes/datetimes.py 96.32% <100%> (-0.01%) ⬇️
pandas/core/tools/datetimes.py 85.32% <100%> (+0.04%) ⬆️
pandas/core/indexes/base.py 96.27% <100%> (ø) ⬆️
... 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 f6cf7d9...d800f2b. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 19, 2018

Codecov Report

Merging #24364 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24364      +/-   ##
==========================================
+ Coverage   92.29%   92.29%   +<.01%     
==========================================
  Files         162      162              
  Lines       51832    51834       +2     
==========================================
+ Hits        47839    47841       +2     
  Misses       3993     3993
Flag Coverage Δ
#multiple 90.7% <100%> (ø) ⬆️
#single 42.99% <59.52%> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/core/arrays/datetimelike.py 96.46% <100%> (+0.01%) ⬆️
pandas/core/indexes/datetimelike.py 97.3% <100%> (ø) ⬆️
pandas/core/arrays/timedeltas.py 87.38% <100%> (+0.22%) ⬆️
pandas/core/arrays/datetimes.py 98.24% <100%> (ø) ⬆️
pandas/core/indexes/timedeltas.py 90.39% <100%> (-0.03%) ⬇️
pandas/core/arrays/period.py 98.5% <100%> (ø) ⬆️
pandas/core/reshape/merge.py 94.3% <100%> (ø) ⬆️
pandas/core/indexes/datetimes.py 96.32% <100%> (-0.01%) ⬇️
pandas/core/tools/datetimes.py 85.32% <100%> (+0.04%) ⬆️
pandas/core/indexes/base.py 96.27% <100%> (ø) ⬆️
... 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 f6cf7d9...cc3a301. Read the comment docs.

@TomAugspurger
Copy link
Contributor

#24024 doesn't apply cleanly on top of this.

Could we instead give a +1 to the changes here, and then you make a PR against my branch for #24024 with the new changes?

@jbrockmendel
Copy link
Member Author

Could we instead give a +1 to the changes here, and then you make a PR against my branch for #24024 with the new changes?

Will do.

This was referenced Dec 20, 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.

i would split out the hasnans change and do that separately as it needs to happen globally

(bamboo-dev) jreback@dev:~/pandas-dev$ grep -r hasnans pandas --include '*.py'|cut -d ' ' -f 1|uniq
pandas/core/arrays/timedeltas.py:
pandas/core/arrays/period.py:
pandas/core/arrays/datetimelike.py:
pandas/core/arrays/datetimes.py:
pandas/core/indexes/timedeltas.py:
pandas/core/indexes/interval.py:
pandas/core/indexes/category.py:
pandas/core/indexes/numeric.py:
pandas/core/indexes/datetimelike.py:
pandas/core/indexes/base.py:
pandas/core/dtypes/dtypes.py:
pandas/core/series.py:
pandas/core/resample.py:
pandas/core/base.py:
pandas/tests/test_lib.py:
pandas/tests/indexes/datetimes/test_ops.py:
pandas/tests/indexes/interval/test_interval.py:
pandas/tests/indexes/period/test_ops.py:
pandas/tests/indexes/multi/test_missing.py:
pandas/tests/indexes/multi/test_missing.py:def
pandas/tests/indexes/multi/test_missing.py:
pandas/tests/indexes/common.py:
pandas/tests/indexes/timedeltas/test_ops.py:
pandas/tests/indexes/test_common.py:
pandas/tests/series/test_internals.py:def
pandas/tests/series/test_internals.py:

@@ -451,7 +464,7 @@ def _isnan(self):
return (self.asi8 == iNaT)

@property # NB: override with cache_readonly in immutable subclasses
def hasnans(self):
def _hasnans(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC this is a general Index property, are changing this globally? (ok by me)

@jreback jreback added the Internals Related to non-user accessible pandas implementation label Dec 21, 2018
@TomAugspurger
Copy link
Contributor

TomAugspurger commented Dec 21, 2018 via email

@jbrockmendel
Copy link
Member Author

I don't think anyone was suggesting changing that anywhere other than on the datelike Array classes,

This matches what I had in mind, just doing it on DTI/TDI/PI.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Dec 21, 2018 via email

@jbrockmendel
Copy link
Member Author

Probably a typo. Lots of open windows ATM.

@jreback
Copy link
Contributor

jreback commented Dec 21, 2018

What do you mean by globally changing the hasnans? I don't think anyone was
suggesting changing that anywhere other than on the datelike Array classes,
where we (I) don't want them as part of the public API.

that's fine, but wont' accept a change that also does not fix the existing Index codebases. This is SO confusing you need as much consistency as possible.

@TomAugspurger
Copy link
Contributor

I'm pretty confused right now, so I'll restate what Brock and I are saying.

  1. The hasnans property shouldn't be part of the public API for Datetime-like arrays. It's duplicative with isna()
  2. Index.hasnans is a well-established API that we don't want to change.

Maybe you could restate what you're looking for @jreback?

@jbrockmendel
Copy link
Member Author

Did we ever reach a consensus here?

@jreback jreback added this to the 0.24.0 milestone Dec 23, 2018
@jreback jreback merged commit d7bf6f2 into pandas-dev:master Dec 23, 2018
@jreback
Copy link
Contributor

jreback commented Dec 23, 2018

thanks. I realized you are just changing the non-Index idiom here which is in-line with other idioms.

@jbrockmendel jbrockmendel deleted the less24024 branch December 23, 2018 16:37
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants