Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions xarray/tests/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import pandas as pd
import pytest
from packaging.version import Version

import xarray as xr
import xarray.ufuncs as xu
Expand Down Expand Up @@ -719,13 +720,17 @@ def test_sparse_dask_dataset_repr(self):
ds = xr.Dataset(
data_vars={"a": ("x", sparse.COO.from_numpy(np.ones(4)))}
).chunk()
if Version(sparse.__version__) >= Version("0.16.0"):
meta = "sparse.numba_backend._coo.core.COO"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be a way to avoid depending on __module__? Alternatively, would there be a preference about what to keep it constant at? I'm happy to make a post1 release fixing this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a suggestion on what else to use. not sure if I understand the proposal for a constant. What kind of constant could you use here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. It's about keeping the Dask repr constant, which in turn uses __module__. I could change the module of all our functions/methods to be just "sparse" and making a post0 release.

else:
meta = "sparse.COO"
expected = dedent(
"""\
f"""\
<xarray.Dataset> Size: 32B
Dimensions: (x: 4)
Dimensions without coordinates: x
Data variables:
a (x) float64 32B dask.array<chunksize=(4,), meta=sparse.COO>"""
a (x) float64 32B dask.array<chunksize=(4,), meta={meta}>"""
)
assert expected == repr(ds)

Expand Down
Loading