BUG: incorrect handling of scipy.sparse.dok formats
State: closed

 - [x] closes #16179 
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff``

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

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=h1) Report
> Merging [#16191](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d50f981d768c3f9b870b8eb0be8f50783467e3be?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/16191/graphs/tree.svg?token=eZ4WkYLtcO&width=650&src=pr&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #16191      +/-   ##
==========================================
- Coverage   90.38%   90.37%   -0.02%     
==========================================
  Files         167      161       -6     
  Lines       50872    50863       -9     
==========================================
- Hits        45982    45968      -14     
- Misses       4890     4895       +5
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.16% <100%> (ø)` | :arrow_up: |
| #single | `40.32% <0%> (-0.11%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/sparse/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL2ZyYW1lLnB5) | `94.26% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/io/msgpack/\_version.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2lvL21zZ3BhY2svX3ZlcnNpb24ucHk=) | `44.86% <0%> (-55.14%)` | :arrow_down: |
| [pandas/core/util/hashing.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdXRpbC9oYXNoaW5nLnB5) | `92.03% <0%> (-7.02%)` | :arrow_down: |
| [pandas/core/computation/expressions.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vZXhwcmVzc2lvbnMucHk=) | `90.47% <0%> (-2.21%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.59% <0%> (-0.1%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.23% <0%> (-0.1%)` | :arrow_down: |
| [pandas/formats/style.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2Zvcm1hdHMvc3R5bGUucHk=) | | |
| [pandas/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL19faW5pdF9fLnB5) | | |
| [pandas/io/msgpack/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree#diff-cGFuZGFzL2lvL21zZ3BhY2svX19pbml0X18ucHk=) | | |
| ... and [18 more](https://codecov.io/gh/pandas-dev/pandas/pull/16191?src=pr&el=tree-more) | |

------

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

I added the whatsnew for 0.20.1. pls rebase and add a note in bug fixes.
@jreback 
rebased and notes added
can you add the test from the issue as well (with a comment as to the issue number). ping on green.
@jreback 
I've modified the test for the construction of SparseDataFrame from a sparse matrix to actually catch situations where the direct initialization from the array returns a different result. The reason these tests were succeeding in the past was because the array being tested on just happened to return the correct result by chance.
Should I add another, different test for this issue? Or is commenting on this issue where I have changed the tests enough?
your change looks fine. I would still like another test that is the exact replica from the issue as well. otherwise lgtm. ping on green.
@jreback 
Thanks, understood and tests have been added
thanks!