Skip to content

Commit

Permalink
silence the dask dataframe upstream-dev errors (#4757)
Browse files Browse the repository at this point in the history
Co-authored-by: Maximilian Roos <5635139+max-sixty@users.noreply.github.com>
  • Loading branch information
keewis and max-sixty authored Jan 4, 2021
1 parent 65beab8 commit 8731acc
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,13 @@ def test_tokenize_duck_dask_array(self):
class TestToDaskDataFrame:
def test_to_dask_dataframe(self):
# Test conversion of Datasets to dask DataFrames
x = da.from_array(np.random.randn(10), chunks=4)
x = np.random.randn(10)
y = np.arange(10, dtype="uint8")
t = list("abcdefghij")

ds = Dataset({"a": ("t", x), "b": ("t", y), "t": ("t", t)})
ds = Dataset(
{"a": ("t", da.from_array(x, chunks=4)), "b": ("t", y), "t": ("t", t)}
)

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

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

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

Expand Down Expand Up @@ -791,10 +793,15 @@ def test_to_dask_dataframe_2D_set_index(self):

def test_to_dask_dataframe_coordinates(self):
# Test if coordinate is also a dask array
x = da.from_array(np.random.randn(10), chunks=4)
t = da.from_array(np.arange(10) * 2, chunks=4)
x = np.random.randn(10)
t = np.arange(10) * 2

ds = Dataset({"a": ("t", x), "t": ("t", t)})
ds = Dataset(
{
"a": ("t", da.from_array(x, chunks=4)),
"t": ("t", da.from_array(t, chunks=4)),
}
)

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

0 comments on commit 8731acc

Please sign in to comment.