@@ -1655,7 +1655,7 @@ def test_write_persistence_modes(self):
1655
1655
# check append mode for append write
1656
1656
with self .create_zarr_target () as store_target :
1657
1657
ds .to_zarr (store_target , mode = 'w' )
1658
- ds_to_append .to_zarr (store_target , mode = 'a' , append_dim = 'time' )
1658
+ ds_to_append .to_zarr (store_target , append_dim = 'time' )
1659
1659
original = xr .concat ([ds , ds_to_append ], dim = 'time' )
1660
1660
assert_identical (original , xr .open_zarr (store_target ))
1661
1661
@@ -1691,7 +1691,7 @@ def test_append_write(self):
1691
1691
ds , ds_to_append , _ = create_append_test_data ()
1692
1692
with self .create_zarr_target () as store_target :
1693
1693
ds .to_zarr (store_target , mode = 'w' )
1694
- ds_to_append .to_zarr (store_target , mode = 'a' , append_dim = 'time' )
1694
+ ds_to_append .to_zarr (store_target , append_dim = 'time' )
1695
1695
original = xr .concat ([ds , ds_to_append ], dim = 'time' )
1696
1696
assert_identical (original , xr .open_zarr (store_target ))
1697
1697
@@ -1707,8 +1707,7 @@ def test_append_with_invalid_dim_raises(self):
1707
1707
with pytest .raises (ValueError ):
1708
1708
with self .create_zarr_target () as store_target :
1709
1709
ds .to_zarr (store_target , mode = 'w' )
1710
- ds_to_append .to_zarr (store_target , mode = 'a' ,
1711
- append_dim = 'notvalid' )
1710
+ ds_to_append .to_zarr (store_target , append_dim = 'notvalid' )
1712
1711
1713
1712
def test_append_with_append_dim_not_set_raises (self ):
1714
1713
@@ -1720,6 +1719,17 @@ def test_append_with_append_dim_not_set_raises(self):
1720
1719
ds .to_zarr (store_target , mode = 'w' )
1721
1720
ds_to_append .to_zarr (store_target , mode = 'a' )
1722
1721
1722
+ def test_append_with_mode_not_a_raises (self ):
1723
+
1724
+ ds , ds_to_append , _ = create_append_test_data ()
1725
+
1726
+ # check failure when append_dim is set and mode != 'a'
1727
+ with pytest .raises (ValueError ):
1728
+ with self .create_zarr_target () as store_target :
1729
+ ds .to_zarr (store_target , mode = 'w' )
1730
+ ds_to_append .to_zarr (store_target , mode = 'w' ,
1731
+ append_dim = 'time' )
1732
+
1723
1733
def test_append_with_existing_encoding_raises (self ):
1724
1734
1725
1735
ds , ds_to_append , _ = create_append_test_data ()
@@ -1728,8 +1738,7 @@ def test_append_with_existing_encoding_raises(self):
1728
1738
with pytest .raises (ValueError ):
1729
1739
with self .create_zarr_target () as store_target :
1730
1740
ds .to_zarr (store_target , mode = 'w' )
1731
- ds_to_append .to_zarr (store_target , mode = 'a' ,
1732
- append_dim = 'time' ,
1741
+ ds_to_append .to_zarr (store_target , append_dim = 'time' ,
1733
1742
encoding = {'da' : {'compressor' : None }})
1734
1743
1735
1744
def test_check_encoding_is_consistent_after_append (self ):
@@ -1742,7 +1751,7 @@ def test_check_encoding_is_consistent_after_append(self):
1742
1751
compressor = zarr .Blosc ()
1743
1752
encoding = {'da' : {'compressor' : compressor }}
1744
1753
ds .to_zarr (store_target , mode = 'w' , encoding = encoding )
1745
- ds_to_append .to_zarr (store_target , mode = 'a' , append_dim = 'time' )
1754
+ ds_to_append .to_zarr (store_target , append_dim = 'time' )
1746
1755
actual_ds = xr .open_zarr (store_target )
1747
1756
actual_encoding = actual_ds ['da' ].encoding ['compressor' ]
1748
1757
assert actual_encoding .get_config () == compressor .get_config ()
@@ -1803,7 +1812,7 @@ def test_to_zarr_append_compute_false_roundtrip(self):
1803
1812
assert_identical (ds , actual )
1804
1813
1805
1814
delayed_obj = self .save (ds_to_append , store , compute = False ,
1806
- mode = 'a' , append_dim = 'time' )
1815
+ append_dim = 'time' )
1807
1816
assert isinstance (delayed_obj , Delayed )
1808
1817
1809
1818
with pytest .raises (AssertionError ):
0 commit comments