Skip to content

Commit

Permalink
Fix ci after pytest changes (#11082)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl committed Apr 29, 2024
1 parent dafb6ac commit a453f19
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 20 deletions.
7 changes: 4 additions & 3 deletions dask/array/tests/test_array_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ def test_stack_rechunk():


def test_stack_unknown_chunksizes():
dd = pytest.importorskip("dask.dataframe")
pd = pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")

a_df = pd.DataFrame({"x": np.arange(12)})
b_df = pd.DataFrame({"y": np.arange(12) * 10})
Expand Down Expand Up @@ -546,8 +546,8 @@ def test_concatenate_types(dtypes):


def test_concatenate_unknown_axes():
dd = pytest.importorskip("dask.dataframe")
pd = pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")

a_df = pd.DataFrame({"x": np.arange(12)})
b_df = pd.DataFrame({"y": np.arange(12) * 10})
Expand Down Expand Up @@ -2211,6 +2211,7 @@ def test_to_hdf5():


def test_to_dask_dataframe():
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
a = da.ones((4,), chunks=(2,))
d = a.to_dask_dataframe()
Expand Down Expand Up @@ -2770,8 +2771,8 @@ def test_asarray(asarray):
@pytest.mark.parametrize("asarray", [da.asarray, da.asanyarray])
def test_asarray_dask_dataframe(asarray):
# https://github.com/dask/dask/issues/3885
pd = pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
import pandas as pd

s = dd.from_pandas(pd.Series([1, 2, 3, 4]), 2)
result = asarray(s)
Expand Down
11 changes: 10 additions & 1 deletion dask/array/tests/test_rechunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def test_rechunk_same():


def test_rechunk_same_fully_unknown():
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
x = da.ones(shape=(10, 10), chunks=(5, 10))
y = dd.from_array(x).values
Expand All @@ -299,6 +300,7 @@ def test_rechunk_same_fully_unknown_floats():
"""Similar to test_rechunk_same_fully_unknown but testing the behavior if
``float("nan")`` is used instead of the recommended ``np.nan``
"""
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
x = da.ones(shape=(10, 10), chunks=(5, 10))
y = dd.from_array(x).values
Expand All @@ -308,6 +310,7 @@ def test_rechunk_same_fully_unknown_floats():


def test_rechunk_same_partially_unknown():
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
x = da.ones(shape=(10, 10), chunks=(5, 10))
y = dd.from_array(x).values
Expand Down Expand Up @@ -592,8 +595,8 @@ def test_intersect_nan_long():


def test_rechunk_unknown_from_pandas():
dd = pytest.importorskip("dask.dataframe")
pd = pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")

arr = np.random.default_rng().standard_normal((50, 10))
x = dd.from_pandas(pd.DataFrame(arr), 2).values
Expand All @@ -606,6 +609,7 @@ def test_rechunk_unknown_from_pandas():


def test_rechunk_unknown_from_array():
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
# pd = pytest.importorskip('pandas')
x = dd.from_array(da.ones(shape=(4, 4), chunks=(2, 2))).values
Expand Down Expand Up @@ -635,6 +639,7 @@ def test_rechunk_unknown_from_array():
],
)
def test_rechunk_with_fully_unknown_dimension(x, chunks):
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
y = dd.from_array(x).values
result = y.rechunk(chunks)
Expand All @@ -661,6 +666,7 @@ def test_rechunk_with_fully_unknown_dimension(x, chunks):
],
)
def test_rechunk_with_partially_unknown_dimension(x, chunks):
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
y = dd.from_array(x).values
z = da.concatenate([x, y])
Expand All @@ -680,6 +686,7 @@ def test_rechunk_with_partially_unknown_dimension(x, chunks):
],
)
def test_rechunk_with_fully_unknown_dimension_explicit(new_chunks):
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
x = da.ones(shape=(10, 10), chunks=(5, 2))
y = dd.from_array(x).values
Expand All @@ -698,6 +705,7 @@ def test_rechunk_with_fully_unknown_dimension_explicit(new_chunks):
],
)
def test_rechunk_with_partially_unknown_dimension_explicit(new_chunks):
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
x = da.ones(shape=(10, 10), chunks=(5, 2))
y = dd.from_array(x).values
Expand All @@ -715,6 +723,7 @@ def assert_chunks_match(left, right):


def test_rechunk_unknown_raises():
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")

x = da.ones(shape=(10, 10), chunks=(5, 5))
Expand Down
6 changes: 5 additions & 1 deletion dask/bag/tests/test_bag.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ def test_from_long_sequence():


def test_from_empty_sequence():
pytest.importorskip("pandas")
pytest.importorskip("dask.dataframe")
b = db.from_sequence([])
assert b.npartitions == 1
Expand Down Expand Up @@ -878,8 +879,8 @@ def test_args():


def test_to_dataframe():
dd = pytest.importorskip("dask.dataframe")
pd = pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")

def check_parts(df, sol):
assert all(
Expand Down Expand Up @@ -1608,6 +1609,7 @@ def f_drop(o):


def test_bagged_array_delayed():
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")

obj = da.ones(10, chunks=5).to_delayed()[0]
Expand All @@ -1631,6 +1633,7 @@ def test_dask_layers():
def test_dask_layers_to_delayed(optimize):
# `da.Array.to_delayed` causes the layer name to not match the key.
# Ensure the layer name is propagated between `Delayed` and `Item`.
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")
i = db.Item.from_delayed(da.ones(1).to_delayed()[0])
name = i.key[0]
Expand Down Expand Up @@ -1660,6 +1663,7 @@ def test_dask_layers_to_delayed(optimize):


def test_to_dataframe_optimize_graph():
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")

from dask.dataframe.utils import assert_eq as assert_eq_df
Expand Down
1 change: 1 addition & 0 deletions dask/diagnostics/tests/test_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def check_bar_completed(capsys, width=40):


def test_array_compute(capsys):
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")

data = da.ones((100, 100), dtype="f4", chunks=(100, 100))
Expand Down
7 changes: 7 additions & 0 deletions dask/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def test_is_dask_collection_dask_expr():


def test_is_dask_collection_dask_expr_does_not_materialize():
pytest.importorskip("pandas")
dx = pytest.importorskip("dask_expr")

class DoNotMaterialize(dx._core.Expr):
Expand Down Expand Up @@ -882,6 +883,7 @@ def test_persist_item_change_name():


def test_optimize_globals():
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")

x = da.ones(10, chunks=(5,))
Expand All @@ -906,6 +908,7 @@ def optimize_double(dsk, keys):


def test_optimize_None():
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")

x = da.ones(10, chunks=(5,))
Expand Down Expand Up @@ -997,6 +1000,7 @@ def test_num_workers_config(scheduler):


def test_optimizations_ctd():
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")
x = da.arange(2, chunks=1)[:1]
dsk1 = collections_to_dsk([x])
Expand All @@ -1022,6 +1026,7 @@ def test_clone_key():

def test_compute_as_if_collection_low_level_task_graph():
# See https://github.com/dask/dask/pull/7969
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")
x = da.arange(10)

Expand Down Expand Up @@ -1087,7 +1092,9 @@ def check_default_scheduler(module, collection, expected, emscripten):
),
)
def test_emscripten_default_scheduler(params):
pytest.importorskip("numpy")
pytest.importorskip("dask.array")
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
if dd._dask_expr_enabled() and "dask.dataframe" in params:
pytest.skip("objects not available")
Expand Down
1 change: 1 addition & 0 deletions dask/tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_cache_with_number():
def test_cache_correctness():
# https://github.com/dask/dask/issues/3631
c = Cache(10000)
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")
from numpy import ones, zeros

Expand Down
1 change: 1 addition & 0 deletions dask/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


def test_with_get():
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")
var = [0]

Expand Down
5 changes: 4 additions & 1 deletion dask/tests/test_delayed.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ def test_array_delayed():


def test_array_bag_delayed():
da = pytest.importorskip("dask.array")
np = pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")

arr1 = np.arange(100).reshape((10, 10))
arr2 = arr1.dot(arr1.T)
Expand Down Expand Up @@ -675,6 +675,7 @@ def myfunc(x):


def test_finalize_name():
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")

x = da.ones(10, chunks=5)
Expand All @@ -691,6 +692,7 @@ def key(s):


def test_keys_from_array():
pytest.importorskip("numpy")
da = pytest.importorskip("dask.array")
from dask.array.utils import _check_dsk

Expand Down Expand Up @@ -752,6 +754,7 @@ def test_attribute_of_attribute():


def test_check_meta_flag():
pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
from pandas import Series

Expand Down

0 comments on commit a453f19

Please sign in to comment.