[pypy-commit] pypy object-dtype2: restore a few methods
mattip
noreply at buildbot.pypy.org
Fri Apr 17 09:41:44 CEST 2015
Author: mattip <matti.picus at gmail.com>
Branch: object-dtype2
Changeset: r76808:d9b54f7dd7e1
Date: 2015-04-17 10:41 +0300
http://bitbucket.org/pypy/pypy/changeset/d9b54f7dd7e1/
Log: restore a few methods
diff --git a/pypy/module/micronumpy/ndarray.py b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -202,7 +202,7 @@
return self
elif isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool() \
and w_idx.ndims() > 0:
- w_res = self.getitem_filter(space, w_idx)
+ return self.getitem_filter(space, w_idx)
else:
try:
return self.implementation.descr_getitem(space, self, w_idx)
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
@@ -1857,10 +1857,11 @@
def add_unary_op(cls, op, method):
@simple_unary_op
def func(self, w_v):
- w_impl = getattr(w_v, method)
+ space = self.space
+ w_impl = space.lookup(w_v, method)
if w_impl is None:
- raise oefmt(self.space.w_AttributeError, 'unknown op "%s" on object' % op)
- return w_impl(self.space)
+ raise oefmt(space.w_AttributeError, 'unknown op "%s" on object' % op)
+ return space.get_and_call_function(w_impl, w_v)
func.__name__ = 'object_' + op
setattr(cls, op, func)
@@ -1879,7 +1880,7 @@
setattr(cls, op, func)
for op in ('copysign', 'isfinite', 'isinf', 'isnan', 'logaddexp', 'logaddexp2',
- 'signbit', 'conj', 'rint'):
+ 'signbit'):
add_unsupported_op(ObjectType, op)
for op in ('arctan2', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan',
'arctanh', 'ceil', 'floor', 'cos', 'sin', 'tan', 'cosh', 'sinh',
@@ -1888,6 +1889,8 @@
add_attributeerr_op(ObjectType, op)
for op in ('abs', 'neg', 'pos', 'invert'):
add_space_unary_op(ObjectType, op)
+for op, method in (('conj', 'descr_conjugate'), ('rint', 'descr_rint')):
+ add_unary_op(ObjectType, op, method)
for op in ('add', 'floordiv', 'div', 'mod', 'mul', 'sub', 'lshift', 'rshift'):
add_space_binary_op(ObjectType, op)
More information about the pypy-commit
mailing list