1
1
from __future__ import annotations
2
2
3
- from collections .abc import Hashable , Iterable , Sequence
3
+ from collections .abc import Hashable
4
4
5
5
import numpy as np
6
6
import pandas as pd
@@ -257,17 +257,18 @@ def test_infix_dims_errors(supplied, all_):
257
257
pytest .param ("a" , ("a" ,), id = "str" ),
258
258
pytest .param (["a" , "b" ], ("a" , "b" ), id = "list_of_str" ),
259
259
pytest .param (["a" , 1 ], ("a" , 1 ), id = "list_mixed" ),
260
+ pytest .param (["a" , ...], ("a" , ...), id = "list_with_ellipsis" ),
260
261
pytest .param (("a" , "b" ), ("a" , "b" ), id = "tuple_of_str" ),
261
262
pytest .param (["a" , ("b" , "c" )], ("a" , ("b" , "c" )), id = "list_with_tuple" ),
262
263
pytest .param ((("b" , "c" ),), (("b" , "c" ),), id = "tuple_of_tuple" ),
264
+ pytest .param ({"a" , 1 }, tuple ({"a" , 1 }), id = "non_sequence_collection" ),
265
+ pytest .param ((), (), id = "empty_tuple" ),
266
+ pytest .param (set (), (), id = "empty_collection" ),
263
267
pytest .param (None , None , id = "None" ),
264
268
pytest .param (..., ..., id = "ellipsis" ),
265
269
],
266
270
)
267
- def test_parse_dims (
268
- dim : str | Iterable [Hashable ] | None ,
269
- expected : tuple [Hashable , ...],
270
- ) -> None :
271
+ def test_parse_dims (dim , expected ):
271
272
all_dims = ("a" , "b" , 1 , ("b" , "c" )) # selection of different Hashables
272
273
actual = utils .parse_dims (dim , all_dims , replace_none = False )
273
274
assert actual == expected
@@ -297,7 +298,7 @@ def test_parse_dims_replace_none(dim: None | ellipsis) -> None:
297
298
pytest .param (["x" , 2 ], id = "list_missing_all" ),
298
299
],
299
300
)
300
- def test_parse_dims_raises (dim : str | Iterable [ Hashable ]) -> None :
301
+ def test_parse_dims_raises (dim ) :
301
302
all_dims = ("a" , "b" , 1 , ("b" , "c" )) # selection of different Hashables
302
303
with pytest .raises (ValueError , match = "'x'" ):
303
304
utils .parse_dims (dim , all_dims , check_exists = True )
@@ -313,10 +314,7 @@ def test_parse_dims_raises(dim: str | Iterable[Hashable]) -> None:
313
314
pytest .param (["a" , ..., "b" ], ("a" , "c" , "b" ), id = "list_with_middle_ellipsis" ),
314
315
],
315
316
)
316
- def test_parse_ordered_dims (
317
- dim : str | Sequence [Hashable | ellipsis ],
318
- expected : tuple [Hashable , ...],
319
- ) -> None :
317
+ def test_parse_ordered_dims (dim , expected ):
320
318
all_dims = ("a" , "b" , "c" )
321
319
actual = utils .parse_ordered_dims (dim , all_dims )
322
320
assert actual == expected
0 commit comments