From 3c615a05bbbbb517ffcd464f9a66eb528fba86a4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 28 Dec 2024 19:36:23 +0000 Subject: [PATCH 1/2] repeat --- pint/facets/numpy/numpy_func.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pint/facets/numpy/numpy_func.py b/pint/facets/numpy/numpy_func.py index b79700f9f..58eda696c 100644 --- a/pint/facets/numpy/numpy_func.py +++ b/pint/facets/numpy/numpy_func.py @@ -575,6 +575,12 @@ def _where(condition, *args): return output_wrap(np.where(condition, *args)) +@implements("repeat", "function") +def _repeat(a, repeats, axis=None): + a, output_wrap = unwrap_and_wrap_consistent_units(a) + return output_wrap(np.repeat(a, repeats, axis)) + + @implements("concatenate", "function") def _concatenate(sequence, *args, **kwargs): sequence, output_wrap = unwrap_and_wrap_consistent_units(*sequence) From 8ab1beceafbb735a08e82451bf3682206f1d8fe6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 31 Dec 2024 00:33:51 +0000 Subject: [PATCH 2/2] test --- pint/testsuite/test_numpy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pint/testsuite/test_numpy.py b/pint/testsuite/test_numpy.py index 3075be7ac..cf072010f 100644 --- a/pint/testsuite/test_numpy.py +++ b/pint/testsuite/test_numpy.py @@ -611,6 +611,9 @@ def test_repeat(self): helpers.assert_quantity_equal( self.q.repeat(2), [1, 1, 2, 2, 3, 3, 4, 4] * self.ureg.m ) + helpers.assert_quantity_equal( + np.repeat(self.q, 2), [1, 1, 2, 2, 3, 3, 4, 4] * self.ureg.m + ) def test_sort(self): q = [4, 5, 2, 3, 1, 6] * self.ureg.m