@@ -76,6 +76,10 @@ def dask_array_ones(*args):
76
76
77
77
78
78
DEFAULT_QUANTILE = 0.9
79
+ REINDEX_SPARSE_STRAT = ReindexStrategy (blockwise = False , array_type = ReindexArrayType .SPARSE_COO )
80
+ REINDEX_SPARSE_PARAM = pytest .param (
81
+ REINDEX_SPARSE_STRAT , marks = (requires_dask , pytest .mark .skipif (not has_sparse , reason = "no sparse" ))
82
+ )
79
83
80
84
if TYPE_CHECKING :
81
85
from flox .core import T_Agg , T_Engine , T_ExpectedGroupsOpt , T_Method
@@ -325,7 +329,7 @@ def test_groupby_reduce_all(nby, size, chunks, func, add_nan_by, engine):
325
329
params = list (
326
330
itertools .product (
327
331
["map-reduce" ],
328
- [True , False , None , ReindexStrategy ( blockwise = False , array_type = ReindexArrayType . SPARSE_COO ) ],
332
+ [True , False , None , REINDEX_SPARSE_STRAT ],
329
333
)
330
334
)
331
335
params .extend (itertools .product (["cohorts" ], [False , None ]))
@@ -460,18 +464,7 @@ def test_numpy_reduce_nd_md():
460
464
461
465
462
466
@requires_dask
463
- @pytest .mark .parametrize (
464
- "reindex" ,
465
- [
466
- None ,
467
- False ,
468
- True ,
469
- pytest .param (
470
- ReindexStrategy (blockwise = False , array_type = ReindexArrayType .SPARSE_COO ),
471
- marks = pytest .mark .skipif (not has_sparse , reason = "no sparse" ),
472
- ),
473
- ],
474
- )
467
+ @pytest .mark .parametrize ("reindex" , [None , False , True , REINDEX_SPARSE_PARAM ])
475
468
@pytest .mark .parametrize ("func" , ALL_FUNCS )
476
469
@pytest .mark .parametrize ("add_nan" , [False , True ])
477
470
@pytest .mark .parametrize ("dtype" , (float ,))
@@ -803,7 +796,7 @@ def test_groupby_reduce_axis_subset_against_numpy(func, axis, engine):
803
796
pytest .param (False , (2 , 2 , 3 ), marks = requires_dask ),
804
797
pytest .param (True , (2 , 2 , 3 ), marks = requires_dask ),
805
798
pytest .param (
806
- ReindexStrategy ( blockwise = False , array_type = ReindexArrayType . SPARSE_COO ) ,
799
+ REINDEX_SPARSE_STRAT ,
807
800
(2 , 2 , 3 ),
808
801
marks = (requires_dask , pytest .mark .skipif (not has_sparse , reason = "no sparse" )),
809
802
),
@@ -860,7 +853,7 @@ def _maybe_chunk(arr):
860
853
([0 , 1 , 2 ], False ),
861
854
pytest .param (
862
855
[0 , 1 , 2 ],
863
- ReindexStrategy ( blockwise = False , array_type = ReindexArrayType . SPARSE_COO ) ,
856
+ REINDEX_SPARSE_STRAT ,
864
857
marks = pytest .mark .skipif (not has_sparse , reason = "no sparse" ),
865
858
),
866
859
],
0 commit comments