/// Writes all data from the array `arr` into the given `slice` of the target dataset.
/// The shape of `arr` must match the shape the set of elements included in the slice.
/// If the array has a fixed number of dimensions, it must match the dimensionality of
/// dataset. Use the multi-dimensional slice macro `s![]` from `ndarray` to conveniently create
/// a multidimensional slice.
Writes all data from the array `arr` into the given `slice` of the target dataset.
The shape of `arr` must match the shape the set of elements included in the slice.
If the array has a fixed number of dimensions, it must match the dimensionality of
dataset. Use the multi-dimensional slice macro `s![]` from `ndarray` to conveniently create
a multidimensional slice.
Writes all data from the array ` arr ` into the given ` slice ` of the target dataset . The shape of ` arr ` must match the shape the set of elements included in the slice . If the array has a fixed number of dimensions it must match the dimensionality of dataset . Use the multi - dimensional slice macro ` s! [] ` from ` ndarray ` to conveniently create a multidimensional slice .
pub fn write_slice<'b, A, T, S, D>(&self, arr: A, slice: &SliceInfo<S, D>) -> Result<()>
    where
        A: Into<ArrayView<'b, T, D>>,
        T: H5Type,
        S: AsRef<[SliceOrIndex]>,
        D: ndarray::Dimension,
    {
        ensure!(!self.obj.is_attr(), "slicing cannot be used on attribute datasets");
        let shape = self.obj.get_shape()?;
        let slice_s: &[SliceOrIndex] = slice.as_ref();
        let slice_dim = slice_s.len();
        if shape.ndim() != slice_dim {
            let obj_ndim = shape.ndim();
            ensure!(
                obj_ndim == slice_dim,
                "slice dimension mismatch: dataset has {} dims, slice has {} dims",
                obj_ndim,
                slice_dim
            );
        }
        if shape.ndim() == 0 {
            // Fall back to a simple read for the scalar case
            // Slicing has no effect
            self.write(arr)
        } else {
            let fspace = self.obj.space()?;
            let slice_shape = fspace.select_slice(slice)?;
            let view = arr.into();
            let data_shape = view.shape();
            // Restore dimensions that are SliceOrIndex::Index in the slice.
            let mut data_shape_hydrated = Vec::new();
            let mut pos = 0;
            for s in slice_s {
                if let SliceOrIndex::Index(_) = s {
                    data_shape_hydrated.push(1);
                } else {
                    data_shape_hydrated.push(data_shape[pos]);
                    pos += 1;
                }
            }
            let mspace = Dataspace::try_new(&slice_shape, false)?;
            // FIXME - we can handle non-standard input arrays by creating a memory space
            // that reflects the same slicing/ordering that this ArrayView represents.
            // we could also convert the array into a standard layout, but this is probably expensive.
            ensure!(
                view.is_standard_layout(),
                "input array is not in standard layout or is not contiguous"
            );
            if slice_shape != data_shape_hydrated {
                fail!(
                    "shape mismatch when writing slice: memory = {:?}, destination = {:?}",
                    data_shape_hydrated,
                    slice_shape
                );
            }
            self.write_from_buf(view.as_ptr(), Some(&fspace), Some(&mspace))
        }
    }
pub fn write_slice < ' b , A , T , S , D > ( & self , arr : A , slice : & SliceInfo < S , D > ) -> Result < ( ) > where A : Into < ArrayView < ' b , T , D > > , T : H5Type , S : AsRef < [ SliceOrIndex ] > , D : ndarray :: Dimension , { ensure ! ( self obj is_attr ( ) " " ) ; let shape = self . obj . get_shape ( ) ? ; let slice_s : & [ SliceOrIndex ] = slice . as_ref ( ) ; let slice_dim = slice_s . len ( ) ; if shape . ndim ( ) != slice_dim { let obj_ndim = shape . ndim ( ) ; ensure ! ( obj_ndim slice_dim " " obj_ndim slice_dim ) ; } if shape . ndim ( ) == 0 { // Fall back to a simple read for the scalar case // Slicing has no effect self . write ( arr ) } else { let fspace = self . obj . space ( ) ? ; let slice_shape = fspace . select_slice ( slice ) ? ; let view = arr . into ( ) ; let data_shape = view . shape ( ) ; // Restore dimensions that are SliceOrIndex::Index in the slice. let mut data_shape_hydrated = Vec :: new ( ) ; let mut pos = 0 ; for s in slice_s { if let SliceOrIndex :: Index ( _ ) = s { data_shape_hydrated . push ( 1 ) ; } else { data_shape_hydrated . push ( data_shape [ pos ] ) ; pos += 1 ; } } let mspace = Dataspace :: try_new ( & slice_shape , false ) ? ; // FIXME - we can handle non-standard input arrays by creating a memory space // that reflects the same slicing/ordering that this ArrayView represents. // we could also convert the array into a standard layout, but this is probably expensive. ensure ! ( view is_standard_layout ( ) " " ) ; if slice_shape != data_shape_hydrated { fail ! ( " " data_shape_hydrated slice_shape ) ; } self . write_from_buf ( view . as_ptr ( ) , Some ( & fspace ) , Some ( & mspace ) ) } }
Writes all data from the array `arr` into the given `slice` of the target dataset.
Writes all data from the array ` arr ` into the given ` slice ` of the target dataset .
&self
arr
A
slice
&SliceInfo<S, D>