Skip to content

Commit 8731acc

Browse files
keewismax-sixty
andauthored
silence the dask dataframe upstream-dev errors (#4757)
Co-authored-by: Maximilian Roos <5635139+max-sixty@users.noreply.github.com>
1 parent 65beab8 commit 8731acc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

xarray/tests/test_dask.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,13 @@ def test_tokenize_duck_dask_array(self):
731731
class TestToDaskDataFrame:
732732
def test_to_dask_dataframe(self):
733733
# Test conversion of Datasets to dask DataFrames
734-
x = da.from_array(np.random.randn(10), chunks=4)
734+
x = np.random.randn(10)
735735
y = np.arange(10, dtype="uint8")
736736
t = list("abcdefghij")
737737

738-
ds = Dataset({"a": ("t", x), "b": ("t", y), "t": ("t", t)})
738+
ds = Dataset(
739+
{"a": ("t", da.from_array(x, chunks=4)), "b": ("t", y), "t": ("t", t)}
740+
)
739741

740742
expected_pd = pd.DataFrame({"a": x, "b": y}, index=pd.Index(t, name="t"))
741743

@@ -758,8 +760,8 @@ def test_to_dask_dataframe(self):
758760

759761
def test_to_dask_dataframe_2D(self):
760762
# Test if 2-D dataset is supplied
761-
w = da.from_array(np.random.randn(2, 3), chunks=(1, 2))
762-
ds = Dataset({"w": (("x", "y"), w)})
763+
w = np.random.randn(2, 3)
764+
ds = Dataset({"w": (("x", "y"), da.from_array(w, chunks=(1, 2)))})
763765
ds["x"] = ("x", np.array([0, 1], np.int64))
764766
ds["y"] = ("y", list("abc"))
765767

@@ -791,10 +793,15 @@ def test_to_dask_dataframe_2D_set_index(self):
791793

792794
def test_to_dask_dataframe_coordinates(self):
793795
# Test if coordinate is also a dask array
794-
x = da.from_array(np.random.randn(10), chunks=4)
795-
t = da.from_array(np.arange(10) * 2, chunks=4)
796+
x = np.random.randn(10)
797+
t = np.arange(10) * 2
796798

797-
ds = Dataset({"a": ("t", x), "t": ("t", t)})
799+
ds = Dataset(
800+
{
801+
"a": ("t", da.from_array(x, chunks=4)),
802+
"t": ("t", da.from_array(t, chunks=4)),
803+
}
804+
)
798805

799806
expected_pd = pd.DataFrame({"a": x}, index=pd.Index(t, name="t"))
800807
expected = dd.from_pandas(expected_pd, chunksize=4)

0 commit comments

Comments
 (0)