Skip to content

REF: Remove DatetimelikeArrayMixin._shallow_copy #23430

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 3 commits into from
Nov 2, 2018

Conversation

jbrockmendel
Copy link
Member

Broken off of #23426.

@pep8speaks
Copy link

Hello @jbrockmendel! Thanks for submitting the PR.

@codecov
Copy link

codecov bot commented Oct 31, 2018

Codecov Report

Merging #23430 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #23430      +/-   ##
==========================================
- Coverage   92.21%   92.21%   -0.01%     
==========================================
  Files         161      161              
  Lines       51173    51168       -5     
==========================================
- Hits        47190    47185       -5     
  Misses       3983     3983
Flag Coverage Δ
#multiple 90.65% <100%> (-0.01%) ⬇️
#single 42.24% <44.44%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/arrays/datetimelike.py 96.05% <100%> (-0.07%) ⬇️
pandas/core/indexes/datetimes.py 96.45% <100%> (+0.01%) ⬆️
pandas/core/arrays/datetimes.py 97.9% <100%> (ø) ⬆️
pandas/core/indexes/datetimelike.py 98.01% <100%> (-0.01%) ⬇️

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 de39bfc...e0f02db. Read the comment docs.

@gfyoung gfyoung added Refactor Internal refactoring of code Clean Datetime Datetime data dtype labels Oct 31, 2018
@gfyoung
Copy link
Member

gfyoung commented Oct 31, 2018

Looks fine to me. A couple of points:

  • Any performance impact with this refactor?
  • For the less initiated, why don't we want to use _shallow_copy ?

@jbrockmendel
Copy link
Member Author

Any performance impact with this refactor?

If anything, it removes a level of function-call overhead. Should not make a measurable impact.

For the less initiated, why don't we want to use _shallow_copy ?

_shallow_copy was implemented in these EA mixin classes to make them play nicely when inherited by their respective Index subclasses. We are moving away from having these get mixed in, and do not need _shallow_copy in the standalone EA subclasses.

@jreback
Copy link
Contributor

jreback commented Nov 2, 2018

thanks

@@ -586,7 +586,7 @@ def tz_convert(self, tz):
'tz_localize to localize')

# No conversion since timestamps are all UTC to begin with
return self._shallow_copy(tz=tz)
return self._simple_new(self.asi8, tz=tz, freq=self.freq)
Copy link
Member

Choose a reason for hiding this comment

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

Why self.asi8 and not self or self._data here? Simple_new doesn't take M8 values?

Copy link
Member Author

Choose a reason for hiding this comment

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

_simple_new(int64values, tz=tz) will get you the same thing as __new__(int64values, tz=tz), but the same is not true with M8 values. I find that really helpful.

Copy link
Member

Choose a reason for hiding this comment

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

You are referring to the timezone difference you mentioned earlier?

I personally find that very confusing that DatetimeArray(self._data, tz=..) and DatetimeArray(self._data.view(int), tz=..) do not give the same. To the extent possible, I would not repeat this pattern for our Arrays?
(of course, in the DatetimeIndex constructor we cannot just change it, unless we want to deprecate that first).

@jbrockmendel jbrockmendel deleted the simple2 branch November 2, 2018 14:59
thoo added a commit to thoo/pandas that referenced this pull request Nov 3, 2018
…xamples

* repo_org/master: (66 commits)
  CLN: doc string (pandas-dev#23469)
  DOC: Add cookbook entry for triangular correlation matrix (GH22840) (pandas-dev#23032)
  add number of Errors, Warnings to scripts/validate_docstrings.py (pandas-dev#23150)
  BUG: Allow freq conversion from dt64 to period (pandas-dev#23460)
  ENH: Add FrozenList.union and .difference (pandas-dev#23394)
  REF: cython cleanup, typing, optimizations (pandas-dev#23464)
  strictness and checks for Timedelta _simple_new (pandas-dev#23433)
  Fixing flake8 problems new to flake8 3.6.0 (pandas-dev#23472)
  DOC: Updating the docstring of Series.dot  (pandas-dev#22890)
  TST: Fixturize series/test_analytics.py (pandas-dev#22755)
  BUG/ENH: Handle NonexistentTimeError in date rounding (pandas-dev#23406)
  PERF: speed up concat on Series by making _get_axis_number() a classmethod (pandas-dev#23404)
  REF: Remove DatetimelikeArrayMixin._shallow_copy (pandas-dev#23430)
  REF: strictness/simplification in DatetimeArray/Index _simple_new (pandas-dev#23431)
  REF: cython cleanup, typing, optimizations (pandas-dev#23456)
  TST: tweak Hypothesis configuration and idioms (pandas-dev#23441)
  BUG: fix HDFStore.append with all empty strings error (GH12242) (pandas-dev#23435)
  TST: Skip 32bit failing IntervalTree tests (pandas-dev#23442)
  BUG: Deprecate nthreads argument (pandas-dev#23112)
  style: fix import format at pandas/core/reshape (pandas-dev#23387)
  ...
tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request Nov 19, 2018
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
Clean Datetime Datetime data dtype Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants