From 6b61e8a6b3dddab13b88e51309cbdf2f28247960 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Thu, 22 Aug 2024 08:20:25 +0200 Subject: [PATCH] Fix docstring and implementation of Interval.power This makes the code more resilient to future numpy changes. --- pythran/interval.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pythran/interval.py b/pythran/interval.py index 4e5dff8fd..b8ef42e69 100644 --- a/pythran/interval.py +++ b/pythran/interval.py @@ -196,13 +196,15 @@ def __pow__(range1, range2): >>> Interval(1, 5) ** Interval(-5, -4) Interval(low=1.0, high=1.0) >>> Interval(-1, 5) ** Interval(-5, 3) - Interval(low=-1.0, high=125.0) + Interval(low=-1.0, high=125) >>> Interval(1, 5) ** Interval(3, 8) - Interval(low=1.0, high=390625.0) + Interval(low=1, high=390625) """ res = [v1 ** v2 for v1, v2 in itertools.product(range1.bounds(), range2.bounds())] - return Interval(numpy.ceil(min(res)), numpy.floor(max(res))) + minres, maxres = min(res), max(res) + return Interval(type(minres)(numpy.ceil(minres)), + type(maxres)(numpy.floor(maxres))) def __lshift__(range1, range2): """