From bfc6efb8e6509235ee301301fa0df4aee5fe5176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Sun, 15 Sep 2024 13:21:57 +0200 Subject: [PATCH] Add umath funcs: maximum & minimum --- quantities/dimensionality.py | 2 ++ quantities/tests/test_umath.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/quantities/dimensionality.py b/quantities/dimensionality.py index d38038e..c00190b 100644 --- a/quantities/dimensionality.py +++ b/quantities/dimensionality.py @@ -284,6 +284,8 @@ def _d_check_uniform(q1, q2, out=None): p_dict[np.less_equal] = _d_check_uniform p_dict[np.greater] = _d_check_uniform p_dict[np.greater_equal] = _d_check_uniform +p_dict[np.maximum] = _d_check_uniform +p_dict[np.minimum] = _d_check_uniform def _d_arctan2(q1, q2, out=None): try: diff --git a/quantities/tests/test_umath.py b/quantities/tests/test_umath.py index 6df6490..a29231d 100644 --- a/quantities/tests/test_umath.py +++ b/quantities/tests/test_umath.py @@ -293,3 +293,13 @@ def test_greater_equal(self): arr2 = (1.0, 2.0) * pq.m self.assertTrue(np.all(np.greater_equal(arr2, arr1))) self.assertFalse(np.all(np.greater_equal(arr2*0.99, arr1))) + + def test_maximum(self): + arr1 = (998, 999) * pq.m + arr2 = (1e3, 5e2) * pq.m + self.assertQuantityEqual(np.maximum(arr1, arr2) - [1000, 999]*pq.m, [0, 0]*pq.m) + + def test_minimum(self): + arr1 = (998, 999) * pq.m + arr2 = (1e3, 5e2) * pq.m + self.assertQuantityEqual(np.minimum(arr1, arr2) - [998, 500]*pq.m, [0, 0]*pq.m) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy