[pypy-commit] pypy default: fix reshape with zero-sized array
bdkearns
noreply at buildbot.pypy.org
Thu Feb 27 12:05:05 CET 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r69505:baa6eb2680b0
Date: 2014-02-27 03:15 -0500
http://bitbucket.org/pypy/pypy/changeset/baa6eb2680b0/
Log: fix reshape with zero-sized array
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
@@ -1,12 +1,12 @@
+from pypy.interpreter.error import OperationError, oefmt
+from pypy.interpreter.gateway import unwrap_spec
+from pypy.module.micronumpy import loop, descriptor, ufuncs, support, \
+ constants as NPY
from pypy.module.micronumpy.base import convert_to_array, W_NDimArray
-from pypy.module.micronumpy import loop, descriptor, ufuncs
+from pypy.module.micronumpy.converters import clipmode_converter
from pypy.module.micronumpy.strides import Chunk, Chunks, shape_agreement, \
shape_agreement_multiple
-from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.gateway import unwrap_spec
-from pypy.module.micronumpy.converters import clipmode_converter
-from pypy.module.micronumpy import support
-from pypy.module.micronumpy import constants as NPY
+
def where(space, w_arr, w_x=None, w_y=None):
"""where(condition, [x, y])
diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py
--- a/pypy/module/micronumpy/base.py
+++ b/pypy/module/micronumpy/base.py
@@ -1,7 +1,6 @@
+from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError
-from pypy.interpreter.baseobjspace import W_Root
from rpython.tool.pairtype import extendabletype
-from pypy.module.micronumpy.support import calc_strides
def wrap_impl(space, w_cls, w_instance, impl):
@@ -31,9 +30,10 @@
@staticmethod
def from_shape(space, shape, dtype, order='C', w_instance=None):
from pypy.module.micronumpy import concrete
+ from pypy.module.micronumpy.strides import calc_strides
strides, backstrides = calc_strides(shape, dtype.base, order)
impl = concrete.ConcreteArray(shape, dtype.base, order, strides,
- backstrides)
+ backstrides)
if w_instance:
return wrap_impl(space, space.type(w_instance), w_instance, impl)
return W_NDimArray(impl)
@@ -42,6 +42,7 @@
def from_shape_and_storage(space, shape, storage, dtype, order='C', owning=False,
w_subtype=None, w_base=None, writable=True):
from pypy.module.micronumpy import concrete
+ from pypy.module.micronumpy.strides import calc_strides
strides, backstrides = calc_strides(shape, dtype, order)
if w_base is not None:
if owning:
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
@@ -1,23 +1,22 @@
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.mixedmodule import MixedModule
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.objspace.std.bytesobject import W_BytesObject
+from pypy.objspace.std.complextype import complex_typedef
from pypy.objspace.std.floattype import float_typedef
+from pypy.objspace.std.intobject import W_IntObject
from pypy.objspace.std.unicodeobject import W_UnicodeObject
-from pypy.objspace.std.intobject import W_IntObject
-from pypy.objspace.std.complextype import complex_typedef
from rpython.rlib.rarithmetic import LONG_BIT
-from rpython.rtyper.lltypesystem import rffi
-from rpython.tool.sourcetools import func_with_new_name
-from pypy.module.micronumpy.concrete import VoidBoxStorage
-from pypy.module.micronumpy.base import W_NDimArray
-from pypy.module.micronumpy.flagsobj import W_FlagsObject
-from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rtyper.lltypesystem import lltype
from rpython.rlib.rstring import StringBuilder
from rpython.rlib.objectmodel import specialize
+from rpython.rtyper.lltypesystem import lltype, rffi
+from rpython.tool.sourcetools import func_with_new_name
from pypy.module.micronumpy import constants as NPY
+from pypy.module.micronumpy.base import W_NDimArray
+from pypy.module.micronumpy.concrete import VoidBoxStorage
+from pypy.module.micronumpy.flagsobj import W_FlagsObject
MIXIN_32 = (W_IntObject.typedef,) if LONG_BIT == 32 else ()
diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -1,20 +1,17 @@
""" This is a set of tools for standalone compiling of numpy expressions.
It should not be imported by the module itself
"""
-
import re
-
from pypy.interpreter import special
from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
from pypy.interpreter.error import OperationError
-from pypy.module.micronumpy import boxes
-from pypy.module.micronumpy.descriptor import get_dtype_cache
+from rpython.rlib.objectmodel import specialize, instantiate
+from rpython.rlib.nonconst import NonConstant
+from pypy.module.micronumpy import boxes, ufuncs
+from pypy.module.micronumpy.arrayops import where
from pypy.module.micronumpy.base import W_NDimArray
from pypy.module.micronumpy.ctors import array
-from pypy.module.micronumpy.arrayops import where
-from pypy.module.micronumpy import ufuncs
-from rpython.rlib.objectmodel import specialize, instantiate
-from rpython.rlib.nonconst import NonConstant
+from pypy.module.micronumpy.descriptor import get_dtype_cache
class BogusBytecode(Exception):
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
@@ -1,16 +1,16 @@
-from pypy.module.micronumpy import support, loop, iter
-from pypy.module.micronumpy.base import convert_to_array, W_NDimArray,\
- ArrayArgumentException
-from pypy.module.micronumpy.strides import (Chunk, Chunks, NewAxisChunk,
- RecordChunk, calc_new_strides, shape_agreement, calculate_broadcast_strides,
- calculate_dot_strides)
+from pypy.interpreter.buffer import RWBuffer
from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.buffer import RWBuffer
from rpython.rlib import jit
-from rpython.rtyper.lltypesystem import rffi, lltype
+from rpython.rlib.debug import make_sure_not_resized
from rpython.rlib.rawstorage import alloc_raw_storage, free_raw_storage, \
raw_storage_getitem, raw_storage_setitem, RAW_STORAGE
-from rpython.rlib.debug import make_sure_not_resized
+from rpython.rtyper.lltypesystem import rffi, lltype
+from pypy.module.micronumpy import support, loop, iter
+from pypy.module.micronumpy.base import convert_to_array, W_NDimArray, \
+ ArrayArgumentException
+from pypy.module.micronumpy.strides import (Chunk, Chunks, NewAxisChunk,
+ RecordChunk, calc_strides, calc_new_strides, shape_agreement,
+ calculate_broadcast_strides, calculate_dot_strides)
class BaseConcreteArray(object):
@@ -64,7 +64,9 @@
def reshape(self, orig_array, new_shape):
# Since we got to here, prod(new_shape) == self.size
new_strides = None
- if self.size > 0:
+ if self.size == 0:
+ new_strides, _ = calc_strides(new_shape, self.dtype, self.order)
+ else:
if len(self.get_shape()) == 0:
new_strides = [self.dtype.elsize] * len(new_shape)
else:
@@ -81,7 +83,7 @@
new_shape, self, orig_array)
def get_view(self, space, orig_array, dtype, new_shape):
- strides, backstrides = support.calc_strides(new_shape, dtype,
+ strides, backstrides = calc_strides(new_shape, dtype,
self.order)
return SliceArray(self.start, strides, backstrides, new_shape,
self, orig_array, dtype=dtype)
@@ -268,7 +270,7 @@
backstrides, shape, self, orig_array)
def copy(self, space):
- strides, backstrides = support.calc_strides(self.get_shape(), self.dtype,
+ strides, backstrides = calc_strides(self.get_shape(), self.dtype,
self.order)
impl = ConcreteArray(self.get_shape(), self.dtype, self.order, strides,
backstrides)
@@ -312,7 +314,7 @@
return ArrayBuffer(self)
def astype(self, space, dtype):
- strides, backstrides = support.calc_strides(self.get_shape(), dtype,
+ strides, backstrides = calc_strides(self.get_shape(), dtype,
self.order)
impl = ConcreteArray(self.get_shape(), dtype, self.order,
strides, backstrides)
@@ -358,7 +360,7 @@
box, 0, self.size, 0)
def set_shape(self, space, orig_array, new_shape):
- strides, backstrides = support.calc_strides(new_shape, self.dtype,
+ strides, backstrides = calc_strides(new_shape, self.dtype,
self.order)
return SliceArray(0, strides, backstrides, new_shape, self,
orig_array)
diff --git a/pypy/module/micronumpy/ctors.py b/pypy/module/micronumpy/ctors.py
--- a/pypy/module/micronumpy/ctors.py
+++ b/pypy/module/micronumpy/ctors.py
@@ -1,16 +1,14 @@
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
+from rpython.rlib.rstring import strip_spaces
from rpython.rtyper.lltypesystem import lltype, rffi
-from pypy.module.micronumpy import descriptor, loop
-from rpython.rlib.rstring import strip_spaces
-from pypy.module.micronumpy import ufuncs
+from pypy.module.micronumpy import descriptor, loop, ufuncs
from pypy.module.micronumpy.base import W_NDimArray, convert_to_array
from pypy.module.micronumpy.converters import shape_converter
from pypy.module.micronumpy.strides import find_shape_and_elems
def build_scalar(space, w_dtype, w_state):
- from rpython.rtyper.lltypesystem import rffi, lltype
if not isinstance(w_dtype, descriptor.W_Dtype):
raise oefmt(space.w_TypeError,
"argument 1 must be numpy.dtype, not %T", w_dtype)
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
@@ -4,14 +4,12 @@
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import (TypeDef, GetSetProperty,
interp_attrproperty, interp_attrproperty_w)
-from pypy.module.micronumpy import types, boxes, base
+from rpython.rlib import jit
from rpython.rlib.objectmodel import specialize
from rpython.rlib.rarithmetic import r_longlong, r_ulonglong
-from rpython.rlib import jit
+from pypy.module.micronumpy import types, boxes, base, support, constants as NPY
from pypy.module.micronumpy.appbridge import get_appbridge_cache
from pypy.module.micronumpy.converters import byteorder_converter
-from pypy.module.micronumpy import support
-from pypy.module.micronumpy import constants as NPY
def decode_w_dtype(space, w_dtype):
diff --git a/pypy/module/micronumpy/flagsobj.py b/pypy/module/micronumpy/flagsobj.py
--- a/pypy/module/micronumpy/flagsobj.py
+++ b/pypy/module/micronumpy/flagsobj.py
@@ -1,7 +1,7 @@
from pypy.interpreter.baseobjspace import W_Root
+from pypy.interpreter.error import OperationError
+from pypy.interpreter.gateway import interp2app
from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.gateway import interp2app
-from pypy.interpreter.error import OperationError
class W_FlagsObject(W_Root):
diff --git a/pypy/module/micronumpy/flatiter.py b/pypy/module/micronumpy/flatiter.py
--- a/pypy/module/micronumpy/flatiter.py
+++ b/pypy/module/micronumpy/flatiter.py
@@ -1,7 +1,7 @@
+from pypy.interpreter.error import OperationError, oefmt
+from pypy.module.micronumpy import loop
from pypy.module.micronumpy.base import W_NDimArray, convert_to_array
-from pypy.module.micronumpy import loop
from pypy.module.micronumpy.concrete import BaseConcreteArray
-from pypy.interpreter.error import OperationError, oefmt
class FakeArrayImplementation(BaseConcreteArray):
diff --git a/pypy/module/micronumpy/iter.py b/pypy/module/micronumpy/iter.py
--- a/pypy/module/micronumpy/iter.py
+++ b/pypy/module/micronumpy/iter.py
@@ -40,10 +40,9 @@
but then we cannot gaurentee that we only overflow one single shape
dimension, perhaps we could overflow times in one big step.
"""
-
+from rpython.rlib import jit
+from pypy.module.micronumpy import support
from pypy.module.micronumpy.base import W_NDimArray
-from pypy.module.micronumpy import support
-from rpython.rlib import jit
class PureShapeIterator(object):
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
@@ -2,15 +2,14 @@
operations. This is the place to look for all the computations that iterate
over all the array elements.
"""
-
-from rpython.rlib.rstring import StringBuilder
from pypy.interpreter.error import OperationError
from rpython.rlib import jit
+from rpython.rlib.rstring import StringBuilder
from rpython.rtyper.lltypesystem import lltype, rffi
+from pypy.module.micronumpy import support, constants as NPY
from pypy.module.micronumpy.base import W_NDimArray
from pypy.module.micronumpy.iter import PureShapeIterator
-from pypy.module.micronumpy import support
-from pypy.module.micronumpy import constants as NPY
+
call2_driver = jit.JitDriver(name='numpy_call2',
greens = ['shapelen', 'func', 'calc_dtype',
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
@@ -1,27 +1,25 @@
-from rpython.rtyper.lltypesystem import rffi
-from rpython.rlib.rawstorage import RAW_STORAGE_PTR
from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.typedef import TypeDef, GetSetProperty, make_weakref_descr
from pypy.interpreter.gateway import interp2app, unwrap_spec, applevel, \
WrappedDefault
-from pypy.module.micronumpy.base import W_NDimArray, convert_to_array,\
- ArrayArgumentException, wrap_impl
-from pypy.module.micronumpy import descriptor, ufuncs, boxes, arrayops
-from pypy.module.micronumpy.strides import get_shape_from_iterable, to_coords, \
- shape_agreement, shape_agreement_multiple
-from pypy.module.micronumpy.flagsobj import W_FlagsObject
-from pypy.module.micronumpy.flatiter import W_FlatIterator
-from pypy.module.micronumpy.appbridge import get_appbridge_cache
-from pypy.module.micronumpy import loop
-from pypy.module.micronumpy.arrayops import repeat, choose, put
-from rpython.tool.sourcetools import func_with_new_name
+from pypy.interpreter.typedef import TypeDef, GetSetProperty, make_weakref_descr
from rpython.rlib import jit
from rpython.rlib.rstring import StringBuilder
+from rpython.rlib.rawstorage import RAW_STORAGE_PTR
+from rpython.rtyper.lltypesystem import rffi
+from rpython.tool.sourcetools import func_with_new_name
+from pypy.module.micronumpy import descriptor, ufuncs, boxes, arrayops, loop, \
+ support, constants as NPY
+from pypy.module.micronumpy.appbridge import get_appbridge_cache
+from pypy.module.micronumpy.arrayops import repeat, choose, put
+from pypy.module.micronumpy.base import W_NDimArray, convert_to_array, \
+ ArrayArgumentException, wrap_impl
from pypy.module.micronumpy.concrete import BaseConcreteArray
from pypy.module.micronumpy.converters import order_converter, shape_converter, \
multi_axis_converter
-from pypy.module.micronumpy import support
-from pypy.module.micronumpy import constants as NPY
+from pypy.module.micronumpy.flagsobj import W_FlagsObject
+from pypy.module.micronumpy.flatiter import W_FlatIterator
+from pypy.module.micronumpy.strides import get_shape_from_iterable, to_coords, \
+ shape_agreement, shape_agreement_multiple
def _match_dot_shapes(space, left, right):
@@ -1132,7 +1130,7 @@
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.support import calc_strides
+ 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/sort.py b/pypy/module/micronumpy/sort.py
--- a/pypy/module/micronumpy/sort.py
+++ b/pypy/module/micronumpy/sort.py
@@ -1,18 +1,16 @@
-
""" This is the implementation of various sorting routines in numpy. It's here
because it only makes sense on a concrete array
"""
-
-from rpython.rtyper.lltypesystem import rffi, lltype
+from pypy.interpreter.error import OperationError, oefmt
from rpython.rlib.listsort import make_timsort_class
+from rpython.rlib.objectmodel import specialize
+from rpython.rlib.rarithmetic import widen
from rpython.rlib.rawstorage import raw_storage_getitem, raw_storage_setitem, \
free_raw_storage, alloc_raw_storage
from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.rarithmetic import widen
-from rpython.rlib.objectmodel import specialize
-from pypy.interpreter.error import OperationError, oefmt
+from rpython.rtyper.lltypesystem import rffi, lltype
+from pypy.module.micronumpy import descriptor, types, constants as NPY
from pypy.module.micronumpy.base import W_NDimArray
-from pypy.module.micronumpy import descriptor, types, constants as NPY
from pypy.module.micronumpy.iter import AxisIterator
INT_SIZE = rffi.sizeof(lltype.Signed)
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
@@ -1,8 +1,7 @@
+from pypy.interpreter.error import OperationError, oefmt
from rpython.rlib import jit
-from pypy.interpreter.error import OperationError, oefmt
+from pypy.module.micronumpy import support, constants as NPY
from pypy.module.micronumpy.base import W_NDimArray
-from pypy.module.micronumpy import support
-from pypy.module.micronumpy import constants as NPY
# structures to describe slicing
@@ -21,7 +20,6 @@
# ofs only changes start
# create a view of the original array by extending
# the shape, strides, backstrides of the array
- from pypy.module.micronumpy.support import calc_strides
strides, backstrides = calc_strides(subdtype.shape,
subdtype.subdtype, arr.order)
final_shape = arr.shape + subdtype.shape
@@ -345,6 +343,25 @@
return new_shape
+ at jit.unroll_safe
+def calc_strides(shape, dtype, order):
+ strides = []
+ backstrides = []
+ s = 1
+ shape_rev = shape[:]
+ if order == 'C':
+ shape_rev.reverse()
+ for sh in shape_rev:
+ slimit = max(sh, 1)
+ strides.append(s * dtype.elsize)
+ backstrides.append(s * (slimit - 1) * dtype.elsize)
+ s *= slimit
+ if order == 'C':
+ strides.reverse()
+ backstrides.reverse()
+ return strides, backstrides
+
+
# Recalculating strides. Find the steps that the iteration does for each
# dimension, given the stride and shape. Then try to create a new stride that
# fits the new shape, using those steps. If there is a shape/step mismatch
diff --git a/pypy/module/micronumpy/support.py b/pypy/module/micronumpy/support.py
--- a/pypy/module/micronumpy/support.py
+++ b/pypy/module/micronumpy/support.py
@@ -1,5 +1,5 @@
+from pypy.interpreter.error import OperationError, oefmt
from rpython.rlib import jit
-from pypy.interpreter.error import OperationError, oefmt
def issequence_w(space, w_obj):
@@ -25,22 +25,3 @@
for x in s:
i *= x
return i
-
-
- at jit.unroll_safe
-def calc_strides(shape, dtype, order):
- strides = []
- backstrides = []
- s = 1
- shape_rev = shape[:]
- if order == 'C':
- shape_rev.reverse()
- for sh in shape_rev:
- slimit = max(sh, 1)
- strides.append(s * dtype.elsize)
- backstrides.append(s * (slimit - 1) * dtype.elsize)
- s *= slimit
- if order == 'C':
- strides.reverse()
- backstrides.reverse()
- return strides, backstrides
diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -850,6 +850,17 @@
assert b == a
b[...] = 2.5
assert a == 2.5
+ a = array([]).reshape((0, 2))
+ assert a.shape == (0, 2)
+ assert a.strides == (16, 8)
+ a = array([])
+ a.shape = (4, 0, 3, 0, 0, 2)
+ assert a.strides == (48, 48, 16, 16, 16, 8)
+ a = array(1.5)
+ assert a.reshape(()).shape == ()
+ a = array(1.5)
+ a.shape = ()
+ assert a.strides == ()
a = array(range(12))
exc = raises(ValueError, "b = a.reshape(())")
assert str(exc.value) == "total size of new array must be unchanged"
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
@@ -1,32 +1,31 @@
import functools
import math
-
from pypy.interpreter.error import OperationError, oefmt
-from pypy.module.micronumpy import boxes
-from pypy.module.micronumpy import support
-from pypy.module.micronumpy.concrete import SliceArray, VoidBoxStorage
from pypy.objspace.std.floatobject import float2string
from pypy.objspace.std.complexobject import str_format
-from rpython.rlib import rfloat, clibffi, rcomplex
-from rpython.rlib.rawstorage import (alloc_raw_storage,
- raw_storage_getitem_unaligned, raw_storage_setitem_unaligned)
+from rpython.rlib import clibffi, jit, rfloat, rcomplex
from rpython.rlib.objectmodel import specialize
from rpython.rlib.rarithmetic import widen, byteswap, r_ulonglong, \
most_neg_value_of, LONG_BIT
-from rpython.rtyper.lltypesystem import lltype, rffi
-from rpython.rlib.rstruct.runpack import runpack
-from rpython.rlib.rstruct.nativefmttable import native_is_bigendian
+from rpython.rlib.rawstorage import (alloc_raw_storage,
+ raw_storage_getitem_unaligned, raw_storage_setitem_unaligned)
+from rpython.rlib.rstring import StringBuilder
from rpython.rlib.rstruct.ieee import (float_pack, float_unpack, unpack_float,
pack_float80, unpack_float80)
+from rpython.rlib.rstruct.nativefmttable import native_is_bigendian
+from rpython.rlib.rstruct.runpack import runpack
+from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.tool.sourcetools import func_with_new_name
-from rpython.rlib import jit
-from rpython.rlib.rstring import StringBuilder
+from pypy.module.micronumpy import boxes
+from pypy.module.micronumpy.concrete import SliceArray, VoidBoxStorage
+from pypy.module.micronumpy.strides import calc_strides
degToRad = math.pi / 180.0
log2 = math.log(2)
log2e = 1. / log2
log10 = math.log(10)
+
def simple_unary_op(func):
specialize.argtype(1)(func)
@functools.wraps(func)
@@ -1792,8 +1791,8 @@
from pypy.module.micronumpy.base import W_NDimArray
if dtype is None:
dtype = arr.dtype
- strides, backstrides = support.calc_strides(dtype.shape,
- dtype.subdtype, arr.order)
+ strides, backstrides = calc_strides(dtype.shape, dtype.subdtype,
+ arr.order)
implementation = SliceArray(i + offset, strides, backstrides,
dtype.shape, arr, W_NDimArray(arr),
dtype.subdtype)
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -2,13 +2,12 @@
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef, GetSetProperty, interp_attrproperty
-from pypy.module.micronumpy import boxes, descriptor, loop
from rpython.rlib import jit
from rpython.rlib.rarithmetic import LONG_BIT, maxint
from rpython.tool.sourcetools import func_with_new_name
+from pypy.module.micronumpy import boxes, descriptor, loop, constants as NPY
+from pypy.module.micronumpy.base import convert_to_array, W_NDimArray
from pypy.module.micronumpy.strides import shape_agreement
-from pypy.module.micronumpy.base import convert_to_array, W_NDimArray
-from pypy.module.micronumpy import constants as NPY
def done_if_true(dtype, val):
return dtype.itemtype.bool(val)
More information about the pypy-commit
mailing list