From 1031df26af6d9b209458fb229a987247bf2d5497 Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Wed, 11 Oct 2006 23:28:16 +0000 Subject: Fix scimath.power for negative integer input. --- numpy/lib/scimath.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'numpy/lib/scimath.py') diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py index 4f5a3ec0c..c15f254a3 100644 --- a/numpy/lib/scimath.py +++ b/numpy/lib/scimath.py @@ -31,6 +31,12 @@ def _fix_real_lt_zero(x): x = _tocomplex(x) return x +def _fix_int_lt_zero(x): + x = asarray(x) + if any(isreal(x) & (x < 0)): + x = x * 1.0 + return x + def _fix_real_abs_gt_1(x): x = asarray(x) if any(isreal(x) & (abs(x)>1)): @@ -64,6 +70,7 @@ def log2(x): def power(x, p): x = _fix_real_lt_zero(x) + p = _fix_int_lt_zero(p) return nx.power(x, p) def arccos(x): -- cgit v1.2.1