summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-05-19 14:24:57 -0600
committerCharles Harris <charlesr.harris@gmail.com>2016-05-19 14:24:57 -0600
commit2423048255f74aeefc22f707fcccfb8d21723ce3 (patch)
treecb43edfa51f9f1b96bd1b906dda283103da2150f
parentcd96464e3331e863862055f61322089ec1b2ad18 (diff)
parent5cde31bad1b1e698010fa2801255b5bd8ba3de90 (diff)
downloadnumpy-2423048255f74aeefc22f707fcccfb8d21723ce3.tar.gz
Merge pull request #7651 from ewmoore/ones_array_pow_fix
BUG: one to any power is still 1. Broken edgecase for int arrays
-rw-r--r--numpy/core/src/umath/loops.c.src4
-rw-r--r--numpy/core/tests/test_umath.py4
2 files changed, 8 insertions, 0 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 6f0dee123..157b30e70 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -921,6 +921,10 @@ NPY_NO_EXPORT void
*((@type@ *)op1) = 1;
continue;
}
+ if (in1 == 1) {
+ *((@type@ *)op1) = 1;
+ continue;
+ }
if (in2 < 0 || in1 == 0) {
*((@type@ *)op1) = 0;
continue;
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index f2f94d7bf..759e996e3 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -434,6 +434,10 @@ class TestPower(TestCase):
arr = np.arange(-10, 10)
assert_equal(np.power(arr, 0), np.ones_like(arr))
+ def test_integer_power_of_1(self):
+ arr = np.arange(-10, 10)
+ assert_equal(np.power(1, arr), np.ones_like(arr))
+
class TestLog2(TestCase):
def test_log2_values(self):