[pypy-commit] pypy numpy-unify-methods: implement missing ufuncs for integers
mattip
noreply at buildbot.pypy.org
Wed Feb 13 23:05:27 CET 2013
Author: mattip <matti.picus at gmail.com>
Branch: numpy-unify-methods
Changeset: r61220:219bbd8abdcd
Date: 2013-02-13 23:28 +0200
http://bitbucket.org/pypy/pypy/changeset/219bbd8abdcd/
Log: implement missing ufuncs for integers
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
@@ -7,6 +7,7 @@
from pypy.objspace.std.floatobject import float2string
from pypy.objspace.std.complexobject import str_format
from rpython.rlib import rfloat, clibffi, rcomplex
+from rpython.rlib.rarithmetic import maxint
from rpython.rlib.rawstorage import (alloc_raw_storage, raw_storage_setitem,
raw_storage_getitem)
from rpython.rlib.objectmodel import specialize
@@ -479,6 +480,17 @@
def invert(self, v):
return ~v
+ @simple_unary_op
+ def reciprocal(self, v):
+ if v == 0:
+ # XXX good place to warn
+ return -maxint
+ return 1 / v
+
+ @raw_unary_op
+ def signbit(self, v):
+ return v < 0
+
class NonNativeInteger(NonNativePrimitive, Integer):
_mixin_ = True
More information about the pypy-commit
mailing list