BUG: Add SparseArray.all
State: closed

- [x] closes #xxxx
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

This is the part of https://github.com/pandas-dev/pandas/pull/17386.
`Block.where` uses `ndarray.all`, but there is no such method in `SparseArray`.
This makes that `all` evaluates `SparseArray([False, False, True])` as `True`.
https://github.com/pandas-dev/pandas/blob/master/pandas/core/internals.py#L1400

Labels:
name: Bug
name: Sparse
description: Sparse Data Type

Comments:
@jreback Thanks for your review.
- Changed the `fill_value` check method and now we are not using `tolist()`.
- Removed `dtype` parameter validation check.
There is no `dtype` parameter on `ndarray.all`.
- Also added `SparseArray.any`.
- There seems to be no specific issue for this.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=h1) Report
> Merging [#17570](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/37e23d03e1ba2298d9df05ded69028dfac0e823e?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #17570      +/-   ##
==========================================
- Coverage   91.22%    91.2%   -0.02%     
==========================================
  Files         163      163              
  Lines       49625    49642      +17     
==========================================
+ Hits        45270    45277       +7     
- Misses       4355     4365      +10
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.99% <100%> (ø)` | :arrow_up: |
| #single | `40.19% <41.17%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/compat/numpy/function.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9udW1weS9mdW5jdGlvbi5weQ==) | `93.33% <100%> (+0.2%)` | :arrow_up: |
| [pandas/core/sparse/array.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL2FycmF5LnB5) | `91.31% <100%> (+0.01%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.77% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17570?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/17570?src=pr&el=footer). Last update [37e23d0...5d04485](https://codecov.io/gh/pandas-dev/pandas/pull/17570?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/17570?src=pr&el=h1) Report
> Merging [#17570](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/074b4850151cd2785f670e1d18c412e46c509f60?src=pr&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #17570      +/-   ##
==========================================
- Coverage   91.24%    91.2%   -0.05%     
==========================================
  Files         163      163              
  Lines       49766    49642     -124     
==========================================
- Hits        45411    45276     -135     
- Misses       4355     4366      +11
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.99% <100%> (-0.04%)` | :arrow_down: |
| #single | `40.19% <41.17%> (-0.21%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/compat/numpy/function.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9udW1weS9mdW5jdGlvbi5weQ==) | `93.33% <100%> (+0.2%)` | :arrow_up: |
| [pandas/core/sparse/array.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL2FycmF5LnB5) | `91.31% <100%> (-0.28%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/util/\_decorators.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RlY29yYXRvcnMucHk=) | `66% <0%> (-12%)` | :arrow_down: |
| [pandas/core/dtypes/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL21pc3NpbmcucHk=) | `87.19% <0%> (-3.26%)` | :arrow_down: |
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `96.01% <0%> (-0.56%)` | :arrow_down: |
| [pandas/core/indexes/range.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9yYW5nZS5weQ==) | `92.59% <0%> (-0.25%)` | :arrow_down: |
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `97% <0%> (-0.15%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `95.57% <0%> (-0.14%)` | :arrow_down: |
| ... and [32 more](https://codecov.io/gh/pandas-dev/pandas/pull/17570?src=pr&el=tree-more) | |

------

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

@jreback Thank you. These are now fixed.
@jreback ~~I found the bug in this solution. When `fill_value = np.array([1,1,1])`, `np.all(fill_value)` returns True. In numpy, `np.array([np.array([1,1,1]), 0, np.array([1,1,1])], dtype=np.object).all()` raise `ValueError`, but this is not. I'll fix.~~

**UPDATE:** I found `SparseArray` does not allow `ndarray` as `fill_value`, so this will not happen. I am sorry for the mistake.
lgtm. waiting for CI to go green again before merging (unrelated conda-ish issues)
can you rebase
@jreback Rebased.
thanks @Licht-T