MAINT: Remove np.array_equal calls in tests
State: closed

Preferable to use `tm.assert_numpy_array_equal` instead.

Labels:
name: Testing
description: pandas testing functions or related to the test suite

Comments:
A couple of questions going forward:

1) There are several instances where they used `np.array_equal` to check *non-array inequality*.  Would it be useful to create a method called `tm.assert_numpy_array_not_equal` for this case?

2) `tm.assert_numpy_array_equal` enforces that we must be comparing two `numpy` arrays, which makes it slightly cumbersome at times to compare two arrays (e.g. they are lists).  Perhaps we could take a page out of `numpy` book and create a function called `tm.assert_array_equal` ?
> There are several instances where they used np.array_equal to check non-array inequality. Would it be useful to create a method called tm.assert_numpy_array_not_equal for this case?

this has come up a couple of times, sure I guess that would be ok

> tm.assert_numpy_array_equal enforces that we must be comparing two numpy arrays, which makes it slightly cumbersome at times to compare two arrays (e.g. they are lists). Perhaps we could take a page out of numpy book and create a function called tm.assert_array_equal ?

no,  list comparison is directly handled by assert

> need to add `np.array_equal` to the black-list in ci/lint.sh (near the end)

There are many instances of this method being called in the source code...I think it shouldn't be allowed in tests BUT be careful with source code though.
> There are many instances of this method being called in the source code...I think it shouldn't be allowed in tests BUT be careful with source code though.

that line in lint should be

``grep -r -E --include '*.py' --exclude testing.py '(numpy|np)\.testing' pandas\tests``
(and have to add in the check for array_equal in the regex)
e.g.
```
(pandas) bash-3.2$   grep -r -E --include '*.py' --exclude testing.py '(numpy|np)\.testing|(numpy|np)\.array_equal' pandas/tests
pandas/tests/dtypes/test_cast.py:        assert (np.array_equal(result, arr))
pandas/tests/dtypes/test_cast.py:        assert (np.array_equal(result, expected))
```
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=h1) Report
> Merging [#18047](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/881ee30b443f8b9651068b819ecd43adca5789b5?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #18047      +/-   ##
==========================================
- Coverage   91.25%   91.23%   -0.02%     
==========================================
  Files         163      163              
  Lines       50115    50114       -1     
==========================================
- Hits        45730    45720      -10     
- Misses       4385     4394       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.04% <ø> (-0.01%)` | :arrow_down: |
| #single | `40.24% <ø> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <0%> (-0.1%)` | :arrow_down: |
| [pandas/tslib.py](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree#diff-cGFuZGFzL3RzbGliLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/compat/pickle\_compat.py](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9waWNrbGVfY29tcGF0LnB5) | `75.6% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18047?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/18047?src=pr&el=footer). Last update [881ee30...c7d2e38](https://codecov.io/gh/pandas-dev/pandas/pull/18047?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/18047?src=pr&el=h1) Report
> Merging [#18047](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/15fa4bd62c5c7ac7ac618a7e68742b7eb1f90d21?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #18047      +/-   ##
==========================================
- Coverage   91.25%   91.23%   -0.03%     
==========================================
  Files         163      163              
  Lines       50120    50115       -5     
==========================================
- Hits        45737    45721      -16     
- Misses       4383     4394      +11
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.04% <ø> (-0.01%)` | :arrow_down: |
| #single | `40.23% <ø> (-0.15%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/io/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree#diff-cGFuZGFzL2lvL2h0bWwucHk=) | `85.17% <0%> (-0.81%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <0%> (-0.1%)` | :arrow_down: |
| [pandas/core/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/18047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS5weQ==) | `92.03% <0%> (-0.01%)` | :arrow_down: |

------

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

@gfyoung can you do [this](https://github.com/pandas-dev/pandas/pull/18047#issuecomment-340880213) so we can ensure these don't appear going forward
@jreback : There are several instances that I did not remove yet because I want to do a more thorough refactoring in light of my comment <a href="https://github.com/pandas-dev/pandas/pull/18047#issuecomment-340659137">above</a>

I'll do that in a follow-up PR if that works.
that sounds good @gfyoung thanks!