Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r77933:dd0100ab58a2
Date: 2015-06-07 03:32 +0100
http://bitbucket.org/pypy/pypy/changeset/dd0100ab58a2/
Log: Create W_Dtype.store()
diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -593,7 +593,7 @@
raise oefmt(space.w_IndexError, "222only integers, slices (`:`), "
"ellipsis (`...`), numpy.newaxis (`None`) and integer or "
"boolean arrays are valid indices")
- dtype.itemtype.store(self.arr, self.ofs, ofs,
+ dtype.store(self.arr, self.ofs, ofs,
dtype.coerce(space, w_value))
def convert_to(self, space, dtype):
diff --git a/pypy/module/micronumpy/concrete.py
b/pypy/module/micronumpy/concrete.py
--- a/pypy/module/micronumpy/concrete.py
+++ b/pypy/module/micronumpy/concrete.py
@@ -49,7 +49,7 @@
return self.dtype.itemtype.read_bool(self, index, 0)
def setitem(self, index, value):
- self.dtype.itemtype.store(self, index, 0, value)
+ self.dtype.store(self, index, 0, value)
@jit.unroll_safe
def setslice(self, space, arr):
diff --git a/pypy/module/micronumpy/descriptor.py
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -402,6 +402,9 @@
return self.coerce(space, space.wrap(s))
return self.itemtype.runpack_str(space, s)
+ def store(self, arr, i, offset, value):
+ return self.itemtype.store(arr, i, offset, value)
+
def descr_reduce(self, space):
w_class = space.type(self)
builder_args = space.newtuple([
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
@@ -2264,8 +2264,8 @@
itemtype = subdtype.itemtype
if len(shape) <= 1:
for i in range(len(items_w)):
- w_box = itemtype.coerce(space, subdtype, items_w[i])
- itemtype.store(arr, 0, ofs, w_box)
+ w_box = subdtype.coerce(space, items_w[i])
+ subdtype.store(arr, 0, ofs, w_box)
ofs += itemtype.get_element_size()
else:
for w_item in items_w:
@@ -2381,12 +2381,11 @@
arr = VoidBoxStorage(dtype.elsize, dtype)
for i in range(len(dtype.fields)):
ofs, subdtype = dtype.fields[dtype.names[i]]
- itemtype = subdtype.itemtype
try:
- w_box = itemtype.coerce(space, subdtype, items_w[i])
+ w_box = subdtype.coerce(space, items_w[i])
except IndexError:
- w_box = itemtype.coerce(space, subdtype, None)
- itemtype.store(arr, 0, ofs, w_box)
+ w_box = subdtype.coerce(space, None)
+ subdtype.store(arr, 0, ofs, w_box)
return boxes.W_VoidBox(arr, 0, dtype)
def runpack_str(self, space, s):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit