REF: move range-generation functions to EA mixin classes
State: closed

With the DatetimeArray range-generating functions moved, we are finally able to move `shift`, and in turn `__add__`, `__sub__`, etc.  

Two non-trivial changes made during the move process, see inline comments.

Upcoming commits will add docstrings and port tests.  ATM many tests are a PITA bc the Array contructors don't know how to handle lists of strings.  Trying to find a way to implement that in `__new__` without having it become a total mess.

Labels:
name: Refactor
description: Internal refactoring of code
name: ExtensionArray
description: Extending pandas with custom dtypes or arrays.

Comments:
Hello @jbrockmendel! Thanks for updating the PR.



















Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on July 25, 2018 at 19:12 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22016?src=pr&el=h1) Report
> Merging [#22016](https://codecov.io/gh/pandas-dev/pandas/pull/22016?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/a6c7387cd43ddc45ac1a4a354c7ac5019fa69678?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `94.64%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/22016/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/22016?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #22016      +/-   ##
==========================================
+ Coverage   92.02%   92.03%   +<.01%     
==========================================
  Files         170      170              
  Lines       50707    50743      +36     
==========================================
+ Hits        46661    46699      +38     
+ Misses       4046     4044       -2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.44% <94.64%> (+0.01%)` | :arrow_up: |
| #single | `42.35% <56.85%> (+0.03%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22016?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/22016/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `91.16% <100%> (-0.23%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/22016/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.37% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/22016/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `91.22% <100%> (+0.03%)` | :arrow_up: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/22016/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.68% <100%> (+0.55%)` | :arrow_up: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/22016/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `97.77% <100%> (+0.42%)` | :arrow_up: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/22016/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `95.46% <91.2%> (-0.85%)` | :arrow_down: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/22016/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `92.53% <95%> (+0.77%)` | :arrow_up: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/22016/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `95.06% <96.46%> (+0.57%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22016?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22016?src=pr&el=footer). Last update [a6c7387...e33ff43](https://codecov.io/gh/pandas-dev/pandas/pull/22016?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

> hmm this list conversion is problematic

Why?
> hmm this list conversion is problematic

you are turning an array into a list, only to turn it back to an array
> you are turning an array into a list, only to turn it back to an array

It's the same in the existing implementation; we can open an issue if there's a real perf impact.
> it's the same in the existing implementation; we can open an issue if there's a real perf impact.

ok if that's true, then this is prob an overblow concern. pls give a quick test to see if this is actually an issue.

rebase in an y event.
thanks @jbrockmendel, pls follow up with @jorisvandenbossche comments in next PR
@TomAugspurger I think with this PeriodArrayMixin has everything needed for comparisons+arithmetic, so PeriodBlock should be viable.
@jbrockmendel you are planning to do a PR for that?
> you are planning to do a PR for that?

IIRC Tom wanted to be informed when the arith/compare parts were ready so he could forge ahead with PeriodBlock.

My current focus is on fixing DataFrame/Series ops inconsistencies by having DataFrame dispatch to Series (#22068, #22019) and getting thorough tests for these new EA subclasses (#22033)
Thanks.

I'm hoping to knock out SparseArray this week or, so if anyone else wants
to do Period then by all means.
Otherwise I'll start on it after sparse.

On Thu, Jul 26, 2018 at 3:55 PM jbrockmendel <notifications@github.com>
wrote:

> you are planning to do a PR for that?
>
> IIRC Tom wanted to be informed when the arith/compare parts were ready so
> he could forge ahead with PeriodBlock.
>
> My current focus is on fixing DataFrame/Series ops inconsistencies by
> having DataFrame dispatch to Series (#22068
> <https://github.com/pandas-dev/pandas/pull/22068>, #22019
> <https://github.com/pandas-dev/pandas/pull/22019>) and getting thorough
> tests for these new EA subclasses (#22033
> <https://github.com/pandas-dev/pandas/pull/22033>)
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/22016#issuecomment-408232156>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIsw1L1ZtLtEcms0BN-7aHudIiGqrks5uKiy0gaJpZM4VZwvc>
> .
>

@jbrockmendel since you are now very familiar with code, I would say, certainly go ahead (if you have time of course)