diff --git a/si-units/CHANGELOG.md b/si-units/CHANGELOG.md index 9993666..a292864 100644 --- a/si-units/CHANGELOG.md +++ b/si-units/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Generalized indexing, such that, e.g., general multidimensional slicing operations are possible for quantities containing NumPy arrays. [#110](https://github.com/itt-ustutt/quantity/pull/110) ## [0.11.3] - 2026-04-22 ### Added diff --git a/si-units/src/lib.rs b/si-units/src/lib.rs index 73e1f07..bb0b8a5 100644 --- a/si-units/src/lib.rs +++ b/si-units/src/lib.rs @@ -272,15 +272,15 @@ impl PySIObject { .and_then(|v| v.extract::(py)) } - fn __getitem__(&self, py: Python, idx: isize) -> PyResult { + fn __getitem__(&self, py: Python, idx: &Bound<'_, PyAny>) -> PyResult { let value = self.value.call_method1(py, "__getitem__", (idx,))?; Ok(Self::new(value, self.unit)) } - fn __setitem__(&self, py: Python, idx: isize, value: SINumber) -> PyResult<()> { + fn __setitem__(&self, py: Python, idx: &Bound<'_, PyAny>, value: &Self) -> PyResult<()> { if self.unit == value.unit { self.value - .call_method1(py, "__setitem__", (idx, value.value))?; + .call_method1(py, "__setitem__", (idx, &value.value))?; Ok(()) } else { Err(QuantityError::InconsistentUnits {