Skip to content

Commit

Permalink
Simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed Dec 5, 2022
1 parent 6e89140 commit 5d3a5d3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3261,19 +3261,18 @@ def test_from_series_sparse(self) -> None:

@requires_sparse
def test_sparse_nbytes(self) -> None:
# https://github.com/pydata/xarray/issues/4842#issue-793245791
df = pd.DataFrame()
df["x"] = np.repeat(np.random.rand(10_000), 10)
df["y"] = np.repeat(np.random.rand(10_000), 10)
df["time"] = np.tile(
pd.date_range("2000-01-01", "2000-03-10", freq="W"), 10_000
)
df["x"] = np.repeat(np.random.rand(10), 10)
df["y"] = np.repeat(np.random.rand(10), 10)
df["time"] = np.tile(pd.date_range("2000-01-01", "2000-03-10", freq="W"), 10)
df["rate"] = 10.0
df = df.set_index(["time", "y", "x"])

sparse_ds = xr.Dataset.from_dataframe(df, sparse=True)
rate = sparse_ds["rate"]
assert rate.nbytes < 8000000000
assert rate.size * rate.dtype.itemsize == 8000000000
assert rate.nbytes < 8000
assert rate.size * rate.dtype.itemsize == 8000

@requires_sparse
def test_from_multiindex_series_sparse(self) -> None:
Expand Down

0 comments on commit 5d3a5d3

Please sign in to comment.