@@ -455,6 +455,23 @@ def test_encoding_preserved(self):
455
455
assert_identical (expected .to_base_variable (), actual .to_base_variable ())
456
456
assert expected .encoding == actual .encoding
457
457
458
+ def test_reset_encoding (self ) -> None :
459
+ encoding1 = {"scale_factor" : 1 }
460
+ # encoding set via cls constructor
461
+ v1 = self .cls (["a" ], [0 , 1 , 2 ], encoding = encoding1 )
462
+ assert v1 .encoding == encoding1
463
+ v2 = v1 .reset_encoding ()
464
+ assert v1 .encoding == encoding1
465
+ assert v2 .encoding == {}
466
+
467
+ # encoding set via setter
468
+ encoding3 = {"scale_factor" : 10 }
469
+ v3 = self .cls (["a" ], [0 , 1 , 2 ], encoding = encoding3 )
470
+ assert v3 .encoding == encoding3
471
+ v4 = v3 .reset_encoding ()
472
+ assert v3 .encoding == encoding3
473
+ assert v4 .encoding == {}
474
+
458
475
def test_concat (self ):
459
476
x = np .arange (5 )
460
477
y = np .arange (5 , 10 )
@@ -2201,9 +2218,13 @@ def test_coarsen_keep_attrs(self, operation="mean"):
2201
2218
assert new .attrs == _attrs
2202
2219
2203
2220
2221
+ def _init_dask_variable (* args , ** kwargs ):
2222
+ return Variable (* args , ** kwargs ).chunk ()
2223
+
2224
+
2204
2225
@requires_dask
2205
2226
class TestVariableWithDask (VariableSubclassobjects ):
2206
- cls = staticmethod (lambda * args : Variable ( * args ). chunk () )
2227
+ cls = staticmethod (_init_dask_variable )
2207
2228
2208
2229
def test_chunk (self ):
2209
2230
unblocked = Variable (["dim_0" , "dim_1" ], np .ones ((3 , 4 )))
0 commit comments