[pypy-commit] pypy object-dtype2: fix some translation issues
rlamy
noreply at buildbot.pypy.org
Thu Apr 16 19:57:32 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: object-dtype2
Changeset: r76805:79f2ee46aa25
Date: 2015-04-16 18:57 +0100
http://bitbucket.org/pypy/pypy/changeset/79f2ee46aa25/
Log: fix some translation issues
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
@@ -205,12 +205,9 @@
w_res = self.getitem_filter(space, w_idx)
else:
try:
- w_res = self.implementation.descr_getitem(space, self, w_idx)
+ return self.implementation.descr_getitem(space, self, w_idx)
except ArrayArgumentException:
- w_res = self.getitem_array_int(space, w_idx)
- if w_res.is_scalar() and w_res.get_dtype(space).is_object():
- return w_res.get_dtype(space).itemtype.unbox(w_res)
- return w_res
+ return self.getitem_array_int(space, w_idx)
def getitem(self, space, index_list):
return self.implementation.getitem_index(space, index_list)
@@ -849,7 +846,7 @@
"new type not compatible with array."))
# Strides, shape does not change
v = impl.astype(space, dtype)
- return wrap_impl(space, w_type, self, v)
+ return wrap_impl(space, w_type, self, v)
strides = impl.get_strides()
if dims == 1 or strides[0] <strides[-1]:
# Column-major, resize first dimension
@@ -895,7 +892,7 @@
iter, state = self.create_iter()
w_val = iter.getitem(state)
if self.get_dtype().is_object():
- w_val = self.get_dtype().itemtype.unbox(w_val)
+ w_val = self.get_dtype().itemtype.unbox(w_val)
return space.wrap(space.is_true(w_val))
def _binop_impl(ufunc_name):
@@ -1212,7 +1209,7 @@
"improper dtype '%R'", dtype)
self.implementation = W_NDimArray.from_shape_and_storage(
space, [space.int_w(i) for i in space.listview(shape)],
- rffi.str2charp(space.str_w(storage), track_allocation=False),
+ rffi.str2charp(space.str_w(storage), track_allocation=False),
dtype, storage_bytes=space.len_w(storage), owning=True).implementation
def descr___array_finalize__(self, space, w_obj):
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
@@ -1742,7 +1742,6 @@
return v1
return v2
- @simple_unary_op
def bool(self,v):
return self._obool(v)
@@ -1854,7 +1853,7 @@
def add_unary_op(cls, op, method):
@simple_unary_op
def func(self, w_v):
- w_impl = getattr(w_v, method, None)
+ w_impl = getattr(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)
@@ -1876,15 +1875,13 @@
setattr(cls, op, func)
for op in ('copysign', 'isfinite', 'isinf', 'isnan', 'logaddexp', 'logaddexp2',
- 'signbit'):
+ 'signbit', 'conj', 'rint'):
add_unsupported_op(ObjectType, op)
for op in ('arctan2', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan',
'arctanh', 'ceil', 'floor', 'cos', 'sin', 'tan', 'cosh', 'sinh',
'tanh', 'radians', 'degrees', 'exp','exp2', 'expm1', 'fabs',
'log', 'log10', 'log1p', 'log2', 'sqrt', 'trunc'):
add_attributeerr_op(ObjectType, op)
-for op, method in (('conj', 'descr_conjugate'), ('rint', 'descr_rint')):
- add_unary_op(ObjectType, op, method)
for op in ('abs', 'neg', 'pos', 'invert'):
add_space_unary_op(ObjectType, op)
for op in ('add', 'floordiv', 'div', 'mod', 'mul', 'sub', 'lshift', 'rshift'):
More information about the pypy-commit
mailing list