Repository: pydata/sparse

Issue:
zeros_like return COO format even if DOK is asked
### Bug description

Maybe it is normal behavior but imho it shoud not be. `zeros_like` function return COO format even if DOK is asked.

### Example

```
In[1]: import numpy as np
In[2]: import sparse as sp
In[3]: a = np.random.random((10,10,10))
In[4]: s = sp.zeros_like(a, format='dok')
In[5]: s
Out[5]: <COO: shape=(10, 10, 10), dtype=float64, nnz=0, fill_value=0.0>
```
Note that even starting from a COO and asking for a DOK doesn't work:

```
In[6]: d = sp.zeros_like(s, format='dok')
In[7]: d
Out[7]: <COO: shape=(10, 10, 10), dtype=float64, nnz=0, fill_value=0.0>
```

### Expected behavior

 `zeros_like` should return DOK format if DOK format is asked.

### System

 - OS and version: Ubuntu 18.04.4 LTS (kernel 5.3.0-62-generic)
-  Python 3.8.3
 - `sparse` version: 0.10.0 (from conda-forge)
 - NumPy version: 1.18.5
 - Numba version: 0.50.1

### Additional comment

I looked for a previous notice of this bug but found none. Sorry if it was already reported.
For the moment, I bypass this by using `zeros` (which works) instead.




Discussion:

Patch:
diff --git a/sparse/_common.py b/sparse/_common.py
index 913000d..59471fd 100644
--- a/sparse/_common.py
+++ b/sparse/_common.py
@@ -329,7 +329,7 @@ def zeros_like(a, dtype=None, format=None, compressed_axes=None):
     """
     if format is None and not isinstance(a, np.ndarray):
         format = type(a).__name__.lower()
-    else:
+    elif format is None:
         format = "coo"
     if hasattr(a, "compressed_axes") and compressed_axes is None:
         compressed_axes = a.compressed_axes


Test patch:
diff --git a/sparse/tests/test_dok.py b/sparse/tests/test_dok.py
index e670684..1e0b210 100644
--- a/sparse/tests/test_dok.py
+++ b/sparse/tests/test_dok.py
@@ -158,3 +158,11 @@ def test_empty_dok_dtype():
     d = sparse.DOK(5, dtype=np.uint8)
     s = sparse.COO(d)
     assert s.dtype == d.dtype
+
+
+def test_zeros_like():
+    s = sparse.random((2, 3, 4), density=0.5)
+    s2 = sparse.zeros_like(s, format="dok")
+    assert s.shape == s2.shape
+    assert s.dtype == s2.dtype
+    assert isinstance(s2, sparse.DOK)