From c84343258e91c4a9a3a18214390def65b560c87d Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Tue, 28 Apr 2026 21:10:01 +0200 Subject: [PATCH] Added `sum` to `SIObject` --- si-units/CHANGELOG.md | 1 + si-units/src/lib.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/si-units/CHANGELOG.md b/si-units/CHANGELOG.md index df59f60..9ebb111 100644 --- a/si-units/CHANGELOG.md +++ b/si-units/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added `ATM` and `POISE` as additional units for pressure and viscosity. +- Added `sum` for `SIObject`s that can be summed. [#111](https://github.com/itt-ustutt/quantity/pull/111) ### Fixed - Fixed the String representation of non-scalar mass quantities. [#111](https://github.com/itt-ustutt/quantity/pull/111) diff --git a/si-units/src/lib.rs b/si-units/src/lib.rs index 3adc46f..c12732a 100644 --- a/si-units/src/lib.rs +++ b/si-units/src/lib.rs @@ -297,6 +297,11 @@ impl PySIObject { } } + fn sum(&self, py: Python) -> PyResult { + let value = self.value.call_method0(py, "sum")?; + Ok(Self::new(value, self.unit)) + } + #[getter] fn unit(&self) -> [i8; 7] { self.unit.0