[pypy-commit] pypy numpy-back-to-applevel: soem rpython fixes

fijal noreply at buildbot.pypy.org
Thu Jan 26 21:59:55 CET 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-back-to-applevel
Changeset: r51819:101fcf0a6557
Date: 2012-01-26 22:59 +0200
http://bitbucket.org/pypy/pypy/changeset/101fcf0a6557/

Log:	soem rpython fixes

diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -6,7 +6,6 @@
 from pypy.objspace.std.inttype import int_typedef
 from pypy.rlib.rarithmetic import LONG_BIT
 from pypy.tool.sourcetools import func_with_new_name
-from pypy.rpython.lltypesystem import rffi, lltype
 
 MIXIN_64 = (int_typedef,) if LONG_BIT == 64 else ()
 MIXIN_32 = () if LONG_BIT == 64 else (int_typedef,)
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -2,7 +2,8 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.module.micronumpy import interp_ufuncs, interp_dtype, signature
+from pypy.module.micronumpy import interp_ufuncs, interp_dtype, signature,\
+     interp_boxes
 from pypy.module.micronumpy.strides import calculate_slice_strides,\
      shape_agreement, find_shape_and_elems, get_shape_from_iterable,\
      calc_new_strides, to_coords
@@ -445,7 +446,7 @@
             item = concrete._index_of_single_item(space, w_idx)
             return concrete.getitem(item)
         chunks = self._prepare_slice_args(space, w_idx)
-        return space.wrap(self.create_slice(chunks))
+        return self.create_slice(chunks)
 
     def descr_setitem(self, space, w_idx, w_value):
         self.invalidated()
@@ -656,8 +657,10 @@
             concr = self.get_concrete()
             i = to_coords(space, self.shape, concr.size, concr.order, w_arg)[0]
             # XXX a bit around
-            return self.descr_getitem(space, space.newtuple([space.wrap(x)
-                                                   for x in i])).item(space)
+            item = self.descr_getitem(space, space.newtuple([space.wrap(x)
+                                             for x in i]))
+            assert isinstance(item, interp_boxes.W_GenericBox)
+            return item.item(space)
         raise OperationError(space.w_NotImplementedError, space.wrap(
             "non-int arg not supported"))
 
@@ -686,6 +689,7 @@
         self.shape = []
         BaseArray.__init__(self, [])
         self.dtype = dtype
+        assert isinstance(value, interp_boxes.W_GenericBox)
         self.value = value
 
     def find_dtype(self):
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
@@ -105,8 +105,9 @@
         ))
 
     def read_bool(self, storage, width, i, offset):
-        return bool(libffi.array_getitem(clibffi.cast_type_to_ffitype(self.T),
-                                         width, storage, i, offset))
+        return self.for_computation(
+            libffi.array_getitem(clibffi.cast_type_to_ffitype(self.T),
+                                 width, storage, i, offset)) != 0
 
     def store(self, storage, width, i, offset, box):
         value = self.unbox(box)


More information about the pypy-commit mailing list