diff --git a/Cargo.toml b/Cargo.toml index 73331a1..47fe56f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ fs2 = { version = "0.4", optional = true } itertools = { version = "0.8", optional = true } lz4 = { version = "1.23", optional = true } lz-fear = { version = "0.1.1", optional = true } -ndarray = { version = "0.13", optional = true } +ndarray = { version = "0.15", optional = true } num-traits = { version = "0.2", optional = true } serde = { version = "1.0", features = ["derive"] } smallvec = { version = "1", features = ["serde"] } diff --git a/src/ndarray.rs b/src/ndarray.rs index 49b33b4..fde438f 100644 --- a/src/ndarray.rs +++ b/src/ndarray.rs @@ -11,9 +11,7 @@ use itertools::Itertools; use ndarray::{ Array, ArrayView, - IxDyn, ShapeBuilder, - SliceInfo, }; use crate::{ @@ -117,9 +115,9 @@ impl BoundingBox { self.offset.iter().zip(self.size.iter()).map(|(o, s)| o + s) } - pub fn to_ndarray_slice(&self) -> CoordVec { + pub fn to_ndarray_slice(&self) -> CoordVec { self.offset.iter().zip(self.end()) - .map(|(&start, end)| ndarray::SliceOrIndex::Slice { + .map(|(&start, end)| ndarray::SliceInfoElem::Slice { start: start as isize, end: Some(end as isize), step: 1, @@ -242,14 +240,14 @@ pub trait N5NdarrayReader : N5Reader { let block_read_bb = read_bb.clone() - &block_bb.offset; let arr_slice = arr_read_bb.to_ndarray_slice(); - let mut arr_view = arr.slice_mut(SliceInfo::<_, IxDyn>::new(arr_slice).unwrap().as_ref()); + let mut arr_view = arr.slice_mut(arr_slice.as_slice()); let block_slice = block_read_bb.to_ndarray_slice(); // N5 datasets are stored f-order/column-major. let block_data = ArrayView::from_shape(block_bb.size_ndarray_shape().f(), block.get_data()) .expect("TODO: block ndarray failed"); - let block_view = block_data.slice(SliceInfo::<_, IxDyn>::new(block_slice).unwrap().as_ref()); + let block_view = block_data.slice(block_slice.as_slice()); arr_view.assign(&block_view); } @@ -298,7 +296,7 @@ pub trait N5NdarrayWriter : N5Writer { let arr_bb = write_bb.clone() - &bbox.offset; let arr_slice = arr_bb.to_ndarray_slice(); - let arr_view = array.slice(SliceInfo::<_, IxDyn>::new(arr_slice).unwrap().as_ref()); + let arr_view = array.slice(arr_slice.as_slice()); if write_bb == nom_block_bb { @@ -339,7 +337,7 @@ pub trait N5NdarrayWriter : N5Writer { let block_write_bb = write_bb.clone() - &block_bb.offset; let block_slice = block_write_bb.to_ndarray_slice(); - let mut block_view = block_array.slice_mut(SliceInfo::<_, IxDyn>::new(block_slice).unwrap().as_ref()); + let mut block_view = block_array.slice_mut(block_slice.as_slice()); block_view.assign(&arr_view); diff --git a/tests/ndarray.rs b/tests/ndarray.rs index f7691c1..851f64f 100644 --- a/tests/ndarray.rs +++ b/tests/ndarray.rs @@ -1,7 +1,5 @@ #![cfg(feature = "use_ndarray")] -use std::iter::FromIterator; - use ndarray::Array; use smallvec::smallvec; use rand::Rng;