19
19
requires_matplotlib ,
20
20
)
21
21
from xarray .tests .test_plot import PlotTestCase
22
- from xarray .tests .test_units .params import parametrize_unit_compatibility
22
+ from xarray .tests .test_units .params import (
23
+ parametrize_unit_compatibility ,
24
+ parametrize_variant ,
25
+ )
23
26
from xarray .tests .test_units .pint import unit_registry
24
27
from xarray .tests .test_variable import _PAD_XR_NP_ARGS
25
28
@@ -369,16 +372,7 @@ def __repr__(self):
369
372
return f"function_{ self .name } "
370
373
371
374
372
- @pytest .mark .parametrize (
373
- "variant" ,
374
- (
375
- "data" ,
376
- pytest .param (
377
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
378
- ),
379
- "coords" ,
380
- ),
381
- )
375
+ @parametrize_variant
382
376
def test_apply_ufunc_dataarray (variant , dtype ):
383
377
variants = {
384
378
"data" : (unit_registry .m , 1 , 1 ),
@@ -402,16 +396,7 @@ def test_apply_ufunc_dataarray(variant, dtype):
402
396
assert_identical (expected , actual )
403
397
404
398
405
- @pytest .mark .parametrize (
406
- "variant" ,
407
- (
408
- "data" ,
409
- pytest .param (
410
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
411
- ),
412
- "coords" ,
413
- ),
414
- )
399
+ @parametrize_variant
415
400
def test_apply_ufunc_dataset (variant , dtype ):
416
401
variants = {
417
402
"data" : (unit_registry .m , 1 , 1 ),
@@ -445,16 +430,7 @@ def test_apply_ufunc_dataset(variant, dtype):
445
430
446
431
447
432
@parametrize_unit_compatibility (DimensionalityError )
448
- @pytest .mark .parametrize (
449
- "variant" ,
450
- (
451
- "data" ,
452
- pytest .param (
453
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
454
- ),
455
- "coords" ,
456
- ),
457
- )
433
+ @parametrize_variant
458
434
@pytest .mark .parametrize ("value" , (10 , dtypes .NA ))
459
435
def test_align_dataarray (value , variant , unit , error , dtype ):
460
436
if variant == "coords" and (
@@ -537,16 +513,7 @@ def test_align_dataarray(value, variant, unit, error, dtype):
537
513
538
514
539
515
@parametrize_unit_compatibility (DimensionalityError )
540
- @pytest .mark .parametrize (
541
- "variant" ,
542
- (
543
- "data" ,
544
- pytest .param (
545
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
546
- ),
547
- "coords" ,
548
- ),
549
- )
516
+ @parametrize_variant
550
517
@pytest .mark .parametrize ("value" , (10 , dtypes .NA ))
551
518
def test_align_dataset (value , unit , variant , error , dtype ):
552
519
if variant == "coords" and (
@@ -687,16 +654,7 @@ def test_broadcast_dataset(dtype):
687
654
688
655
689
656
@parametrize_unit_compatibility (DimensionalityError )
690
- @pytest .mark .parametrize (
691
- "variant" ,
692
- (
693
- "data" ,
694
- pytest .param (
695
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
696
- ),
697
- "coords" ,
698
- ),
699
- )
657
+ @parametrize_variant
700
658
def test_combine_by_coords (variant , unit , error , dtype ):
701
659
original_unit = unit_registry .m
702
660
@@ -752,16 +710,7 @@ def test_combine_by_coords(variant, unit, error, dtype):
752
710
753
711
754
712
@parametrize_unit_compatibility (DimensionalityError )
755
- @pytest .mark .parametrize (
756
- "variant" ,
757
- (
758
- "data" ,
759
- pytest .param (
760
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
761
- ),
762
- "coords" ,
763
- ),
764
- )
713
+ @parametrize_variant
765
714
def test_combine_nested (variant , unit , error , dtype ):
766
715
original_unit = unit_registry .m
767
716
@@ -846,16 +795,7 @@ def test_combine_nested(variant, unit, error, dtype):
846
795
847
796
848
797
@parametrize_unit_compatibility (DimensionalityError )
849
- @pytest .mark .parametrize (
850
- "variant" ,
851
- (
852
- "data" ,
853
- pytest .param (
854
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
855
- ),
856
- "coords" ,
857
- ),
858
- )
798
+ @parametrize_variant
859
799
def test_concat_dataarray (variant , unit , error , dtype ):
860
800
original_unit = unit_registry .m
861
801
@@ -902,16 +842,7 @@ def test_concat_dataarray(variant, unit, error, dtype):
902
842
903
843
904
844
@parametrize_unit_compatibility (DimensionalityError )
905
- @pytest .mark .parametrize (
906
- "variant" ,
907
- (
908
- "data" ,
909
- pytest .param (
910
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
911
- ),
912
- "coords" ,
913
- ),
914
- )
845
+ @parametrize_variant
915
846
def test_concat_dataset (variant , unit , error , dtype ):
916
847
original_unit = unit_registry .m
917
848
@@ -956,16 +887,7 @@ def test_concat_dataset(variant, unit, error, dtype):
956
887
957
888
958
889
@parametrize_unit_compatibility (DimensionalityError )
959
- @pytest .mark .parametrize (
960
- "variant" ,
961
- (
962
- "data" ,
963
- pytest .param (
964
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
965
- ),
966
- "coords" ,
967
- ),
968
- )
890
+ @parametrize_variant
969
891
def test_merge_dataarray (variant , unit , error , dtype ):
970
892
original_unit = unit_registry .m
971
893
@@ -1048,16 +970,7 @@ def test_merge_dataarray(variant, unit, error, dtype):
1048
970
1049
971
1050
972
@parametrize_unit_compatibility (DimensionalityError )
1051
- @pytest .mark .parametrize (
1052
- "variant" ,
1053
- (
1054
- "data" ,
1055
- pytest .param (
1056
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
1057
- ),
1058
- "coords" ,
1059
- ),
1060
- )
973
+ @parametrize_variant
1061
974
def test_merge_dataset (variant , unit , error , dtype ):
1062
975
original_unit = unit_registry .m
1063
976
@@ -1125,16 +1038,7 @@ def test_merge_dataset(variant, unit, error, dtype):
1125
1038
assert_allclose (expected , actual )
1126
1039
1127
1040
1128
- @pytest .mark .parametrize (
1129
- "variant" ,
1130
- (
1131
- "data" ,
1132
- pytest .param (
1133
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
1134
- ),
1135
- "coords" ,
1136
- ),
1137
- )
1041
+ @parametrize_variant
1138
1042
@pytest .mark .parametrize ("func" , (xr .zeros_like , xr .ones_like ))
1139
1043
def test_replication_dataarray (func , variant , dtype ):
1140
1044
unit = unit_registry .m
@@ -1161,16 +1065,7 @@ def test_replication_dataarray(func, variant, dtype):
1161
1065
assert_identical (expected , actual )
1162
1066
1163
1067
1164
- @pytest .mark .parametrize (
1165
- "variant" ,
1166
- (
1167
- "data" ,
1168
- pytest .param (
1169
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
1170
- ),
1171
- "coords" ,
1172
- ),
1173
- )
1068
+ @parametrize_variant
1174
1069
@pytest .mark .parametrize ("func" , (xr .zeros_like , xr .ones_like ))
1175
1070
def test_replication_dataset (func , variant , dtype ):
1176
1071
unit = unit_registry .m
@@ -2790,16 +2685,7 @@ def is_compatible(a, b):
2790
2685
pytest .param (unit_registry .m , id = "identical_unit" ),
2791
2686
),
2792
2687
)
2793
- @pytest .mark .parametrize (
2794
- "variant" ,
2795
- (
2796
- "data" ,
2797
- pytest .param (
2798
- "dims" , marks = pytest .mark .skip (reason = "indexes don't support units" )
2799
- ),
2800
- "coords" ,
2801
- ),
2802
- )
2688
+ @parametrize_variant
2803
2689
def test_broadcast_like (self , variant , unit , dtype ):
2804
2690
original_unit = unit_registry .m
2805
2691
0 commit comments