Author: Ronan Lamy <ronan.l...@gmail.com> Branch: indexing Changeset: r78549:e9f26b0c2ae0 Date: 2015-07-13 23:59 +0200 http://bitbucket.org/pypy/pypy/changeset/e9f26b0c2ae0/
Log: kill RecordChunk 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 @@ -11,7 +11,7 @@ from pypy.module.micronumpy.iterators import ArrayIter from pypy.module.micronumpy.strides import ( Chunk, Chunks, NewAxisChunk, EllipsisChunk, - RecordChunk, calc_strides, calc_new_strides, shape_agreement, + calc_strides, calc_new_strides, shape_agreement, calculate_broadcast_strides, calc_backstrides, calc_start, is_c_contiguous, is_f_contiguous) from rpython.rlib.objectmodel import keepalive_until_here 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 @@ -20,7 +20,7 @@ from pypy.module.micronumpy.flagsobj import W_FlagsObject from pypy.module.micronumpy.strides import ( get_shape_from_iterable, shape_agreement, shape_agreement_multiple, - is_c_contiguous, is_f_contiguous, RecordChunk) + is_c_contiguous, is_f_contiguous, calc_strides) from pypy.module.micronumpy.casting import can_cast_array @@ -257,8 +257,23 @@ dtype = self.get_dtype() if field not in dtype.fields: raise oefmt(space.w_ValueError, "field named %s not found", field) - chunks = RecordChunk(field) - return chunks.apply(space, self) + arr = self.implementation + ofs, subdtype = arr.dtype.fields[field] + # ofs only changes start + # create a view of the original array by extending + # the shape, strides, backstrides of the array + strides, backstrides = calc_strides(subdtype.shape, + subdtype.subdtype, arr.order) + final_shape = arr.shape + subdtype.shape + final_strides = arr.get_strides() + strides + final_backstrides = arr.get_backstrides() + backstrides + final_dtype = subdtype + if subdtype.subdtype: + final_dtype = subdtype.subdtype + return W_NDimArray.new_slice(space, arr.start + ofs, final_strides, + final_backstrides, + final_shape, arr, self, final_dtype) + def descr_delitem(self, space, w_idx): raise OperationError(space.w_ValueError, space.wrap( @@ -1317,7 +1332,6 @@ def descr_new_array(space, w_subtype, w_shape, w_dtype=None, w_buffer=None, offset=0, w_strides=None, w_order=None): from pypy.module.micronumpy.concrete import ConcreteArray - from pypy.module.micronumpy.strides import calc_strides dtype = space.interp_w(descriptor.W_Dtype, space.call_function( space.gettypefor(descriptor.W_Dtype), w_dtype)) shape = shape_converter(space, w_shape, dtype) diff --git a/pypy/module/micronumpy/strides.py b/pypy/module/micronumpy/strides.py --- a/pypy/module/micronumpy/strides.py +++ b/pypy/module/micronumpy/strides.py @@ -10,29 +10,6 @@ pass -class RecordChunk(BaseChunk): - def __init__(self, name): - self.name = name - - def apply(self, space, orig_arr): - arr = orig_arr.implementation - ofs, subdtype = arr.dtype.fields[self.name] - # ofs only changes start - # create a view of the original array by extending - # the shape, strides, backstrides of the array - strides, backstrides = calc_strides(subdtype.shape, - subdtype.subdtype, arr.order) - final_shape = arr.shape + subdtype.shape - final_strides = arr.get_strides() + strides - final_backstrides = arr.get_backstrides() + backstrides - final_dtype = subdtype - if subdtype.subdtype: - final_dtype = subdtype.subdtype - return W_NDimArray.new_slice(space, arr.start + ofs, final_strides, - final_backstrides, - final_shape, arr, orig_arr, final_dtype) - - class Chunks(BaseChunk): def __init__(self, l): self.l = l _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit