Author: Brian Kearns <[email protected]>
Branch: remove-numpypy
Changeset: r67715:44bfbd81979e
Date: 2013-10-29 18:37 -0400
http://bitbucket.org/pypy/pypy/changeset/44bfbd81979e/
Log: merge default
diff --git a/pypy/module/micronumpy/test/test_scalar.py
b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -23,19 +23,19 @@
assert loads(dumps(sum(a))) == sum(a)
def test_round(self):
- from numpypy import int32, float64, complex128, bool
+ from numpypy import int32, float64, complex128, bool_
i = int32(1337)
f = float64(13.37)
c = complex128(13 + 37.j)
- b = bool(0)
+ b = bool_(1)
assert i.round(decimals=-2) == 1300
assert i.round(decimals=1) == 1337
assert c.round() == c
assert f.round() == 13.
assert f.round(decimals=-1) == 10.
assert f.round(decimals=1) == 13.4
- exc = raises(AttributeError, 'b.round()')
- assert exc.value[0] == "'bool' object has no attribute 'round'"
+ assert b.round() == 1.0
+ assert b.round(decimals=5) is b
def test_attributes(self):
import numpypy as np
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -400,6 +400,12 @@
return 1
return 0
+ @specialize.argtype(1)
+ def round(self, v, decimals=0):
+ if decimals != 0:
+ return v
+ return Float64().box(self.unbox(v))
+
class Integer(Primitive):
_mixin_ = True
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit