[pypy-commit] pypy object-dtype: Add space everywhere
rguillebert
noreply at buildbot.pypy.org
Mon Jan 26 17:56:24 CET 2015
Author: Romain Guillebert <romain.py at gmail.com>
Branch: object-dtype
Changeset: r75540:7cbb4af9b24f
Date: 2015-01-26 17:56 +0100
http://bitbucket.org/pypy/pypy/changeset/7cbb4af9b24f/
Log: Add space everywhere
diff --git a/pypy/module/micronumpy/arrayops.py b/pypy/module/micronumpy/arrayops.py
--- a/pypy/module/micronumpy/arrayops.py
+++ b/pypy/module/micronumpy/arrayops.py
@@ -192,7 +192,7 @@
def count_nonzero(space, w_obj):
- return space.wrap(loop.count_all_true(convert_to_array(space, w_obj)))
+ return space.wrap(loop.count_all_true(space, convert_to_array(space, w_obj)))
def choose(space, w_arr, w_choices, w_out, w_mode):
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -268,10 +268,10 @@
out_indices = out_iter.indices(out_state)
if out_indices[axis] == 0:
if identity is not None:
- w_val = func(dtype, identity, w_val)
+ w_val = func(space, dtype, identity, w_val)
else:
cur = temp_iter.getitem(temp_state)
- w_val = func(dtype, cur, w_val)
+ w_val = func(space, dtype, cur, w_val)
out_iter.setitem(out_state, w_val)
out_state = out_iter.next(out_state)
@@ -288,7 +288,7 @@
greens = ['shapelen', 'dtype'],
reds = 'auto')
- def argmin_argmax(arr):
+ def argmin_argmax(space, arr):
result = 0
idx = 1
dtype = arr.get_dtype()
@@ -299,8 +299,8 @@
while not iter.done(state):
arg_driver.jit_merge_point(shapelen=shapelen, dtype=dtype)
w_val = iter.getitem(state)
- new_best = getattr(dtype.itemtype, op_name)(cur_best, w_val)
- if dtype.itemtype.ne(new_best, cur_best):
+ new_best = getattr(dtype.itemtype, op_name)(space, cur_best, w_val)
+ if dtype.itemtype.ne(space, new_best, cur_best):
result = idx
cur_best = new_best
state = iter.next(state)
@@ -379,9 +379,9 @@
state = iter.next(state)
return s
-def count_all_true(arr):
+def count_all_true(space, arr):
if arr.is_scalar():
- return arr.get_dtype().itemtype.bool(arr.get_scalar_value())
+ return arr.get_dtype().itemtype.bool(space, arr.get_scalar_value())
else:
return count_all_true_concrete(arr.implementation)
@@ -662,12 +662,12 @@
arr_state = arr_iter.next(arr_state)
if min_iter is not None:
w_min = min_iter.getitem(min_state).convert_to(space, dtype)
- if dtype.itemtype.lt(w_v, w_min):
+ if dtype.itemtype.lt(space, w_v, w_min):
w_v = w_min
min_state = min_iter.next(min_state)
if max_iter is not None:
w_max = max_iter.getitem(max_state).convert_to(space, dtype)
- if dtype.itemtype.gt(w_v, w_max):
+ if dtype.itemtype.gt(space, w_v, w_max):
w_v = w_max
max_state = max_iter.next(max_state)
out_iter.setitem(out_state, w_v)
@@ -750,7 +750,7 @@
last_key_val = key_iter.getitem(key_state)
while not key_iter.done(key_state):
key_val = key_iter.getitem(key_state)
- if dtype.itemtype.lt(last_key_val, key_val):
+ if dtype.itemtype.lt(space, last_key_val, key_val):
max_idx = size
else:
min_idx = 0
@@ -760,7 +760,7 @@
binsearch_driver.jit_merge_point(dtype=dtype)
mid_idx = min_idx + ((max_idx - min_idx) >> 1)
mid_val = arr.getitem(space, [mid_idx]).convert_to(space, dtype)
- if op(mid_val, key_val):
+ if op(space, mid_val, key_val):
min_idx = mid_idx + 1
else:
max_idx = mid_idx
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
@@ -1068,7 +1068,7 @@
raise oefmt(space.w_NotImplementedError,
'%s not implemented for %s',
op_name, self.get_dtype().get_name())
- return space.wrap(getattr(loop, op_name)(self))
+ return space.wrap(getattr(loop, op_name)(space, self))
return func_with_new_name(impl, "reduce_%s_impl" % op_name)
descr_argmax = _reduce_argmax_argmin_impl("max")
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
@@ -44,10 +44,10 @@
def complex_unary_op(func):
specialize.argtype(1)(func)
@functools.wraps(func)
- def dispatcher(self, v):
+ def dispatcher(self, space, v):
return self.box_complex(
*func(
- self,
+ self, space,
self.for_computation(self.unbox(v))
)
)
@@ -308,7 +308,7 @@
@raw_unary_op
def rint(self, space, v):
float64 = Float64()
- return float64.rint(float64.box(v))
+ return float64.rint(space, float64.box(v))
class Bool(BaseType, Primitive):
T = lltype.Bool
@@ -513,7 +513,7 @@
return ~v
@specialize.argtype(1)
- def reciprocal(self, v):
+ def reciprocal(self, space, v):
raw = self.for_computation(self.unbox(v))
ans = 0
if raw == 0:
@@ -1268,13 +1268,13 @@
b = self._bool(v2)
return (not b and a) or (not a and b)
- def min(self, v1, v2):
- if self.le(v1, v2) or self.isnan(v1):
+ def min(self, space, v1, v2):
+ if self.le(space, v1, v2) or self.isnan(space, v1):
return v1
return v2
- def max(self, v1, v2):
- if self.ge(v1, v2) or self.isnan(v1):
+ def max(self, space, v1, v2):
+ if self.ge(space, v1, v2) or self.isnan(space, v1):
return v1
return v2
@@ -1300,14 +1300,14 @@
if y[0] == 1:
return v1
if y[0] == 2:
- return self.mul(v1, v1)
+ return self.mul(space, v1, v1)
x = self.for_computation(self.unbox(v1))
if x[0] == 0 and x[1] == 0:
if y[0] > 0 and y[1] == 0:
return self.box_complex(0, 0)
return self.box_complex(rfloat.NAN, rfloat.NAN)
- b = self.for_computation(self.unbox(self.log(v1)))
- return self.exp(self.box_complex(b[0] * y[0] - b[1] * y[1],
+ b = self.for_computation(self.unbox(self.log(space, v1)))
+ return self.exp(space, self.box_complex(b[0] * y[0] - b[1] * y[1],
b[0] * y[1] + b[1] * y[0]))
#complex copysign does not exist in numpy
@@ -1332,13 +1332,13 @@
return 1,0
return -1,0
- def fmax(self, v1, v2):
- if self.ge(v1, v2) or self.isnan(v2):
+ def fmax(self, space, v1, v2):
+ if self.ge(space, v1, v2) or self.isnan(space, v2):
return v1
return v2
- def fmin(self, v1, v2):
- if self.le(v1, v2) or self.isnan(v2):
+ def fmin(self, space, v1, v2):
+ if self.le(space, v1, v2) or self.isnan(space, v2):
return v1
return v2
@@ -1363,7 +1363,7 @@
return rfloat.NAN, rfloat.NAN
@specialize.argtype(1)
- def round(self, v, decimals=0):
+ def round(self, space, v, decimals=0):
ans = list(self.for_computation(self.unbox(v)))
if rfloat.isfinite(ans[0]):
ans[0] = rfloat.round_double(ans[0], decimals, half_even=True)
@@ -1371,8 +1371,8 @@
ans[1] = rfloat.round_double(ans[1], decimals, half_even=True)
return self.box_complex(ans[0], ans[1])
- def rint(self, v):
- return self.round(v)
+ def rint(self, space, v):
+ return self.round(space, v)
# No floor, ceil, trunc in numpy for complex
#@simple_unary_op
@@ -1804,7 +1804,7 @@
b = bool(v2)
return (not b and a) or (not a and b)
- def bool(self, v):
+ def bool(self, space, v):
return bool(self.to_str(v))
def fill(self, storage, width, box, start, stop, offset):
@@ -1997,7 +1997,7 @@
pieces.append(")")
return "".join(pieces)
- def eq(self, v1, v2):
+ def eq(self, space, v1, v2):
assert isinstance(v1, boxes.W_VoidBox)
assert isinstance(v2, boxes.W_VoidBox)
s1 = v1.dtype.elsize
@@ -2008,8 +2008,8 @@
return False
return True
- def ne(self, v1, v2):
- return not self.eq(v1, v2)
+ def ne(self, space, v1, v2):
+ return not self.eq(space, v1, v2)
for tp in [Int32, Int64]:
if tp.T == lltype.Signed:
More information about the pypy-commit
mailing list