[Bug] Comparison between two PeriodIndexes doesn't validate length (GH #23078)
State: closed

- [x] closes #23078
- [x] tests added
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Period
description: Period data type
name: ExtensionArray
description: Extending pandas with custom dtypes or arrays.

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





















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

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

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

```diff
@@            Coverage Diff             @@
##           master   #23896      +/-   ##
==========================================
+ Coverage    92.3%   92.31%   +<.01%     
==========================================
  Files         163      163              
  Lines       51950    51954       +4     
==========================================
+ Hits        47953    47961       +8     
+ Misses       3997     3993       -4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.72% <100%> (ø)` | :arrow_up: |
| #single | `42.99% <25%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23896?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/23896/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `97.59% <100%> (+0.04%)` | :arrow_up: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23896/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `98.48% <100%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/23896/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.84% <0%> (+0.09%)` | :arrow_up: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/23896/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `96.57% <0%> (+0.21%)` | :arrow_up: |
| [pandas/core/arrays/integer.py](https://codecov.io/gh/pandas-dev/pandas/pull/23896/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVnZXIucHk=) | `96.23% <0%> (+0.68%)` | :arrow_up: |

------

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

@makbigc when you update for @jreback's feedback, can you add a couple new base tests to `BaseComparisonOpsTests` and `BaseArithmeticOpsTests` ensure that a ValueError is raised when comparing / operating on two EAs with different lengths? These are in `tests/extension/base/ops.py`.
@makbigc can you merge master and update
this overlaps with #24397 @jbrockmendel can you comment here
Should I close this PR? Because #23078 was already resolved by #24397. The length check is done in the wrapper of _period_array_cmp. This is not need to add _validate_shape additionally.

The generic base test cannot handle all six EA subclasses:
- Integer array: deprecationwarning raised by numpy
- category: only __eq__ and __ne__ comparison are implemented
- json: no json comparison

The raise of ValueError for DecimalArray could be implemented in a new PR. 
@jreback @TomAugspurger  Thank you for your review.