TimedeltaArray freq validation without _from_sequence
State: closed

This aligns `TimedeltaArray.__init__` with `DatetimeArray.__init__`, using the same approach how @jbrockmendel now handled the freq validation in `DatetimeArray` in the merged https://github.com/pandas-dev/pandas/pull/24686 
First commits removes usage of `from_sequence` (from https://github.com/pandas-dev/pandas/pull/24666), second commit adds the freq validation as in https://github.com/pandas-dev/pandas/pull/24686 

So related to the discussion at the end https://github.com/pandas-dev/pandas/pull/24666 (and a partial revert of that). This makes the `TimedeltaArray` constructor again more restricted (only accepts correctly typed (int or timedelta64) containers. 
Until we decide on the constructors in general (https://github.com/pandas-dev/pandas/issues/24684), I would prefer to keep them strict: it is always easier to later expand functionality (and then also test it), than remove functionality.

Labels:
name: Timedelta
description: Timedelta data type

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24723?src=pr&el=h1) Report
> Merging [#24723](https://codecov.io/gh/pandas-dev/pandas/pull/24723?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d46d2a5ea900c59439dff58942e79ea8b39e918d?src=pr&el=desc) will **decrease** coverage by `49.31%`.
> The diff coverage is `64.7%`.

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

```diff
@@             Coverage Diff             @@
##           master   #24723       +/-   ##
===========================================
- Coverage   92.38%   43.07%   -49.32%     
===========================================
  Files         166      166               
  Lines       52321    52344       +23     
===========================================
- Hits        48337    22545    -25792     
- Misses       3984    29799    +25815
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `?` | |
| #single | `43.07% <64.7%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24723?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `41.25% <64.7%> (-46.61%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-99.35%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `0% <0%> (-95.46%)` | :arrow_down: |
| [pandas/io/sas/sas7bdat.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXM3YmRhdC5weQ==) | `0% <0%> (-91.17%)` | :arrow_down: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfeHBvcnQucHk=) | `0% <0%> (-90.15%)` | :arrow_down: |
| ... and [124 more](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24723?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/24723?src=pr&el=footer). Last update [d46d2a5...19c5160](https://codecov.io/gh/pandas-dev/pandas/pull/24723?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24723?src=pr&el=h1) Report
> Merging [#24723](https://codecov.io/gh/pandas-dev/pandas/pull/24723?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d46d2a5ea900c59439dff58942e79ea8b39e918d?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `94.11%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24723      +/-   ##
==========================================
+ Coverage   92.38%   92.38%   +<.01%     
==========================================
  Files         166      166              
  Lines       52321    52344      +23     
==========================================
+ Hits        48337    48360      +23     
  Misses       3984     3984
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.81% <94.11%> (ø)` | :arrow_up: |
| #single | `43.07% <64.7%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24723?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `88.21% <94.11%> (+0.35%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24723/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.09% <0%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24723?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/24723?src=pr&el=footer). Last update [d46d2a5...19c5160](https://codecov.io/gh/pandas-dev/pandas/pull/24723?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Doing this for the RC?
I would personally do that, but it might need some discussion with @jreback / @jbrockmendel ?
Yeah. Though I'm also comfortable with doing this after the RC is tagged, but before 0.24.0.
looks fine. @jbrockmendel 
I think let's just do this now. Apologies for ramming this through @jbrockmendel.
No sweat; I'm eager to see the RC too.

This does re-add a lot of redundant code.  If the only objection to the previous implementation was that it let too many dtypes through, then just disallow those in the same line that disallowed np.bool_
> This does re-add a lot of redundant code. If the only objection to the previous implementation was that it let too many dtypes through, then just disallow those in the same line that disallowed np.bool_

Looking back at the discussion, I think other concerns were performance / the `sequence_to_td64` doing too much other work ?