From c0761cafddf46807fb7034834ba783b86ab676df Mon Sep 17 00:00:00 2001 From: Michael Dales Date: Fri, 24 Jan 2025 10:13:14 +0000 Subject: [PATCH] Fix compatibility with numpy 1 --- yirgacheffe/operators.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yirgacheffe/operators.py b/yirgacheffe/operators.py index 0055ee9..02b9050 100644 --- a/yirgacheffe/operators.py +++ b/yirgacheffe/operators.py @@ -120,11 +120,15 @@ def exp2(self): ) def clip(self, min=None, max=None): # pylint: disable=W0622 + # In the numpy 1 API np.clip(array) used a_max, a_min arguments and array.clip() used max and min as arguments + # In numpy 2 they moved so that max and min worked on both, but still support a_max, and a_min on np.clip. + # For now I'm only going to support the newer max/min everywhere notion, but I have to internally call + # a_max, a_min so that yirgacheffe can work on older numpy installs. return LayerOperation( self, np.clip, - min=min, - max=max, + a_min=min, + a_max=max, ) def numpy_apply(self, func, other=None):