@@ -1526,12 +1526,6 @@ def roundtrip(
1526
1526
with self .open (store_target , ** open_kwargs ) as ds :
1527
1527
yield ds
1528
1528
1529
- @contextlib .contextmanager
1530
- def roundtrip_append (
1531
- self , data , save_kwargs = None , open_kwargs = None , allow_cleanup_failure = False
1532
- ):
1533
- pytest .skip ("zarr backend does not support appending" )
1534
-
1535
1529
def test_roundtrip_consolidated (self ):
1536
1530
pytest .importorskip ("zarr" , minversion = "2.2.1.dev2" )
1537
1531
expected = create_test_data ()
@@ -1826,63 +1820,52 @@ def test_encoding_kwarg_fixed_width_string(self):
1826
1820
# not relevant for zarr, since we don't use EncodedStringCoder
1827
1821
pass
1828
1822
1829
- # TODO: someone who understand caching figure out whether chaching
1823
+ # TODO: someone who understand caching figure out whether caching
1830
1824
# makes sense for Zarr backend
1831
1825
@pytest .mark .xfail (reason = "Zarr caching not implemented" )
1832
1826
def test_dataset_caching (self ):
1833
1827
super ().test_dataset_caching ()
1834
1828
1835
1829
@pytest .mark .skipif (LooseVersion (dask_version ) < "2.4" , reason = "dask GH5334" )
1836
1830
def test_append_write (self ):
1837
- ds , ds_to_append , _ = create_append_test_data ()
1838
- with self .create_zarr_target () as store_target :
1839
- ds .to_zarr (store_target , mode = "w" )
1840
- ds_to_append .to_zarr (store_target , append_dim = "time" )
1841
- original = xr .concat ([ds , ds_to_append ], dim = "time" )
1842
- assert_identical (original , xr .open_zarr (store_target ))
1843
-
1844
- @pytest .mark .xfail (reason = "Zarr stores can not be appended to" )
1845
- def test_append_overwrite_values (self ):
1846
- super ().test_append_overwrite_values ()
1831
+ super ().test_append_write ()
1847
1832
1848
1833
def test_append_with_invalid_dim_raises (self ):
1849
-
1850
1834
ds , ds_to_append , _ = create_append_test_data ()
1851
-
1852
- # check failure when append_dim not valid
1853
- with pytest .raises (ValueError ):
1854
- with self . create_zarr_target () as store_target :
1855
- ds . to_zarr ( store_target , mode = "w" )
1835
+ with self . create_zarr_target () as store_target :
1836
+ ds . to_zarr ( store_target , mode = "w" )
1837
+ with pytest .raises (
1838
+ ValueError , match = "does not match any existing dataset dimensions"
1839
+ ):
1856
1840
ds_to_append .to_zarr (store_target , append_dim = "notvalid" )
1857
1841
1858
- def test_append_with_append_dim_not_set_raises (self ):
1842
+ def test_append_with_no_dims_raises (self ):
1843
+ with self .create_zarr_target () as store_target :
1844
+ Dataset ({"foo" : ("x" , [1 ])}).to_zarr (store_target , mode = "w" )
1845
+ with pytest .raises (ValueError , match = "different dimension names" ):
1846
+ Dataset ({"foo" : ("y" , [2 ])}).to_zarr (store_target , mode = "a" )
1859
1847
1848
+ def test_append_with_append_dim_not_set_raises (self ):
1860
1849
ds , ds_to_append , _ = create_append_test_data ()
1861
-
1862
- # check failure when append_dim not set
1863
- with pytest .raises (ValueError ):
1864
- with self .create_zarr_target () as store_target :
1865
- ds .to_zarr (store_target , mode = "w" )
1850
+ with self .create_zarr_target () as store_target :
1851
+ ds .to_zarr (store_target , mode = "w" )
1852
+ with pytest .raises (ValueError , match = "different dimension sizes" ):
1866
1853
ds_to_append .to_zarr (store_target , mode = "a" )
1867
1854
1868
1855
def test_append_with_mode_not_a_raises (self ):
1869
-
1870
1856
ds , ds_to_append , _ = create_append_test_data ()
1871
-
1872
- # check failure when append_dim is set and mode != 'a'
1873
- with pytest .raises (ValueError ):
1874
- with self . create_zarr_target () as store_target :
1875
- ds . to_zarr ( store_target , mode = "w" )
1857
+ with self . create_zarr_target () as store_target :
1858
+ ds . to_zarr ( store_target , mode = "w" )
1859
+ with pytest .raises (
1860
+ ValueError , match = "append_dim was set along with mode='w'"
1861
+ ):
1876
1862
ds_to_append .to_zarr (store_target , mode = "w" , append_dim = "time" )
1877
1863
1878
1864
def test_append_with_existing_encoding_raises (self ):
1879
-
1880
1865
ds , ds_to_append , _ = create_append_test_data ()
1881
-
1882
- # check failure when providing encoding to existing variable
1883
- with pytest .raises (ValueError ):
1884
- with self .create_zarr_target () as store_target :
1885
- ds .to_zarr (store_target , mode = "w" )
1866
+ with self .create_zarr_target () as store_target :
1867
+ ds .to_zarr (store_target , mode = "w" )
1868
+ with pytest .raises (ValueError , match = "but encoding was provided" ):
1886
1869
ds_to_append .to_zarr (
1887
1870
store_target ,
1888
1871
append_dim = "time" ,
0 commit comments