File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 9
9
import xarray as xr
10
10
from xarray .core import formatting
11
11
12
- from . import requires_netCDF4
12
+ from . import (
13
+ requires_netCDF4 ,
14
+ requires_dask ,
15
+ )
13
16
14
17
15
18
class TestFormatting :
@@ -413,6 +416,7 @@ def test_array_repr_variable(self) -> None:
413
416
with xr .set_options (display_expand_data = False ):
414
417
formatting .array_repr (var )
415
418
419
+ @requires_dask
416
420
def test_array_scalar_format (self ) -> None :
417
421
var = xr .DataArray (0 )
418
422
assert var .__format__ ("" ) == "0"
@@ -425,6 +429,12 @@ def test_array_scalar_format(self) -> None:
425
429
var .__format__ (".2f" )
426
430
assert "unsupported format string passed to" in str (excinfo .value )
427
431
432
+ # also check for dask
433
+ var = var .chunk (chunks = {'dim_0' : 1 })
434
+ assert var .__format__ ("" ) == "[0.1 0.2]"
435
+ with pytest .raises (TypeError ) as excinfo :
436
+ var .__format__ (".2f" )
437
+ assert "unsupported format string passed to" in str (excinfo .value )
428
438
429
439
def test_inline_variable_array_repr_custom_repr () -> None :
430
440
class CustomArray :
You can’t perform that action at this time.
0 commit comments