@@ -492,6 +492,7 @@ def write_chunked_dense_array_to_group(
492492)
493493
494494
495+ @_REGISTRY .register_write (ZarrGroup , views .DaskArrayView , IOSpec ("array" , "0.2.0" ))
495496@_REGISTRY .register_write (ZarrGroup , DaskArray , IOSpec ("array" , "0.2.0" ))
496497def write_basic_dask_zarr (
497498 f : ZarrGroup ,
@@ -514,6 +515,7 @@ def write_basic_dask_zarr(
514515
515516# Adding this separately because h5py isn't serializable
516517# https://github.com/pydata/xarray/issues/4242
518+ @_REGISTRY .register_write (H5Group , views .DaskArrayView , IOSpec ("array" , "0.2.0" ))
517519@_REGISTRY .register_write (H5Group , DaskArray , IOSpec ("array" , "0.2.0" ))
518520def write_basic_dask_h5 (
519521 f : H5Group ,
@@ -803,21 +805,7 @@ def write_sparse_dataset(
803805 f [k ].attrs ["encoding-version" ] = "0.1.0"
804806
805807
806- @_REGISTRY .register_write (H5Group , (DaskArray , CupyArray ), IOSpec ("array" , "0.2.0" ))
807- @_REGISTRY .register_write (ZarrGroup , (DaskArray , CupyArray ), IOSpec ("array" , "0.2.0" ))
808- @_REGISTRY .register_write (
809- H5Group , (DaskArray , CupyCSRMatrix ), IOSpec ("csr_matrix" , "0.1.0" )
810- )
811- @_REGISTRY .register_write (
812- H5Group , (DaskArray , CupyCSCMatrix ), IOSpec ("csc_matrix" , "0.1.0" )
813- )
814- @_REGISTRY .register_write (
815- ZarrGroup , (DaskArray , CupyCSRMatrix ), IOSpec ("csr_matrix" , "0.1.0" )
816- )
817- @_REGISTRY .register_write (
818- ZarrGroup , (DaskArray , CupyCSCMatrix ), IOSpec ("csc_matrix" , "0.1.0" )
819- )
820- def write_cupy_dask_sparse (f , k , elem , _writer , dataset_kwargs = MappingProxyType ({})):
808+ def write_cupy_dask (f , k , elem , _writer , dataset_kwargs = MappingProxyType ({})):
821809 _writer .write_elem (
822810 f ,
823811 k ,
@@ -826,18 +814,6 @@ def write_cupy_dask_sparse(f, k, elem, _writer, dataset_kwargs=MappingProxyType(
826814 )
827815
828816
829- @_REGISTRY .register_write (
830- H5Group , (DaskArray , sparse .csr_matrix ), IOSpec ("csr_matrix" , "0.1.0" )
831- )
832- @_REGISTRY .register_write (
833- H5Group , (DaskArray , sparse .csc_matrix ), IOSpec ("csc_matrix" , "0.1.0" )
834- )
835- @_REGISTRY .register_write (
836- ZarrGroup , (DaskArray , sparse .csr_matrix ), IOSpec ("csr_matrix" , "0.1.0" )
837- )
838- @_REGISTRY .register_write (
839- ZarrGroup , (DaskArray , sparse .csc_matrix ), IOSpec ("csc_matrix" , "0.1.0" )
840- )
841817def write_dask_sparse (
842818 f : GroupStorageType ,
843819 k : str ,
@@ -886,6 +862,26 @@ def chunk_slice(start: int, stop: int) -> tuple[slice | None, slice | None]:
886862 disk_mtx .append (elem [chunk_slice (chunk_start , chunk_stop )].compute ())
887863
888864
865+ for array_type , group_type in product (
866+ [DaskArray , views .DaskArrayView ], [H5Group , ZarrGroup ]
867+ ):
868+ for cupy_array_type , spec in [
869+ (CupyArray , IOSpec ("array" , "0.2.0" )),
870+ (CupyCSCMatrix , IOSpec ("csc_matrix" , "0.1.0" )),
871+ (CupyCSRMatrix , IOSpec ("csr_matrix" , "0.1.0" )),
872+ ]:
873+ _REGISTRY .register_write (group_type , (array_type , cupy_array_type ), spec )(
874+ write_cupy_dask
875+ )
876+ for scipy_sparse_type , spec in [
877+ (sparse .csr_matrix , IOSpec ("csr_matrix" , "0.1.0" )),
878+ (sparse .csc_matrix , IOSpec ("csc_matrix" , "0.1.0" )),
879+ ]:
880+ _REGISTRY .register_write (group_type , (array_type , scipy_sparse_type ), spec )(
881+ write_dask_sparse
882+ )
883+
884+
889885@_REGISTRY .register_read (H5Group , IOSpec ("csc_matrix" , "0.1.0" ))
890886@_REGISTRY .register_read (H5Group , IOSpec ("csr_matrix" , "0.1.0" ))
891887@_REGISTRY .register_read (ZarrGroup , IOSpec ("csc_matrix" , "0.1.0" ))
0 commit comments