[pypy-commit] pypy numpy-cleanup: more cleanups, rename micronumpy to _numpypy
fijal
noreply at buildbot.pypy.org
Sat Jun 23 15:43:51 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-cleanup
Changeset: r55779:0c016a5fd264
Date: 2012-06-23 15:43 +0200
http://bitbucket.org/pypy/pypy/changeset/0c016a5fd264/
Log: more cleanups, rename micronumpy to _numpypy
diff --git a/pypy/annotation/test/test_annrpython.py b/pypy/annotation/test/test_annrpython.py
--- a/pypy/annotation/test/test_annrpython.py
+++ b/pypy/annotation/test/test_annrpython.py
@@ -2484,7 +2484,7 @@
assert s.const == 5
def test_multiple_mixins_mro(self):
- # an obscure situation, but it occurred in module/micronumpy/types.py
+ # an obscure situation, but it occurred in module/_numpypy/types.py
class A(object):
_mixin_ = True
def foo(self): return 1
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -33,7 +33,7 @@
"struct", "_hashlib", "_md5", "_sha", "_minimal_curses", "cStringIO",
"thread", "itertools", "pyexpat", "_ssl", "cpyext", "array",
"_bisect", "binascii", "_multiprocessing", '_warnings',
- "_collections", "_multibytecodec", "micronumpy", "_ffi",
+ "_collections", "_multibytecodec", "_numpypy", "_ffi",
"_continuation"]
))
diff --git a/pypy/jit/tl/pypyjit.py b/pypy/jit/tl/pypyjit.py
--- a/pypy/jit/tl/pypyjit.py
+++ b/pypy/jit/tl/pypyjit.py
@@ -44,7 +44,7 @@
#
config.objspace.usemodules._ffi = True
#config.objspace.usemodules.cppyy = True
-config.objspace.usemodules.micronumpy = False
+config.objspace.usemodules._numpypy = False
#
set_pypy_opt_level(config, level='jit')
diff --git a/pypy/module/micronumpy/+interp_numarray.py b/pypy/module/_numpypy/+interp_numarray.py
rename from pypy/module/micronumpy/+interp_numarray.py
rename to pypy/module/_numpypy/+interp_numarray.py
--- a/pypy/module/micronumpy/+interp_numarray.py
+++ b/pypy/module/_numpypy/+interp_numarray.py
@@ -2,20 +2,20 @@
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, interp_boxes,
+from pypy.module._numpypy import (interp_ufuncs, interp_dtype, interp_boxes,
signature, support, loop)
-from pypy.module.micronumpy.appbridge import get_appbridge_cache
-from pypy.module.micronumpy.dot import multidim_dot, match_dot_shapes
-from pypy.module.micronumpy.interp_iter import (ArrayIterator,
+from pypy.module._numpypy.appbridge import get_appbridge_cache
+from pypy.module._numpypy.dot import multidim_dot, match_dot_shapes
+from pypy.module._numpypy.interp_iter import (ArrayIterator,
SkipLastAxisIterator, Chunk, ViewIterator, Chunks, RecordChunk,
NewAxisChunk)
-from pypy.module.micronumpy.strides import (shape_agreement,
+from pypy.module._numpypy.strides import (shape_agreement,
find_shape_and_elems, get_shape_from_iterable, calc_new_strides, to_coords)
from pypy.rlib import jit
from pypy.rlib.rstring import StringBuilder
from pypy.rpython.lltypesystem import lltype, rffi
from pypy.tool.sourcetools import func_with_new_name
-from pypy.module.micronumpy.interp_support import unwrap_axis_arg
+from pypy.module._numpypy.interp_support import unwrap_axis_arg
count_driver = jit.JitDriver(
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/_numpypy/__init__.py
rename from pypy/module/micronumpy/__init__.py
rename to pypy/module/_numpypy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/_numpypy/__init__.py
@@ -9,20 +9,16 @@
}
appleveldefs = {}
-class MultiArrayModule(MixedModule):
- interpleveldefs = {
- 'ndarray': 'interp_numarray.W_NDArray',
- }
-
class Module(MixedModule):
applevel_name = '_numpypy'
submodules = {
'pypy': PyPyModule,
- 'multiarray': MultiArrayModule,
}
- interpleveldefs = {}
+ interpleveldefs = {
+ 'ndarray': 'interp_numarray.W_NDArray',
+ }
appleveldefs = {}
# interpleveldefs = {
diff --git a/pypy/module/micronumpy/app_numpy.py b/pypy/module/_numpypy/app_numpy.py
rename from pypy/module/micronumpy/app_numpy.py
rename to pypy/module/_numpypy/app_numpy.py
diff --git a/pypy/module/micronumpy/appbridge.py b/pypy/module/_numpypy/appbridge.py
rename from pypy/module/micronumpy/appbridge.py
rename to pypy/module/_numpypy/appbridge.py
diff --git a/pypy/module/micronumpy/bench/add.py b/pypy/module/_numpypy/bench/add.py
rename from pypy/module/micronumpy/bench/add.py
rename to pypy/module/_numpypy/bench/add.py
diff --git a/pypy/module/micronumpy/bench/iterate.py b/pypy/module/_numpypy/bench/iterate.py
rename from pypy/module/micronumpy/bench/iterate.py
rename to pypy/module/_numpypy/bench/iterate.py
diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/_numpypy/compile.py
rename from pypy/module/micronumpy/compile.py
rename to pypy/module/_numpypy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/_numpypy/compile.py
@@ -7,12 +7,12 @@
from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
from pypy.interpreter.error import OperationError
-from pypy.module.micronumpy import interp_boxes
-from pypy.module.micronumpy.interp_dtype import get_dtype_cache
-from pypy.module.micronumpy.interp_numarray import (Scalar, BaseArray,
+from pypy.module._numpypy import interp_boxes
+from pypy.module._numpypy.interp_dtype import get_dtype_cache
+from pypy.module._numpypy.interp_numarray import (Scalar, BaseArray,
scalar_w, W_NDimArray, array)
-from pypy.module.micronumpy.interp_arrayops import where
-from pypy.module.micronumpy import interp_ufuncs
+from pypy.module._numpypy.interp_arrayops import where
+from pypy.module._numpypy import interp_ufuncs
from pypy.rlib.objectmodel import specialize, instantiate
diff --git a/pypy/module/micronumpy/dot.py b/pypy/module/_numpypy/dot.py
rename from pypy/module/micronumpy/dot.py
rename to pypy/module/_numpypy/dot.py
--- a/pypy/module/micronumpy/dot.py
+++ b/pypy/module/_numpypy/dot.py
@@ -1,6 +1,6 @@
-from pypy.module.micronumpy.strides import calculate_dot_strides
+from pypy.module._numpypy.strides import calculate_dot_strides
from pypy.interpreter.error import OperationError
-from pypy.module.micronumpy.interp_iter import ViewIterator
+from pypy.module._numpypy.interp_iter import ViewIterator
from pypy.rlib import jit
def dot_printable_location(shapelen):
diff --git a/pypy/module/micronumpy/interp_arrayops.py b/pypy/module/_numpypy/interp_arrayops.py
rename from pypy/module/micronumpy/interp_arrayops.py
rename to pypy/module/_numpypy/interp_arrayops.py
--- a/pypy/module/micronumpy/interp_arrayops.py
+++ b/pypy/module/_numpypy/interp_arrayops.py
@@ -1,7 +1,7 @@
-from pypy.module.micronumpy.interp_numarray import convert_to_array,\
+from pypy.module._numpypy.interp_numarray import convert_to_array,\
VirtualArray
-from pypy.module.micronumpy import signature
+from pypy.module._numpypy import signature
class WhereArray(VirtualArray):
def __init__(self, space, arr, x, y):
diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/_numpypy/interp_boxes.py
rename from pypy/module/micronumpy/interp_boxes.py
rename to pypy/module/_numpypy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/_numpypy/interp_boxes.py
@@ -15,7 +15,7 @@
def new_dtype_getter(name):
def _get_dtype(space):
- from pypy.module.micronumpy.interp_dtype import get_dtype_cache
+ from pypy.module._numpypy.interp_dtype import get_dtype_cache
return getattr(get_dtype_cache(space), "w_%sdtype" % name)
def new(space, w_subtype, w_value):
@@ -67,21 +67,21 @@
def _binop_impl(ufunc_name):
def impl(self, space, w_other, w_out=None):
- from pypy.module.micronumpy import interp_ufuncs
+ from pypy.module._numpypy import interp_ufuncs
return getattr(interp_ufuncs.get(space), ufunc_name).call(space,
[self, w_other, w_out])
return func_with_new_name(impl, "binop_%s_impl" % ufunc_name)
def _binop_right_impl(ufunc_name):
def impl(self, space, w_other, w_out=None):
- from pypy.module.micronumpy import interp_ufuncs
+ from pypy.module._numpypy import interp_ufuncs
return getattr(interp_ufuncs.get(space), ufunc_name).call(space,
[w_other, self, w_out])
return func_with_new_name(impl, "binop_right_%s_impl" % ufunc_name)
def _unaryop_impl(ufunc_name):
def impl(self, space, w_out=None):
- from pypy.module.micronumpy import interp_ufuncs
+ from pypy.module._numpypy import interp_ufuncs
return getattr(interp_ufuncs.get(space), ufunc_name).call(space,
[self, w_out])
return func_with_new_name(impl, "unaryop_%s_impl" % ufunc_name)
@@ -246,8 +246,8 @@
class W_StringBox(W_CharacterBox):
def descr__new__string_box(space, w_subtype, w_arg):
- from pypy.module.micronumpy.interp_numarray import W_NDimArray
- from pypy.module.micronumpy.interp_dtype import new_string_dtype
+ from pypy.module._numpypy.interp_numarray import W_NDimArray
+ from pypy.module._numpypy.interp_dtype import new_string_dtype
arg = space.str_w(space.str(w_arg))
arr = W_NDimArray([1], new_string_dtype(space, len(arg)))
@@ -258,8 +258,8 @@
class W_UnicodeBox(W_CharacterBox):
def descr__new__unicode_box(space, w_subtype, w_arg):
- from pypy.module.micronumpy.interp_numarray import W_NDimArray
- from pypy.module.micronumpy.interp_dtype import new_unicode_dtype
+ from pypy.module._numpypy.interp_numarray import W_NDimArray
+ from pypy.module._numpypy.interp_dtype import new_unicode_dtype
arg = space.unicode_w(unicode_from_object(space, w_arg))
arr = W_NDimArray([1], new_unicode_dtype(space, len(arg)))
diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/_numpypy/interp_dtype.py
rename from pypy/module/micronumpy/interp_dtype.py
rename to pypy/module/_numpypy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/_numpypy/interp_dtype.py
@@ -5,7 +5,7 @@
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, interp_boxes
+from pypy.module._numpypy import types, interp_boxes
from pypy.rlib.objectmodel import specialize
from pypy.rlib.rarithmetic import LONG_BIT, r_longlong, r_ulonglong
diff --git a/pypy/module/micronumpy/interp_extras.py b/pypy/module/_numpypy/interp_extras.py
rename from pypy/module/micronumpy/interp_extras.py
rename to pypy/module/_numpypy/interp_extras.py
--- a/pypy/module/micronumpy/interp_extras.py
+++ b/pypy/module/_numpypy/interp_extras.py
@@ -1,5 +1,5 @@
from pypy.interpreter.gateway import unwrap_spec
-from pypy.module.micronumpy.interp_numarray import BaseArray, get_numarray_cache
+from pypy.module._numpypy.interp_numarray import BaseArray, get_numarray_cache
@unwrap_spec(array=BaseArray)
diff --git a/pypy/module/micronumpy/interp_iter.py b/pypy/module/_numpypy/interp_iter.py
rename from pypy/module/micronumpy/interp_iter.py
rename to pypy/module/_numpypy/interp_iter.py
--- a/pypy/module/micronumpy/interp_iter.py
+++ b/pypy/module/_numpypy/interp_iter.py
@@ -1,7 +1,7 @@
from pypy.rlib import jit
from pypy.rlib.objectmodel import instantiate
-from pypy.module.micronumpy.strides import calculate_broadcast_strides,\
+from pypy.module._numpypy.strides import calculate_broadcast_strides,\
calculate_slice_strides, calculate_dot_strides, enumerate_chunks
""" This is a mini-tutorial on iterators, strides, and
@@ -57,7 +57,7 @@
self.name = name
def apply(self, arr):
- from pypy.module.micronumpy.interp_numarray import W_NDimSlice
+ from pypy.module._numpypy.interp_numarray import W_NDimSlice
arr = arr.get_concrete()
ofs, subdtype = arr.dtype.fields[self.name]
@@ -81,7 +81,7 @@
return shape[:] + old_shape[s:]
def apply(self, arr):
- from pypy.module.micronumpy.interp_numarray import W_NDimSlice,\
+ from pypy.module._numpypy.interp_numarray import W_NDimSlice,\
VirtualSlice, ConcreteArray
shape = self.extend_shape(arr.shape)
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/_numpypy/interp_numarray.py
rename from pypy/module/micronumpy/interp_numarray.py
rename to pypy/module/_numpypy/interp_numarray.py
diff --git a/pypy/module/micronumpy/interp_support.py b/pypy/module/_numpypy/interp_support.py
rename from pypy/module/micronumpy/interp_support.py
rename to pypy/module/_numpypy/interp_support.py
--- a/pypy/module/micronumpy/interp_support.py
+++ b/pypy/module/_numpypy/interp_support.py
@@ -1,7 +1,7 @@
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import unwrap_spec
from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.module.micronumpy import interp_dtype
+from pypy.module._numpypy import interp_dtype
from pypy.objspace.std.strutil import strip_spaces
from pypy.rlib import jit
from pypy.rlib.rarithmetic import maxint
@@ -9,7 +9,7 @@
FLOAT_SIZE = rffi.sizeof(lltype.Float)
def _fromstring_text(space, s, count, sep, length, dtype):
- from pypy.module.micronumpy.interp_numarray import W_NDimArray
+ from pypy.module._numpypy.interp_numarray import W_NDimArray
sep_stripped = strip_spaces(sep)
skip_bad_vals = len(sep_stripped) == 0
@@ -61,7 +61,7 @@
return space.wrap(a)
def _fromstring_bin(space, s, count, length, dtype):
- from pypy.module.micronumpy.interp_numarray import W_NDimArray
+ from pypy.module._numpypy.interp_numarray import W_NDimArray
itemsize = dtype.itemtype.get_element_size()
assert itemsize >= 0
diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/_numpypy/interp_ufuncs.py
rename from pypy/module/micronumpy/interp_ufuncs.py
rename to pypy/module/_numpypy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/_numpypy/interp_ufuncs.py
@@ -2,11 +2,11 @@
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import interp2app, unwrap_spec, NoneNotWrapped
from pypy.interpreter.typedef import TypeDef, GetSetProperty, interp_attrproperty
-from pypy.module.micronumpy import interp_boxes, interp_dtype, loop
+from pypy.module._numpypy import interp_boxes, interp_dtype, loop
from pypy.rlib import jit
from pypy.rlib.rarithmetic import LONG_BIT
from pypy.tool.sourcetools import func_with_new_name
-from pypy.module.micronumpy.interp_support import unwrap_axis_arg
+from pypy.module._numpypy.interp_support import unwrap_axis_arg
class W_Ufunc(Wrappable):
_attrs_ = ["name", "promote_to_float", "promote_bools", "identity"]
@@ -119,7 +119,7 @@
array([[ 1, 5],
[ 9, 13]])
"""
- from pypy.module.micronumpy.interp_numarray import BaseArray
+ from pypy.module._numpypy.interp_numarray import BaseArray
if w_axis is None:
w_axis = space.wrap(0)
if space.is_w(w_out, space.w_None):
@@ -133,7 +133,7 @@
def reduce(self, space, w_obj, multidim, promote_to_largest, w_axis,
keepdims=False, out=None):
- from pypy.module.micronumpy.interp_numarray import convert_to_array, \
+ from pypy.module._numpypy.interp_numarray import convert_to_array, \
Scalar, ReduceArray, W_NDimArray
if self.argcount != 2:
raise OperationError(space.w_ValueError, space.wrap("reduce only "
@@ -205,7 +205,7 @@
return val
def do_axis_reduce(self, obj, dtype, axis, result):
- from pypy.module.micronumpy.interp_numarray import AxisReduce
+ from pypy.module._numpypy.interp_numarray import AxisReduce
arr = AxisReduce(self.func, self.name, self.identity, obj.shape, dtype,
result, obj, axis)
loop.compute(arr)
@@ -225,7 +225,7 @@
self.bool_result = bool_result
def call(self, space, args_w):
- from pypy.module.micronumpy.interp_numarray import (Call1, BaseArray,
+ from pypy.module._numpypy.interp_numarray import (Call1, BaseArray,
convert_to_array, Scalar, shape_agreement)
if len(args_w)<2:
[w_obj] = args_w
@@ -292,7 +292,7 @@
@jit.unroll_safe
def call(self, space, args_w):
- from pypy.module.micronumpy.interp_numarray import (Call2,
+ from pypy.module._numpypy.interp_numarray import (Call2,
convert_to_array, Scalar, shape_agreement, BaseArray)
if len(args_w) > 2:
[w_lhs, w_rhs, w_out] = args_w
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/_numpypy/loop.py
rename from pypy/module/micronumpy/loop.py
rename to pypy/module/_numpypy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/_numpypy/loop.py
@@ -4,7 +4,7 @@
"""
from pypy.rlib.jit import JitDriver, hint, unroll_safe, promote
-from pypy.module.micronumpy.interp_iter import ConstantIterator
+from pypy.module._numpypy.interp_iter import ConstantIterator
class NumpyEvalFrame(object):
_virtualizable2_ = ['iterators[*]', 'final_iter', 'arraylist[*]',
diff --git a/pypy/module/micronumpy/signature.py b/pypy/module/_numpypy/signature.py
rename from pypy/module/micronumpy/signature.py
rename to pypy/module/_numpypy/signature.py
--- a/pypy/module/micronumpy/signature.py
+++ b/pypy/module/_numpypy/signature.py
@@ -1,9 +1,9 @@
from pypy.rlib.objectmodel import r_dict, compute_identity_hash, compute_hash
from pypy.rlib.rarithmetic import intmask
-from pypy.module.micronumpy.interp_iter import ConstantIterator, AxisIterator,\
+from pypy.module._numpypy.interp_iter import ConstantIterator, AxisIterator,\
ViewTransform, BroadcastTransform
from pypy.tool.pairtype import extendabletype
-from pypy.module.micronumpy.loop import ComputationDone
+from pypy.module._numpypy.loop import ComputationDone
from pypy.rlib import jit
""" Signature specifies both the numpy expression that has been constructed
@@ -97,7 +97,7 @@
self.iter_no = no
def create_frame(self, arr):
- from pypy.module.micronumpy.loop import NumpyEvalFrame
+ from pypy.module._numpypy.loop import NumpyEvalFrame
iterlist = []
arraylist = []
@@ -134,7 +134,7 @@
return 'Array'
def _invent_array_numbering(self, arr, cache):
- from pypy.module.micronumpy.interp_numarray import ConcreteArray
+ from pypy.module._numpypy.interp_numarray import ConcreteArray
concr = arr.get_concrete()
# this get_concrete never forces assembler. If we're here and array
# is not of a concrete class it means that we have a _forced_result,
@@ -144,7 +144,7 @@
self.array_no = _add_ptr_to_cache(concr.storage, cache)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import ConcreteArray
+ from pypy.module._numpypy.interp_numarray import ConcreteArray
concr = arr.get_concrete()
assert isinstance(concr, ConcreteArray)
if self.iter_no >= len(iterlist):
@@ -169,7 +169,7 @@
iterlist.append(iter)
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import Scalar
+ from pypy.module._numpypy.interp_numarray import Scalar
assert isinstance(arr, Scalar)
return arr.value
@@ -192,7 +192,7 @@
self.child = child
def _invent_array_numbering(self, arr, cache):
- from pypy.module.micronumpy.interp_numarray import VirtualSlice
+ from pypy.module._numpypy.interp_numarray import VirtualSlice
assert isinstance(arr, VirtualSlice)
self.child._invent_array_numbering(arr.child, cache)
@@ -209,13 +209,13 @@
return self.child.eq(other.child, compare_array_no)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import VirtualSlice
+ from pypy.module._numpypy.interp_numarray import VirtualSlice
assert isinstance(arr, VirtualSlice)
transforms = [ViewTransform(arr.chunks)] + transforms
self.child._create_iter(iterlist, arraylist, arr.child, transforms)
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import VirtualSlice
+ from pypy.module._numpypy.interp_numarray import VirtualSlice
assert isinstance(arr, VirtualSlice)
return self.child.eval(frame, arr.child)
@@ -249,17 +249,17 @@
self.child._invent_numbering(cache, allnumbers)
def _invent_array_numbering(self, arr, cache):
- from pypy.module.micronumpy.interp_numarray import Call1
+ from pypy.module._numpypy.interp_numarray import Call1
assert isinstance(arr, Call1)
self.child._invent_array_numbering(arr.values, cache)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import Call1
+ from pypy.module._numpypy.interp_numarray import Call1
assert isinstance(arr, Call1)
self.child._create_iter(iterlist, arraylist, arr.values, transforms)
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import Call1
+ from pypy.module._numpypy.interp_numarray import Call1
assert isinstance(arr, Call1)
v = self.child.eval(frame, arr.values).convert_to(arr.calc_dtype)
return self.unfunc(arr.calc_dtype, v)
@@ -274,7 +274,7 @@
return 'BroadcastUfunc(%s, %s)' % (self.name, self.child.debug_repr())
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import Call1
+ from pypy.module._numpypy.interp_numarray import Call1
assert isinstance(arr, Call1)
vtransforms = [BroadcastTransform(arr.values.shape)] + transforms
@@ -282,7 +282,7 @@
self.res._create_iter(iterlist, arraylist, arr.res, transforms)
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import Call1
+ from pypy.module._numpypy.interp_numarray import Call1
assert isinstance(arr, Call1)
v = self.child.eval(frame, arr.values).convert_to(arr.calc_dtype)
return self.unfunc(arr.calc_dtype, v)
@@ -311,7 +311,7 @@
self.right.eq(other.right, compare_array_no))
def _invent_array_numbering(self, arr, cache):
- from pypy.module.micronumpy.interp_numarray import Call2
+ from pypy.module._numpypy.interp_numarray import Call2
assert isinstance(arr, Call2)
self.left._invent_array_numbering(arr.left, cache)
self.right._invent_array_numbering(arr.right, cache)
@@ -321,14 +321,14 @@
self.right._invent_numbering(cache, allnumbers)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import Call2
+ from pypy.module._numpypy.interp_numarray import Call2
assert isinstance(arr, Call2)
self.left._create_iter(iterlist, arraylist, arr.left, transforms)
self.right._create_iter(iterlist, arraylist, arr.right, transforms)
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import Call2
+ from pypy.module._numpypy.interp_numarray import Call2
assert isinstance(arr, Call2)
lhs = self.left.eval(frame, arr.left).convert_to(self.calc_dtype)
rhs = self.right.eval(frame, arr.right).convert_to(self.calc_dtype)
@@ -343,7 +343,7 @@
Call2.__init__(self, None, 'assign', dtype, left, right)
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import ResultArray
+ from pypy.module._numpypy.interp_numarray import ResultArray
assert isinstance(arr, ResultArray)
offset = frame.get_final_iter().offset
@@ -352,7 +352,7 @@
class BroadcastResultSignature(ResultSignature):
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import ResultArray
+ from pypy.module._numpypy.interp_numarray import ResultArray
assert isinstance(arr, ResultArray)
rtransforms = [BroadcastTransform(arr.left.shape)] + transforms
@@ -365,7 +365,7 @@
@jit.unroll_safe
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import ToStringArray
+ from pypy.module._numpypy.interp_numarray import ToStringArray
assert isinstance(arr, ToStringArray)
arr.res_str.setitem(0, self.child.eval(frame, arr.values).convert_to(
@@ -379,7 +379,7 @@
self.right._invent_numbering(cache, allnumbers)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import Call2
+ from pypy.module._numpypy.interp_numarray import Call2
assert isinstance(arr, Call2)
ltransforms = [BroadcastTransform(arr.shape)] + transforms
@@ -392,7 +392,7 @@
self.right._invent_numbering(new_cache(), allnumbers)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import Call2
+ from pypy.module._numpypy.interp_numarray import Call2
assert isinstance(arr, Call2)
rtransforms = [BroadcastTransform(arr.shape)] + transforms
@@ -405,7 +405,7 @@
self.right._invent_numbering(new_cache(), allnumbers)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import Call2
+ from pypy.module._numpypy.interp_numarray import Call2
assert isinstance(arr, Call2)
rtransforms = [BroadcastTransform(arr.shape)] + transforms
@@ -423,7 +423,7 @@
self.done_func = done_func
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import ReduceArray
+ from pypy.module._numpypy.interp_numarray import ReduceArray
assert isinstance(arr, ReduceArray)
rval = self.right.eval(frame, arr.right).convert_to(self.calc_dtype)
if self.done_func is not None and self.done_func(self.calc_dtype, rval):
@@ -435,7 +435,7 @@
class SliceloopSignature(Call2):
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import Call2
+ from pypy.module._numpypy.interp_numarray import Call2
assert isinstance(arr, Call2)
ofs = frame.iterators[0].offset
@@ -456,7 +456,7 @@
self.right._invent_numbering(cache, allnumbers)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import SliceArray
+ from pypy.module._numpypy.interp_numarray import SliceArray
assert isinstance(arr, SliceArray)
rtransforms = [BroadcastTransform(arr.shape)] + transforms
@@ -465,7 +465,7 @@
class AxisReduceSignature(Call2):
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_numarray import AxisReduce,\
+ from pypy.module._numpypy.interp_numarray import AxisReduce,\
ConcreteArray
assert isinstance(arr, AxisReduce)
@@ -480,13 +480,13 @@
self.right._invent_numbering(cache, allnumbers)
def _invent_array_numbering(self, arr, cache):
- from pypy.module.micronumpy.interp_numarray import AxisReduce
+ from pypy.module._numpypy.interp_numarray import AxisReduce
assert isinstance(arr, AxisReduce)
self.right._invent_array_numbering(arr.right, cache)
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_numarray import AxisReduce
+ from pypy.module._numpypy.interp_numarray import AxisReduce
assert isinstance(arr, AxisReduce)
iterator = frame.get_final_iter()
@@ -527,7 +527,7 @@
self.ysig.eq(other.ysig, compare_array_no))
def _invent_array_numbering(self, arr, cache):
- from pypy.module.micronumpy.interp_arrayops import WhereArray
+ from pypy.module._numpypy.interp_arrayops import WhereArray
assert isinstance(arr, WhereArray)
self.arrsig._invent_array_numbering(arr.arr, cache)
self.xsig._invent_array_numbering(arr.x, cache)
@@ -539,7 +539,7 @@
self.ysig._invent_numbering(cache, allnumbers)
def _create_iter(self, iterlist, arraylist, arr, transforms):
- from pypy.module.micronumpy.interp_arrayops import WhereArray
+ from pypy.module._numpypy.interp_arrayops import WhereArray
assert isinstance(arr, WhereArray)
# XXX this does not support broadcasting correctly
@@ -548,7 +548,7 @@
self.ysig._create_iter(iterlist, arraylist, arr.y, transforms)
def eval(self, frame, arr):
- from pypy.module.micronumpy.interp_arrayops import WhereArray
+ from pypy.module._numpypy.interp_arrayops import WhereArray
assert isinstance(arr, WhereArray)
lhs = self.xsig.eval(frame, arr.x).convert_to(self.dtype)
rhs = self.ysig.eval(frame, arr.y).convert_to(self.dtype)
diff --git a/pypy/module/micronumpy/strides.py b/pypy/module/_numpypy/strides.py
rename from pypy/module/micronumpy/strides.py
rename to pypy/module/_numpypy/strides.py
diff --git a/pypy/module/micronumpy/support.py b/pypy/module/_numpypy/support.py
rename from pypy/module/micronumpy/support.py
rename to pypy/module/_numpypy/support.py
diff --git a/pypy/module/micronumpy/test/__init__.py b/pypy/module/_numpypy/test/__init__.py
rename from pypy/module/micronumpy/test/__init__.py
rename to pypy/module/_numpypy/test/__init__.py
diff --git a/pypy/module/micronumpy/test/test_arrayops.py b/pypy/module/_numpypy/test/test_arrayops.py
rename from pypy/module/micronumpy/test/test_arrayops.py
rename to pypy/module/_numpypy/test/test_arrayops.py
--- a/pypy/module/micronumpy/test/test_arrayops.py
+++ b/pypy/module/_numpypy/test/test_arrayops.py
@@ -1,15 +1,15 @@
-from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.module._numpypy.test.test_base import BaseNumpyAppTest
class AppTestNumSupport(BaseNumpyAppTest):
def test_where(self):
- from _numpypy import where, ones, zeros, array
+ from numpy import where, ones, zeros, array
a = [1, 2, 3, 0, -3]
a = where(array(a) > 0, ones(5), zeros(5))
assert (a == [1, 1, 1, 0, 0]).all()
def test_where_invalidates(self):
- from _numpypy import where, ones, zeros, array
+ from numpy import where, ones, zeros, array
a = array([1, 2, 3, 0, -3])
b = where(a > 0, ones(5), zeros(5))
a[0] = 0
diff --git a/pypy/module/micronumpy/test/test_base.py b/pypy/module/_numpypy/test/test_base.py
rename from pypy/module/micronumpy/test/test_base.py
rename to pypy/module/_numpypy/test/test_base.py
--- a/pypy/module/micronumpy/test/test_base.py
+++ b/pypy/module/_numpypy/test/test_base.py
@@ -1,11 +1,11 @@
import py
from pypy.conftest import gettestobjspace
-from pypy.module.micronumpy.interp_dtype import get_dtype_cache
-#from pypy.module.micronumpy.interp_numarray import W_NDimArray, Scalar
-from pypy.module.micronumpy.interp_ufuncs import (find_binop_result_dtype,
+from pypy.module._numpypy.interp_dtype import get_dtype_cache
+#from pypy.module._numpypy.interp_numarray import W_NDimArray, Scalar
+from pypy.module._numpypy.interp_ufuncs import (find_binop_result_dtype,
find_unaryop_result_dtype)
-from pypy.module.micronumpy.interp_boxes import W_Float64Box
-from pypy.module.micronumpy.interp_dtype import nonnative_byteorder_prefix,\
+from pypy.module._numpypy.interp_boxes import W_Float64Box
+from pypy.module._numpypy.interp_dtype import nonnative_byteorder_prefix,\
byteorder_prefix
from pypy.conftest import option
import sys
@@ -13,15 +13,12 @@
class BaseNumpyAppTest(object):
@classmethod
def setup_class(cls):
- if option.runappdirect:
- if '__pypy__' not in sys.builtin_module_names:
- import numpy
- # weeeell
- sys.modules['numpypy'] = numpy
- sys.modules['_numpypy'] = numpy
- cls.space = gettestobjspace(usemodules=['micronumpy'])
+ cls.space = gettestobjspace(usemodules=['_numpypy'])
+ if not option.runappdirect:
+ cls.space.builtin_modules['numpy'] = cls.space.builtin_modules['_numpypy']
cls.w_non_native_prefix = cls.space.wrap(nonnative_byteorder_prefix)
cls.w_native_prefix = cls.space.wrap(byteorder_prefix)
+ cls.w_newaxis = cls.space.w_None
class TestSignature(object):
def setup_class(cls):
diff --git a/pypy/module/micronumpy/test/test_compile.py b/pypy/module/_numpypy/test/test_compile.py
rename from pypy/module/micronumpy/test/test_compile.py
rename to pypy/module/_numpypy/test/test_compile.py
--- a/pypy/module/micronumpy/test/test_compile.py
+++ b/pypy/module/_numpypy/test/test_compile.py
@@ -1,7 +1,7 @@
import py
py.test.skip("disabled")
-from pypy.module.micronumpy.compile import (numpy_compile, Assignment,
+from pypy.module._numpypy.compile import (numpy_compile, Assignment,
ArrayConstant, FloatConstant, Operator, Variable, RangeConstant, Execute,
FunctionCall, FakeSpace)
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/_numpypy/test/test_dtypes.py
rename from pypy/module/micronumpy/test/test_dtypes.py
rename to pypy/module/_numpypy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/_numpypy/test/test_dtypes.py
@@ -1,11 +1,11 @@
import py
from pypy.conftest import option
-from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.module._numpypy.test.test_base import BaseNumpyAppTest
from pypy.interpreter.gateway import interp2app
class AppTestDtypes(BaseNumpyAppTest):
def test_dtype(self):
- from _numpypy import dtype
+ from numpy import dtype
d = dtype('?')
assert d.num == 0
@@ -20,7 +20,7 @@
raises(KeyError, 'dtype(int)["asdasd"]')
def test_dtype_eq(self):
- from _numpypy import dtype
+ from numpy import dtype
assert dtype("int8") == "int8"
assert "int8" == dtype("int8")
@@ -28,7 +28,7 @@
assert dtype(bool) == bool
def test_dtype_with_types(self):
- from _numpypy import dtype
+ from numpy import dtype
assert dtype(bool).num == 0
assert dtype(int).num == 7
@@ -36,13 +36,13 @@
assert dtype(float).num == 12
def test_array_dtype_attr(self):
- from _numpypy import array, dtype
+ from numpy import array, dtype
a = array(range(5), long)
assert a.dtype is dtype(long)
def test_repr_str(self):
- from _numpypy import dtype
+ from numpy import dtype
assert '.dtype' in repr(dtype)
d = dtype('?')
@@ -50,7 +50,7 @@
assert str(d) == "bool"
def test_bool_array(self):
- from _numpypy import array, False_, True_
+ from numpy import array, False_, True_
a = array([0, 1, 2, 2.5], dtype='?')
assert a[0] is False_
@@ -58,7 +58,7 @@
assert a[i] is True_
def test_copy_array_with_dtype(self):
- from _numpypy import array, False_, longlong
+ from numpy import array, False_, longlong
a = array([0, 1, 2, 3], dtype=long)
# int on 64-bit, long in 32-bit
@@ -72,35 +72,35 @@
assert b[0] is False_
def test_zeros_bool(self):
- from _numpypy import zeros, False_
+ from numpy import zeros, False_
a = zeros(10, dtype=bool)
for i in range(10):
assert a[i] is False_
def test_ones_bool(self):
- from _numpypy import ones, True_
+ from numpy import ones, True_
a = ones(10, dtype=bool)
for i in range(10):
assert a[i] is True_
def test_zeros_long(self):
- from _numpypy import zeros, longlong
+ from numpy import zeros, longlong
a = zeros(10, dtype=long)
for i in range(10):
assert isinstance(a[i], longlong)
assert a[1] == 0
def test_ones_long(self):
- from _numpypy import ones, longlong
+ from numpy import ones, longlong
a = ones(10, dtype=long)
for i in range(10):
assert isinstance(a[i], longlong)
assert a[1] == 1
def test_overflow(self):
- from _numpypy import array, dtype
+ from numpy import array, dtype
assert array([128], 'b')[0] == -128
assert array([256], 'B')[0] == 0
assert array([32768], 'h')[0] == -32768
@@ -112,7 +112,7 @@
raises(OverflowError, "array([2**64], 'Q')")
def test_bool_binop_types(self):
- from _numpypy import array, dtype
+ from numpy import array, dtype
types = [
'?', 'b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q', 'f', 'd'
]
@@ -121,7 +121,7 @@
assert (a + array([0], t)).dtype is dtype(t)
def test_binop_types(self):
- from _numpypy import array, dtype
+ from numpy import array, dtype
tests = [('b','B','h'), ('b','h','h'), ('b','H','i'), ('b','i','i'),
('b','l','l'), ('b','q','q'), ('b','Q','d'), ('B','h','h'),
('B','H','H'), ('B','i','i'), ('B','I','I'), ('B','l','l'),
@@ -143,7 +143,7 @@
assert (array([1], d1) + array([1], d2)).dtype is dtype(dout)
def test_add_int8(self):
- from _numpypy import array, dtype
+ from numpy import array, dtype
a = array(range(5), dtype="int8")
b = a + a
@@ -152,7 +152,7 @@
assert b[i] == i * 2
def test_add_int16(self):
- from _numpypy import array, dtype
+ from numpy import array, dtype
a = array(range(5), dtype="int16")
b = a + a
@@ -161,7 +161,7 @@
assert b[i] == i * 2
def test_add_uint32(self):
- from _numpypy import array, dtype
+ from numpy import array, dtype
a = array(range(5), dtype="I")
b = a + a
@@ -170,44 +170,44 @@
assert b[i] == i * 2
def test_shape(self):
- from _numpypy import dtype
+ from numpy import dtype
assert dtype(long).shape == ()
def test_cant_subclass(self):
- from _numpypy import dtype
+ from numpy import dtype
# You can't subclass dtype
raises(TypeError, type, "Foo", (dtype,), {})
def test_aliases(self):
- from _numpypy import dtype
+ from numpy import dtype
assert dtype("float") is dtype(float)
def test_index_int8(self):
- from _numpypy import array, int8
+ from numpy import array, int8
a = array(range(10), dtype=int8)
b = array([0] * 10, dtype=int8)
for idx in b: a[idx] += 1
def test_index_int16(self):
- from _numpypy import array, int16
+ from numpy import array, int16
a = array(range(10), dtype=int16)
b = array([0] * 10, dtype=int16)
for idx in b: a[idx] += 1
def test_index_int32(self):
- from _numpypy import array, int32
+ from numpy import array, int32
a = array(range(10), dtype=int32)
b = array([0] * 10, dtype=int32)
for idx in b: a[idx] += 1
def test_index_int64(self):
- from _numpypy import array, int64
+ from numpy import array, int64
a = array(range(10), dtype=int64)
b = array([0] * 10, dtype=int64)
@@ -215,7 +215,7 @@
a[idx] += 1
def test_hash(self):
- import _numpypy as numpy
+ import numpy
for tp, value in [
(numpy.int8, 4),
(numpy.int16, 5),
@@ -229,7 +229,7 @@
class AppTestTypes(BaseNumpyAppTest):
def test_abstract_types(self):
- import _numpypy as numpy
+ import numpy
raises(TypeError, numpy.generic, 0)
raises(TypeError, numpy.number, 0)
raises(TypeError, numpy.integer, 0)
@@ -243,16 +243,16 @@
raises(TypeError, numpy.inexact, 0)
def test_new(self):
- import _numpypy as np
+ import numpy as np
assert np.int_(4) == 4
assert np.float_(3.4) == 3.4
def test_pow(self):
- from _numpypy import int_
+ from numpy import int_
assert int_(4) ** 2 == 16
def test_bool(self):
- import _numpypy as numpy
+ import numpy
assert numpy.bool_.mro() == [numpy.bool_, numpy.generic, object]
assert numpy.bool_(3) is numpy.True_
@@ -267,7 +267,7 @@
assert numpy.bool_("False") is numpy.True_
def test_int8(self):
- import _numpypy as numpy
+ import numpy
assert numpy.int8.mro() == [numpy.int8, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, object]
@@ -289,7 +289,7 @@
assert numpy.int8('128') == -128
def test_uint8(self):
- import _numpypy as numpy
+ import numpy
assert numpy.uint8.mro() == [numpy.uint8, numpy.unsignedinteger, numpy.integer, numpy.number, numpy.generic, object]
@@ -312,7 +312,7 @@
assert numpy.uint8('256') == 0
def test_int16(self):
- import _numpypy as numpy
+ import numpy
x = numpy.int16(3)
assert x == 3
@@ -322,7 +322,7 @@
assert numpy.int16('32768') == -32768
def test_uint16(self):
- import _numpypy as numpy
+ import numpy
assert numpy.uint16(65535) == 65535
assert numpy.uint16(65536) == 0
@@ -331,7 +331,7 @@
def test_int32(self):
import sys
- import _numpypy as numpy
+ import numpy
x = numpy.int32(23)
assert x == 23
@@ -347,7 +347,7 @@
def test_uint32(self):
import sys
- import _numpypy as numpy
+ import numpy
assert numpy.uint32(10) == 10
@@ -358,14 +358,14 @@
assert numpy.uint32('4294967296') == 0
def test_int_(self):
- import _numpypy as numpy
+ import numpy
assert numpy.int_ is numpy.dtype(int).type
assert numpy.int_.mro() == [numpy.int_, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, int, object]
def test_int64(self):
import sys
- import _numpypy as numpy
+ import numpy
if sys.maxint == 2 ** 63 -1:
assert numpy.int64.mro() == [numpy.int64, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, int, object]
@@ -383,7 +383,7 @@
def test_uint64(self):
import sys
- import _numpypy as numpy
+ import numpy
assert numpy.uint64.mro() == [numpy.uint64, numpy.unsignedinteger, numpy.integer, numpy.number, numpy.generic, object]
@@ -398,7 +398,7 @@
raises(OverflowError, numpy.uint64(18446744073709551616))
def test_float32(self):
- import _numpypy as numpy
+ import numpy
assert numpy.float32.mro() == [numpy.float32, numpy.floating, numpy.inexact, numpy.number, numpy.generic, object]
@@ -407,7 +407,7 @@
raises(ValueError, numpy.float32, '23.2df')
def test_float64(self):
- import _numpypy as numpy
+ import numpy
assert numpy.float64.mro() == [numpy.float64, numpy.floating, numpy.inexact, numpy.number, numpy.generic, float, object]
@@ -422,7 +422,7 @@
raises(ValueError, numpy.float64, '23.2df')
def test_subclass_type(self):
- import _numpypy as numpy
+ import numpy
class X(numpy.float64):
def m(self):
@@ -433,13 +433,13 @@
assert b.m() == 12
def test_long_as_index(self):
- from _numpypy import int_, float64
+ from numpy import int_, float64
assert (1, 2, 3)[int_(1)] == 2
raises(TypeError, lambda: (1, 2, 3)[float64(1)])
def test_int(self):
import sys
- from _numpypy import int32, int64, int_
+ from numpy import int32, int64, int_
assert issubclass(int_, int)
if sys.maxint == (1<<31) - 1:
assert issubclass(int32, int)
@@ -449,7 +449,7 @@
assert int_ is int64
def test_various_types(self):
- import _numpypy as numpy
+ import numpy
import sys
assert numpy.int16 is numpy.short
@@ -461,7 +461,7 @@
assert numpy.intp is numpy.int32
def test_mro(self):
- import _numpypy as numpy
+ import numpy
assert numpy.int16.__mro__ == (numpy.int16, numpy.signedinteger,
numpy.integer, numpy.number,
@@ -470,7 +470,7 @@
def test_operators(self):
from operator import truediv
- from _numpypy import float64, int_, True_, False_
+ from numpy import float64, int_, True_, False_
assert 5 / int_(2) == int_(2)
assert truediv(int_(3), int_(2)) == float64(1.5)
assert truediv(3, int_(2)) == float64(1.5)
@@ -495,7 +495,7 @@
raises(TypeError, lambda: float64(3) & 1)
def test_alternate_constructs(self):
- from _numpypy import dtype
+ from numpy import dtype
nnp = self.non_native_prefix
byteorder = self.native_prefix
assert dtype('i8') == dtype(byteorder + 'i8') == dtype('=i8') # XXX should be equal == dtype(long)
@@ -505,12 +505,12 @@
assert dtype(byteorder + 'i8').byteorder == '='
def test_alignment(self):
- from _numpypy import dtype
+ from numpy import dtype
assert dtype('i4').alignment == 4
def test_typeinfo(self):
from numpy.core.multiarray import typeinfo
- from _numpypy import void, number, longlong, bool_
+ from numpy import void, number, longlong, bool_
assert typeinfo['Number'] == number
assert typeinfo['LONGLONG'] == ('q', 9, 64, 8, 9223372036854775807L, -9223372036854775808L, longlong)
assert typeinfo['VOID'] == ('V', 20, 0, 1, void)
@@ -518,13 +518,13 @@
class AppTestStrUnicodeDtypes(BaseNumpyAppTest):
def test_str_unicode(self):
- from _numpypy import str_, unicode_, character, flexible, generic
+ from numpy import str_, unicode_, character, flexible, generic
assert str_.mro() == [str_, str, basestring, character, flexible, generic, object]
assert unicode_.mro() == [unicode_, unicode, basestring, character, flexible, generic, object]
def test_str_dtype(self):
- from _numpypy import dtype, str_
+ from numpy import dtype, str_
raises(TypeError, "dtype('Sx')")
d = dtype('S8')
@@ -536,7 +536,7 @@
assert d.num == 18
def test_unicode_dtype(self):
- from _numpypy import dtype, unicode_
+ from numpy import dtype, unicode_
raises(TypeError, "dtype('Ux')")
d = dtype('U8')
@@ -548,16 +548,16 @@
assert d.num == 19
def test_string_boxes(self):
- from _numpypy import str_
+ from numpy import str_
assert isinstance(str_(3), str_)
def test_unicode_boxes(self):
- from _numpypy import unicode_
+ from numpy import unicode_
assert isinstance(unicode_(3), unicode)
class AppTestRecordDtypes(BaseNumpyAppTest):
def test_create(self):
- from _numpypy import dtype, void
+ from numpy import dtype, void
raises(ValueError, "dtype([('x', int), ('x', float)])")
d = dtype([("x", "int32"), ("y", "int32"), ("z", "int32"), ("value", float)])
@@ -576,7 +576,7 @@
def test_create_from_dict(self):
skip("not yet")
- from _numpypy import dtype
+ from numpy import dtype
d = dtype({'names': ['a', 'b', 'c'],
})
@@ -597,7 +597,7 @@
py.test.skip("not a direct test")
def test_non_native(self):
- from _numpypy import array
+ from numpy import array
a = array([1, 2, 3], dtype=self.non_native_prefix + 'i2')
assert a[0] == 1
assert (a + a)[1] == 4
diff --git a/pypy/module/micronumpy/test/test_iter.py b/pypy/module/_numpypy/test/test_iter.py
rename from pypy/module/micronumpy/test/test_iter.py
rename to pypy/module/_numpypy/test/test_iter.py
--- a/pypy/module/micronumpy/test/test_iter.py
+++ b/pypy/module/_numpypy/test/test_iter.py
@@ -1,4 +1,4 @@
-from pypy.module.micronumpy.interp_iter import ViewIterator
+from pypy.module._numpypy.interp_iter import ViewIterator
class TestIterDirect(object):
def test_C_viewiterator(self):
diff --git a/pypy/module/micronumpy/test/test_module.py b/pypy/module/_numpypy/test/test_module.py
rename from pypy/module/micronumpy/test/test_module.py
rename to pypy/module/_numpypy/test/test_module.py
--- a/pypy/module/micronumpy/test/test_module.py
+++ b/pypy/module/_numpypy/test/test_module.py
@@ -1,23 +1,23 @@
-from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.module._numpypy.test.test_base import BaseNumpyAppTest
class AppTestNumPyModule(BaseNumpyAppTest):
def test_average(self):
- from _numpypy import array, average
+ from numpy import array, average
assert average(range(10)) == 4.5
assert average(array(range(10))) == 4.5
def test_sum(self):
- from _numpypy import array, sum
+ from numpy import array, sum
assert sum(range(10)) == 45
assert sum(array(range(10))) == 45
def test_min(self):
- from _numpypy import array, min
+ from numpy import array, min
assert min(range(10)) == 0
assert min(array(range(10))) == 0
def test_max(self):
- from _numpypy import array, max
+ from numpy import array, max
assert max(range(10)) == 9
assert max(array(range(10))) == 9
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/_numpypy/test/test_numarray.py
rename from pypy/module/micronumpy/test/test_numarray.py
rename to pypy/module/_numpypy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/_numpypy/test/test_numarray.py
@@ -3,10 +3,10 @@
from pypy.conftest import option
from pypy.interpreter.error import OperationError
-from pypy.module.micronumpy.appbridge import get_appbridge_cache
-from pypy.module.micronumpy.interp_iter import Chunk, Chunks
-#from pypy.module.micronumpy.interp_numarray import W_NDimArray, shape_agreement
-from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.module._numpypy.appbridge import get_appbridge_cache
+from pypy.module._numpypy.interp_iter import Chunk, Chunks
+#from pypy.module._numpypy.interp_numarray import W_NDimArray, shape_agreement
+from pypy.module._numpypy.test.test_base import BaseNumpyAppTest
class MockDtype(object):
class itemtype(object):
@@ -164,7 +164,7 @@
[5, 2], [4, 3, 5, 2]) == [4, 3, 5, 2]
def test_calc_new_strides(self):
- from pypy.module.micronumpy.interp_numarray import calc_new_strides
+ from pypy.module._numpypy.interp_numarray import calc_new_strides
assert calc_new_strides([2, 4], [4, 2], [4, 2], "C") == [8, 2]
assert calc_new_strides([2, 4, 3], [8, 3], [1, 16], 'F') == [1, 2, 16]
assert calc_new_strides([2, 3, 4], [8, 3], [1, 16], 'F') is None
@@ -179,7 +179,7 @@
[1, 1, 1, 105, 105]
def test_to_coords(self):
- from pypy.module.micronumpy.strides import to_coords
+ from pypy.module._numpypy.strides import to_coords
def _to_coords(index, order):
return to_coords(self.space, [2, 3, 4], 24, order,
@@ -228,7 +228,7 @@
return CustomIntObject(value)
def test_ndarray(self):
- from _numpypy import ndarray, array, dtype
+ from numpy import ndarray, array, dtype
assert type(ndarray) is type
assert type(array) is not type
@@ -243,24 +243,24 @@
assert a.dtype is dtype(int)
def test_ndmin(self):
- from _numpypy import array
+ from numpy import array
arr = array([[[1]]], ndmin=1)
assert arr.shape == (1, 1, 1)
def test_noop_ndmin(self):
- from _numpypy import array
+ from numpy import array
arr = array([1], ndmin=3)
assert arr.shape == (1, 1, 1)
def test_type(self):
- from _numpypy import array
+ from numpy import array
ar = array(range(5))
assert type(ar) is type(ar + ar)
def test_ndim(self):
- from _numpypy import array
+ from numpy import array
x = array(0.2)
assert x.ndim == 0
x = array([1, 2])
@@ -274,7 +274,7 @@
raises((AttributeError, TypeError), 'x.ndim = 3')
def test_init(self):
- from _numpypy import zeros
+ from numpy import zeros
a = zeros(15)
# Check that storage was actually zero'd.
assert a[10] == 0.0
@@ -284,7 +284,7 @@
assert zeros(()).shape == ()
def test_size(self):
- from _numpypy import array,arange,cos
+ from numpy import array,arange,cos
assert array(3).size == 1
a = array([1, 2, 3])
assert a.size == 3
@@ -297,13 +297,13 @@
Test that empty() works.
"""
- from _numpypy import empty
+ from numpy import empty
a = empty(2)
a[1] = 1.0
assert a[1] == 1.0
def test_ones(self):
- from _numpypy import ones
+ from numpy import ones
a = ones(3)
assert len(a) == 3
assert a[0] == 1
@@ -312,7 +312,7 @@
assert a[2] == 4
def test_copy(self):
- from _numpypy import arange, array
+ from numpy import arange, array
a = arange(5)
b = a.copy()
for i in xrange(5):
@@ -334,12 +334,12 @@
assert (b == a).all()
def test_iterator_init(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
assert a[3] == 3
def test_getitem(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
raises(IndexError, "a[5]")
a = a + a
@@ -348,7 +348,7 @@
raises(IndexError, "a[-6]")
def test_getitem_tuple(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
raises(IndexError, "a[(1,2)]")
for i in xrange(5):
@@ -358,20 +358,20 @@
assert a[i] == b[i]
def test_getitem_nd(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(15).reshape(3, 5)
assert a[1, 3] == 8
assert a.T[1, 2] == 11
def test_getitem_obj_index(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
assert a[self.CustomIndexObject(1)] == 1
def test_getitem_obj_prefer_index_to_int(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
@@ -379,14 +379,14 @@
assert a[self.CustomIndexIntObject(0, 1)] == 0
def test_getitem_obj_int(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
assert a[self.CustomIntObject(1)] == 1
def test_setitem(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
a[-1] = 5.0
assert a[4] == 5.0
@@ -394,7 +394,7 @@
raises(IndexError, "a[-6] = 3.0")
def test_setitem_tuple(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
raises(IndexError, "a[(1,2)] = [0,1]")
for i in xrange(5):
@@ -405,7 +405,7 @@
assert a[i] == i
def test_setitem_obj_index(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
@@ -413,7 +413,7 @@
assert a[1] == 100
def test_setitem_obj_prefer_index_to_int(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
@@ -421,7 +421,7 @@
assert a[0] == 100
def test_setitem_obj_int(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
@@ -441,13 +441,13 @@
# numpy will swallow errors in __int__ and __index__ and
# just raise IndexError.
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
raises(IndexError, "a[ErrorIndex()] == 0")
raises(IndexError, "a[ErrorInt()] == 0")
def test_setslice_array(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = array(range(2))
a[1:4:2] = b
@@ -458,7 +458,7 @@
assert b[1] == 0.
def test_setslice_of_slice_array(self):
- from _numpypy import array, zeros
+ from numpy import array, zeros
a = zeros(5)
a[::2] = array([9., 10., 11.])
assert a[0] == 9.
@@ -477,7 +477,7 @@
assert a[0] == 3.
def test_setslice_list(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5), float)
b = [0., 1.]
a[1:4:2] = b
@@ -485,7 +485,7 @@
assert a[3] == 1.
def test_setslice_constant(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5), float)
a[1:4:2] = 0.
assert a[1] == 0.
@@ -493,22 +493,20 @@
def test_newaxis(self):
import math
- from _numpypy import array, cos, zeros
- from numpypy.core.numeric import newaxis
+ from numpy import array, cos, zeros
a = array(range(5))
b = array([range(5)])
- assert (a[newaxis] == b).all()
+ assert (a[self.newaxis] == b).all()
a = array(range(3))
b = array([1, 3])
expected = zeros((3, 2))
for x in range(3):
for y in range(2):
expected[x, y] = math.cos(a[x]) * math.cos(b[y])
- assert ((cos(a)[:,newaxis] * cos(b).T) == expected).all()
+ assert ((cos(a)[:,self.newaxis] * cos(b).T) == expected).all()
def test_newaxis_slice(self):
- from _numpypy import array
- from numpypy.core.numeric import newaxis
+ from numpy import array
a = array(range(5))
b = array(range(1,5))
@@ -516,43 +514,39 @@
d = array([[x] for x in range(1,5)])
assert (a[1:] == b).all()
- assert (a[1:,newaxis] == d).all()
- assert (a[newaxis,1:] == c).all()
+ assert (a[1:,self.newaxis] == d).all()
+ assert (a[self.newaxis,1:] == c).all()
def test_newaxis_assign(self):
- from _numpypy import array
- from numpypy.core.numeric import newaxis
+ from numpy import array
a = array(range(5))
- a[newaxis,1] = [2]
+ a[self.newaxis,1] = [2]
assert a[1] == 2
def test_newaxis_virtual(self):
- from _numpypy import array
- from numpypy.core.numeric import newaxis
+ from numpy import array
a = array(range(5))
- b = (a + a)[newaxis]
+ b = (a + a)[self.newaxis]
c = array([[0, 2, 4, 6, 8]])
assert (b == c).all()
def test_newaxis_then_slice(self):
- from _numpypy import array
- from numpypy.core.numeric import newaxis
+ from numpy import array
a = array(range(5))
- b = a[newaxis]
+ b = a[self.newaxis]
assert b.shape == (1, 5)
assert (b[0,1:] == a[1:]).all()
def test_slice_then_newaxis(self):
- from _numpypy import array
- from numpypy.core.numeric import newaxis
+ from numpy import array
a = array(range(5))
b = a[2:]
- assert (b[newaxis] == [[2, 3, 4]]).all()
+ assert (b[self.newaxis] == [[2, 3, 4]]).all()
def test_scalar(self):
- from _numpypy import array, dtype
+ from numpy import array, dtype
a = array(3)
raises(IndexError, "a[0]")
raises(IndexError, "a[0] = 5")
@@ -561,13 +555,13 @@
assert a.dtype is dtype(int)
def test_len(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
assert len(a) == 5
assert len(a + a) == 5
def test_shape(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
assert a.shape == (5,)
b = a + a
@@ -577,7 +571,7 @@
assert array([]).shape == (0,)
def test_set_shape(self):
- from _numpypy import array, zeros
+ from numpy import array, zeros
a = array([])
raises(ValueError, "a.shape = []")
a = array(range(12))
@@ -599,7 +593,7 @@
raises(AttributeError, 'a.shape = 6')
def test_reshape(self):
- from _numpypy import array, zeros
+ from numpy import array, zeros
a = array(range(12))
exc = raises(ValueError, "b = a.reshape((3, 10))")
assert str(exc.value) == "total size of new array must be unchanged"
@@ -615,7 +609,7 @@
assert a.reshape((0,)).shape == (0,)
def test_slice_reshape(self):
- from _numpypy import zeros, arange
+ from numpy import zeros, arange
a = zeros((4, 2, 3))
b = a[::2, :, :]
b.shape = (2, 6)
@@ -651,20 +645,20 @@
raises(ValueError, arange(10).reshape, (5, -1, -1))
def test_reshape_varargs(self):
- from _numpypy import arange
+ from numpy import arange
z = arange(96).reshape(12, -1)
y = z.reshape(4, 3, 8)
assert y.shape == (4, 3, 8)
def test_scalar_reshape(self):
- from numpypy import array
+ from numpy import array
a = array(3)
assert a.reshape([1, 1]).shape == (1, 1)
assert a.reshape([1]).shape == (1,)
raises(ValueError, "a.reshape(3)")
def test_add(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a + a
for i in range(5):
@@ -677,7 +671,7 @@
assert c[i] == bool(a[i] + b[i])
def test_add_other(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = array([i for i in reversed(range(5))])
c = a + b
@@ -685,20 +679,20 @@
assert c[i] == 4
def test_add_constant(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a + 5
for i in range(5):
assert b[i] == i + 5
def test_radd(self):
- from _numpypy import array
+ from numpy import array
r = 3 + array(range(3))
for i in range(3):
assert r[i] == i + 3
def test_add_list(self):
- from _numpypy import array, ndarray
+ from numpy import array, ndarray
a = array(range(5))
b = list(reversed(range(5)))
c = a + b
@@ -707,14 +701,14 @@
assert c[i] == 4
def test_subtract(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a - a
for i in range(5):
assert b[i] == 0
def test_subtract_other(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = array([1, 1, 1, 1, 1])
c = a - b
@@ -722,35 +716,35 @@
assert c[i] == i - 1
def test_subtract_constant(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a - 5
for i in range(5):
assert b[i] == i - 5
def test_scalar_subtract(self):
- from _numpypy import int32
+ from numpy import int32
assert int32(2) - 1 == 1
assert 1 - int32(2) == -1
def test_mul(self):
- import _numpypy
+ import numpy
- a = _numpypy.array(range(5))
+ a = numpy.array(range(5))
b = a * a
for i in range(5):
assert b[i] == i * i
assert b.dtype is a.dtype
- a = _numpypy.array(range(5), dtype=bool)
+ a = numpy.array(range(5), dtype=bool)
b = a * a
- assert b.dtype is _numpypy.dtype(bool)
- assert b[0] is _numpypy.False_
+ assert b.dtype is numpy.dtype(bool)
+ assert b[0] is numpy.False_
for i in range(1, 5):
- assert b[i] is _numpypy.True_
+ assert b[i] is numpy.True_
def test_mul_constant(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a * 5
for i in range(5):
@@ -758,7 +752,7 @@
def test_div(self):
from math import isnan
- from _numpypy import array, dtype
+ from numpy import array, dtype
a = array(range(1, 6))
b = a / a
@@ -790,7 +784,7 @@
assert c[2] == float('-inf')
def test_div_other(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = array([2, 2, 2, 2, 2], float)
c = a / b
@@ -798,7 +792,7 @@
assert c[i] == i / 2.0
def test_div_constant(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a / 5.0
for i in range(5):
@@ -806,7 +800,7 @@
def test_floordiv(self):
from math import isnan
- from _numpypy import array, dtype
+ from numpy import array, dtype
a = array(range(1, 6))
b = a // a
@@ -836,47 +830,47 @@
assert c[2] == float('-inf')
def test_floordiv_other(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = array([2, 2, 2, 2, 2], float)
c = a // b
assert (c == [0, 0, 1, 1, 2]).all()
def test_rfloordiv(self):
- from _numpypy import array
+ from numpy import array
a = array(range(1, 6))
b = 3 // a
assert (b == [3, 1, 1, 0, 0]).all()
def test_floordiv_constant(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a // 2
assert (b == [0, 0, 1, 1, 2]).all()
def test_truediv(self):
from operator import truediv
- from _numpypy import arange
+ from numpy import arange
assert (truediv(arange(5), 2) == [0., .5, 1., 1.5, 2.]).all()
assert (truediv(2, arange(3)) == [float("inf"), 2., 1.]).all()
def test_divmod(self):
- from _numpypy import arange
+ from numpy import arange
a, b = divmod(arange(10), 3)
assert (a == [0, 0, 0, 1, 1, 1, 2, 2, 2, 3]).all()
assert (b == [0, 1, 2, 0, 1, 2, 0, 1, 2, 0]).all()
def test_rdivmod(self):
- from _numpypy import arange
+ from numpy import arange
a, b = divmod(3, arange(1, 5))
assert (a == [3, 1, 1, 0]).all()
assert (b == [0, 1, 0, 3]).all()
def test_lshift(self):
- from _numpypy import array
+ from numpy import array
a = array([0, 1, 2, 3])
assert (a << 2 == [0, 4, 8, 12]).all()
@@ -886,13 +880,13 @@
raises(TypeError, lambda: a << 2)
def test_rlshift(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(3)
assert (2 << a == [2, 4, 8]).all()
def test_rshift(self):
- from _numpypy import arange, array
+ from numpy import arange, array
a = arange(10)
assert (a >> 2 == [0, 0, 0, 0, 1, 1, 1, 1, 2, 2]).all()
@@ -902,13 +896,13 @@
raises(TypeError, lambda: a >> 1)
def test_rrshift(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(5)
assert (2 >> a == [2, 1, 0, 0, 0]).all()
def test_pow(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5), float)
b = a ** a
for i in range(5):
@@ -918,7 +912,7 @@
assert (a ** 2 == a * a).all()
def test_pow_other(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5), float)
b = array([2, 2, 2, 2, 2])
c = a ** b
@@ -926,14 +920,14 @@
assert c[i] == i ** 2
def test_pow_constant(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5), float)
b = a ** 2
for i in range(5):
assert b[i] == i ** 2
def test_mod(self):
- from _numpypy import array
+ from numpy import array
a = array(range(1, 6))
b = a % a
for i in range(5):
@@ -946,7 +940,7 @@
assert b[i] == 1
def test_mod_other(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = array([2, 2, 2, 2, 2])
c = a % b
@@ -954,38 +948,38 @@
assert c[i] == i % 2
def test_mod_constant(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a % 2
for i in range(5):
assert b[i] == i % 2
def test_rand(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(5)
assert (3 & a == [0, 1, 2, 3, 0]).all()
def test_ror(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(5)
assert (3 | a == [3, 3, 3, 3, 7]).all()
def test_xor(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(5)
assert (a ^ 3 == [3, 2, 1, 0, 7]).all()
def test_rxor(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(5)
assert (3 ^ a == [3, 2, 1, 0, 7]).all()
def test_pos(self):
- from _numpypy import array
+ from numpy import array
a = array([1., -2., 3., -4., -5.])
b = +a
for i in range(5):
@@ -996,7 +990,7 @@
assert a[i] == i
def test_neg(self):
- from _numpypy import array
+ from numpy import array
a = array([1., -2., 3., -4., -5.])
b = -a
for i in range(5):
@@ -1007,7 +1001,7 @@
assert a[i] == -i
def test_abs(self):
- from _numpypy import array
+ from numpy import array
a = array([1., -2., 3., -4., -5.])
b = abs(a)
for i in range(5):
@@ -1018,7 +1012,7 @@
assert a[i + 5] == abs(i)
def test_auto_force(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
b = a - 1
a[2] = 3
@@ -1032,7 +1026,7 @@
assert c[1] == 4
def test_getslice(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
s = a[1:5]
assert len(s) == 4
@@ -1046,7 +1040,7 @@
assert s[0] == 5
def test_getslice_step(self):
- from _numpypy import array
+ from numpy import array
a = array(range(10))
s = a[1:9:2]
assert len(s) == 4
@@ -1054,7 +1048,7 @@
assert s[i] == a[2 * i + 1]
def test_slice_update(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
s = a[0:3]
s[1] = 10
@@ -1064,7 +1058,7 @@
def test_slice_invaidate(self):
# check that slice shares invalidation list with
- from _numpypy import array
+ from numpy import array
a = array(range(5))
s = a[0:2]
b = array([10, 11])
@@ -1078,7 +1072,7 @@
assert d[1] == 12
def test_mean(self):
- from _numpypy import array, arange
+ from numpy import array, arange
a = array(range(5))
assert a.mean() == 2.0
assert a[:4].mean() == 1.5
@@ -1094,7 +1088,7 @@
raises(ValueError, a.mean, 3)
def test_sum(self):
- from _numpypy import array, ndarray
+ from numpy import array, ndarray
a = array(range(5))
assert a.sum() == 10
assert a[:4].sum() == 6
@@ -1110,7 +1104,7 @@
assert isinstance(b, ndarray)
def test_reduce_nd(self):
- from numpypy import arange, array, multiply
+ from numpy import arange, array, multiply
a = arange(15).reshape(5, 3)
assert a.sum() == 105
assert a.max() == 14
@@ -1140,8 +1134,8 @@
assert (array([[1,2],[3,4]]).prod(1) == [2, 12]).all()
def test_identity(self):
- from _numpypy import identity, array
- from _numpypy import int32, float64, dtype
+ from numpy import identity, array
+ from numpy import int32, float64, dtype
a = identity(0)
assert len(a) == 0
assert a.dtype == dtype('float64')
@@ -1160,32 +1154,32 @@
assert (d == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]).all()
def test_prod(self):
- from _numpypy import array
+ from numpy import array
a = array(range(1, 6))
assert a.prod() == 120.0
assert a[:4].prod() == 24.0
def test_max(self):
- from _numpypy import array
+ from numpy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
assert a.max() == 5.7
b = array([])
raises(ValueError, "b.max()")
def test_max_add(self):
- from _numpypy import array
+ from numpy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
assert (a + a).max() == 11.4
def test_min(self):
- from _numpypy import array
+ from numpy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
assert a.min() == -3.0
b = array([])
raises(ValueError, "b.min()")
def test_argmax(self):
- from _numpypy import array
+ from numpy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
r = a.argmax()
assert r == 2
@@ -1206,14 +1200,14 @@
assert a.argmax() == 2
def test_argmin(self):
- from _numpypy import array
+ from numpy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
assert a.argmin() == 3
b = array([])
raises(ValueError, "b.argmin()")
def test_all(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
assert a.all() == False
a[0] = 3.0
@@ -1222,7 +1216,7 @@
assert b.all() == True
def test_any(self):
- from _numpypy import array, zeros
+ from numpy import array, zeros
a = array(range(5))
assert a.any() == True
b = zeros(5)
@@ -1231,7 +1225,7 @@
assert c.any() == False
def test_dot(self):
- from _numpypy import array, dot, arange
+ from numpy import array, dot, arange
a = array(range(5))
assert dot(a, a) == 30.0
@@ -1262,7 +1256,7 @@
assert (dot([[1,2],[3,4]],[5,6]) == [17, 39]).all()
def test_dot_constant(self):
- from _numpypy import array, dot
+ from numpy import array, dot
a = array(range(5))
b = a.dot(2.5)
for i in xrange(5):
@@ -1273,7 +1267,7 @@
assert c == 12.0
def test_dtype_guessing(self):
- from _numpypy import array, dtype, float64, int8, bool_
+ from numpy import array, dtype, float64, int8, bool_
assert array([True]).dtype is dtype(bool)
assert array([True, False]).dtype is dtype(bool)
@@ -1290,7 +1284,7 @@
def test_comparison(self):
import operator
- from _numpypy import array, dtype
+ from numpy import array, dtype
a = array(range(5))
b = array(range(5), float)
@@ -1309,7 +1303,7 @@
assert c[i] == func(b[i], 3)
def test_nonzero(self):
- from _numpypy import array
+ from numpy import array
a = array([1, 2])
raises(ValueError, bool, a)
raises(ValueError, bool, a == a)
@@ -1319,7 +1313,7 @@
assert not bool(array([0]))
def test_slice_assignment(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
a[::-1] = a
assert (a == [4, 3, 2, 1, 0]).all()
@@ -1329,9 +1323,9 @@
assert (a == [8, 6, 4, 2, 0]).all()
def test_debug_repr(self):
- from _numpypy import zeros, sin
+ from numpy import zeros, sin
try:
- from _numpypy.pypy import debug_repr
+ from numpy.pypy import debug_repr
except ImportError:
skip("-A run unsupported")
a = zeros(1)
@@ -1347,9 +1341,9 @@
assert debug_repr(b) == 'Array'
def test_remove_invalidates(self):
- from _numpypy import array
+ from numpy import array
try:
- from _numpypy.pypy import remove_invalidates
+ from numpy.pypy import remove_invalidates
except ImportError:
skip("-A run unsupported")
a = array([1, 2, 3])
@@ -1359,7 +1353,7 @@
assert b[0] == 28
def test_virtual_views(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(15)
c = (a + a)
d = c[::2]
@@ -1377,7 +1371,7 @@
assert b[1] == 2
def test_tolist_scalar(self):
- from _numpypy import int32, bool_
+ from numpy import int32, bool_
x = int32(23)
assert x.tolist() == 23
assert type(x.tolist()) is int
@@ -1385,13 +1379,13 @@
assert y.tolist() is True
def test_tolist_zerodim(self):
- from _numpypy import array
+ from numpy import array
x = array(3)
assert x.tolist() == 3
assert type(x.tolist()) is int
def test_tolist_singledim(self):
- from _numpypy import array
+ from numpy import array
a = array(range(5))
assert a.tolist() == [0, 1, 2, 3, 4]
assert type(a.tolist()[0]) is int
@@ -1399,23 +1393,23 @@
assert b.tolist() == [0.2, 0.4, 0.6]
def test_tolist_multidim(self):
- from _numpypy import array
+ from numpy import array
a = array([[1, 2], [3, 4]])
assert a.tolist() == [[1, 2], [3, 4]]
def test_tolist_view(self):
- from _numpypy import array
+ from numpy import array
a = array([[1, 2], [3, 4]])
assert (a + a).tolist() == [[2, 4], [6, 8]]
def test_tolist_slice(self):
- from _numpypy import array
+ from numpy import array
a = array([[17.1, 27.2], [40.3, 50.3]])
assert a[:, 0].tolist() == [17.1, 40.3]
assert a[0].tolist() == [17.1, 27.2]
def test_var(self):
- from _numpypy import array, arange
+ from numpy import array, arange
a = array(range(10))
assert a.var() == 8.25
a = array([5.0])
@@ -1426,7 +1420,7 @@
assert (a.var(1) == [.25] * 5).all()
def test_concatenate(self):
- from numpypy import array, concatenate, dtype
+ from numpy import array, concatenate, dtype
a1 = array([0,1,2])
a2 = array([3,4,5])
a = concatenate((a1, a2))
@@ -1464,14 +1458,14 @@
assert (b == [2, 6, 10, 2, 6, 10]).all()
def test_std(self):
- from _numpypy import array
+ from numpy import array
a = array(range(10))
assert a.std() == 2.8722813232690143
a = array([5.0])
assert a.std() == 0.0
def test_flatten(self):
- from _numpypy import array
+ from numpy import array
assert array(3).flatten().shape == (1,)
a = array([[1, 2], [3, 4]])
@@ -1494,7 +1488,7 @@
assert (a.T.flatten() == [1, 3, 2, 4]).all()
def test_itemsize(self):
- from _numpypy import ones, dtype, array
+ from numpy import ones, dtype, array
for obj in [float, bool, int]:
assert ones(1, dtype=obj).itemsize == dtype(obj).itemsize
@@ -1503,7 +1497,7 @@
assert ones(1)[:].itemsize == 8
def test_nbytes(self):
- from _numpypy import array, ones
+ from numpy import array, ones
assert ones(1).nbytes == 8
assert ones((2, 2)).nbytes == 32
@@ -1512,7 +1506,7 @@
assert array(3.0).nbytes == 8
def test_repeat(self):
- from _numpypy import repeat, array
+ from numpy import repeat, array
assert (repeat([[1, 2], [3, 4]], 3) == [1, 1, 1, 2, 2, 2,
3, 3, 3, 4, 4, 4]).all()
assert (repeat([[1, 2], [3, 4]], 2, axis=0) == [[1, 2], [1, 2], [3, 4],
@@ -1523,7 +1517,7 @@
def test_swapaxes(self):
- from _numpypy import array
+ from numpy import array
# testcases from numpy docstring
x = array([[1, 2, 3]])
assert (x.swapaxes(0, 1) == array([[1], [2], [3]])).all()
@@ -1552,30 +1546,30 @@
[[ 8, 10, 12], [20, 22, 24]]])).all()
def test_filter_bug(self):
- from numpypy import array
+ from numpy import array
a = array([1.0,-1.0])
a[a<0] = -a[a<0]
assert (a == [1, 1]).all()
class AppTestMultiDim(BaseNumpyAppTest):
def test_init(self):
- import _numpypy
- a = _numpypy.zeros((2, 2))
+ import numpy
+ a = numpy.zeros((2, 2))
assert len(a) == 2
def test_shape(self):
- import _numpypy
- assert _numpypy.zeros(1).shape == (1,)
- assert _numpypy.zeros((2, 2)).shape == (2, 2)
- assert _numpypy.zeros((3, 1, 2)).shape == (3, 1, 2)
- assert _numpypy.array([[1], [2], [3]]).shape == (3, 1)
- assert len(_numpypy.zeros((3, 1, 2))) == 3
- raises(TypeError, len, _numpypy.zeros(()))
- raises(ValueError, _numpypy.array, [[1, 2], 3], dtype=float)
+ import numpy
+ assert numpy.zeros(1).shape == (1,)
+ assert numpy.zeros((2, 2)).shape == (2, 2)
+ assert numpy.zeros((3, 1, 2)).shape == (3, 1, 2)
+ assert numpy.array([[1], [2], [3]]).shape == (3, 1)
+ assert len(numpy.zeros((3, 1, 2))) == 3
+ raises(TypeError, len, numpy.zeros(()))
+ raises(ValueError, numpy.array, [[1, 2], 3], dtype=float)
def test_getsetitem(self):
- import _numpypy
- a = _numpypy.zeros((2, 3, 1))
+ import numpy
+ a = numpy.zeros((2, 3, 1))
raises(IndexError, a.__getitem__, (2, 0, 0))
raises(IndexError, a.__getitem__, (0, 3, 0))
raises(IndexError, a.__getitem__, (0, 0, 1))
@@ -1586,8 +1580,8 @@
assert a[1, -1, 0] == 3
def test_slices(self):
- import _numpypy
- a = _numpypy.zeros((4, 3, 2))
+ import numpy
+ a = numpy.zeros((4, 3, 2))
raises(IndexError, a.__getitem__, (4,))
raises(IndexError, a.__getitem__, (3, 3))
raises(IndexError, a.__getitem__, (slice(None), 3))
@@ -1620,39 +1614,39 @@
assert a[1][2][1] == 15
def test_setitem_slice(self):
- import _numpypy
- a = _numpypy.zeros((3, 4))
+ import numpy
+ a = numpy.zeros((3, 4))
a[1] = [1, 2, 3, 4]
assert a[1, 2] == 3
raises(TypeError, a[1].__setitem__, [1, 2, 3])
- a = _numpypy.array([[1, 2], [3, 4]])
+ a = numpy.array([[1, 2], [3, 4]])
assert (a == [[1, 2], [3, 4]]).all()
- a[1] = _numpypy.array([5, 6])
+ a[1] = numpy.array([5, 6])
assert (a == [[1, 2], [5, 6]]).all()
- a[:, 1] = _numpypy.array([8, 10])
+ a[:, 1] = numpy.array([8, 10])
assert (a == [[1, 8], [5, 10]]).all()
- a[0, :: -1] = _numpypy.array([11, 12])
+ a[0, :: -1] = numpy.array([11, 12])
assert (a == [[12, 11], [5, 10]]).all()
def test_ufunc(self):
- from _numpypy import array
+ from numpy import array
a = array([[1, 2], [3, 4], [5, 6]])
assert ((a + a) == \
array([[1 + 1, 2 + 2], [3 + 3, 4 + 4], [5 + 5, 6 + 6]])).all()
def test_getitem_add(self):
- from _numpypy import array
+ from numpy import array
a = array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])
assert (a + a)[1, 1] == 8
def test_ufunc_negative(self):
- from _numpypy import array, negative
+ from numpy import array, negative
a = array([[1, 2], [3, 4]])
b = negative(a + a)
assert (b == [[-2, -4], [-6, -8]]).all()
def test_getitem_3(self):
- from _numpypy import array
+ from numpy import array
a = array([[1, 2], [3, 4], [5, 6], [7, 8],
[9, 10], [11, 12], [13, 14]])
b = a[::2]
@@ -1661,12 +1655,12 @@
assert c[1][1] == 12
def test_multidim_ones(self):
- from _numpypy import ones
+ from numpy import ones
a = ones((1, 2, 3))
assert a[0, 1, 2] == 1.0
def test_multidim_setslice(self):
- from _numpypy import zeros, ones
+ from numpy import zeros, ones
a = zeros((3, 3))
b = ones((3, 3))
a[:, 1:3] = b[:, 1:3]
@@ -1677,21 +1671,21 @@
assert (a == [[1, 0, 1], [1, 0, 1], [1, 0, 1]]).all()
def test_broadcast_ufunc(self):
- from _numpypy import array
+ from numpy import array
a = array([[1, 2], [3, 4], [5, 6]])
b = array([5, 6])
c = ((a + b) == [[1 + 5, 2 + 6], [3 + 5, 4 + 6], [5 + 5, 6 + 6]])
assert c.all()
def test_broadcast_setslice(self):
- from _numpypy import zeros, ones
+ from numpy import zeros, ones
a = zeros((10, 10))
b = ones(10)
a[:, :] = b
assert a[3, 5] == 1
def test_broadcast_shape_agreement(self):
- from _numpypy import zeros, array
+ from numpy import zeros, array
a = zeros((3, 1, 3))
b = array(((10, 11, 12), (20, 21, 22), (30, 31, 32)))
c = ((a + b) == [b, b, b])
@@ -1705,7 +1699,7 @@
assert c.all()
def test_broadcast_scalar(self):
- from _numpypy import zeros
+ from numpy import zeros
a = zeros((4, 5), 'd')
a[:, 1] = 3
assert a[2, 1] == 3
@@ -1716,14 +1710,14 @@
assert a[3, 2] == 0
def test_broadcast_call2(self):
- from _numpypy import zeros, ones
+ from numpy import zeros, ones
a = zeros((4, 1, 5))
b = ones((4, 3, 5))
b[:] = (a + a)
assert (b == zeros((4, 3, 5))).all()
def test_broadcast_virtualview(self):
- from _numpypy import arange, zeros
+ from numpy import arange, zeros
a = arange(8).reshape([2, 2, 2])
b = (a + a)[1, 1]
c = zeros((2, 2, 2))
@@ -1731,19 +1725,19 @@
assert (c == [[[12, 14], [12, 14]], [[12, 14], [12, 14]]]).all()
def test_argmax(self):
- from _numpypy import array
+ from numpy import array
a = array([[1, 2], [3, 4], [5, 6]])
assert a.argmax() == 5
assert a[:2, ].argmax() == 3
def test_broadcast_wrong_shapes(self):
- from _numpypy import zeros
+ from numpy import zeros
a = zeros((4, 3, 2))
b = zeros((4, 2))
raises(ValueError, lambda: a + b)
def test_reduce(self):
- from _numpypy import array
+ from numpy import array
a = array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
assert a.sum() == (13 * 12) / 2
b = a[1:, 1::2]
@@ -1751,7 +1745,7 @@
assert c.sum() == (6 + 8 + 10 + 12) * 2
def test_transpose(self):
- from _numpypy import array
+ from numpy import array
a = array(((range(3), range(3, 6)),
(range(6, 9), range(9, 12)),
(range(12, 15), range(15, 18)),
@@ -1771,7 +1765,7 @@
assert (a.transpose() == b).all()
def test_flatiter(self):
- from _numpypy import array, flatiter, arange
+ from numpy import array, flatiter, arange
a = array([[10, 30], [40, 60]])
f_iter = a.flat
assert f_iter.next() == 10
@@ -1789,17 +1783,17 @@
assert a.flat.base is a
def test_flatiter_array_conv(self):
- from _numpypy import array, dot
+ from numpy import array, dot
a = array([1, 2, 3])
assert dot(a.flat, a.flat) == 14
def test_flatiter_varray(self):
- from _numpypy import ones
+ from numpy import ones
a = ones((2, 2))
assert list(((a + a).flat)) == [2, 2, 2, 2]
def test_flatiter_getitem(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
assert a.flat[3] == 3
assert a[2:].flat[3] == 5
@@ -1821,7 +1815,7 @@
assert b.coords == (0,0)
def test_flatiter_setitem(self):
- from _numpypy import arange, array
+ from numpy import arange, array
a = arange(12).reshape(3,4)
b = a.T.flat
b[6::2] = [-1, -2]
@@ -1836,7 +1830,7 @@
assert b[11] == -40
def test_flatiter_ops(self):
- from _numpypy import arange, array
+ from numpy import arange, array
a = arange(12).reshape(3,4)
b = a.T.flat
assert (b == [0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11]).all()
@@ -1850,12 +1844,12 @@
assert ((b > range(12)) == [False, True, True,False, True, True,
False, False, True, False, False, False]).all()
def test_flatiter_view(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10).reshape(5, 2)
assert (a[::2].flat == [0, 1, 4, 5, 8, 9]).all()
def test_flatiter_transpose(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10).reshape(2, 5).T
b = a.flat
assert (b[:5] == [0, 5, 1, 6, 2]).all()
@@ -1866,7 +1860,7 @@
assert b.coords == (1, 1)
def test_flatiter_len(self):
- from _numpypy import arange
+ from numpy import arange
assert len(arange(10).flat) == 10
assert len(arange(10).reshape(2, 5).flat) == 10
@@ -1874,13 +1868,13 @@
assert len((arange(2) + arange(2)).flat) == 2
def test_slice_copy(self):
- from _numpypy import zeros
+ from numpy import zeros
a = zeros((10, 10))
b = a[0].copy()
assert (b == zeros(10)).all()
def test_array_interface(self):
- from _numpypy import array
+ from numpy import array
a = array([1, 2, 3])
i = a.__array_interface__
assert isinstance(i['data'][0], int)
@@ -1890,7 +1884,7 @@
def test_array_indexing_one_elem(self):
skip("not yet")
- from _numpypy import array, arange
+ from numpy import array, arange
raises(IndexError, 'arange(3)[array([3.5])]')
a = arange(3)[array([1])]
assert a == 1
@@ -1901,7 +1895,7 @@
assert arange(3)[array(1)] == 1
def test_fill(self):
- from _numpypy import array
+ from numpy import array
a = array([1, 2, 3])
a.fill(10)
assert (a == [10, 10, 10]).all()
@@ -1921,7 +1915,7 @@
assert d == 100
def test_array_indexing_bool(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
assert (a[a > 3] == [4, 5, 6, 7, 8, 9]).all()
a = arange(10).reshape(5, 2)
@@ -1929,7 +1923,7 @@
assert (a[a & 1 == 1] == [1, 3, 5, 7, 9]).all()
def test_array_indexing_bool_setitem(self):
- from _numpypy import arange, array
+ from numpy import arange, array
a = arange(6)
a[a > 3] = 15
assert (a == [0, 1, 2, 3, 15, 15]).all()
@@ -1938,20 +1932,20 @@
assert (a == [[0, 8], [2, 9], [4, 10]]).all()
def test_array_indexing_bool_setitem_multidim(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10).reshape(5, 2)
a[a & 1 == 0] = 15
assert (a == [[15, 1], [15, 3], [15, 5], [15, 7], [15, 9]]).all()
def test_array_indexing_bool_setitem_2(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10).reshape(5, 2)
a = a[::2]
a[a & 1 == 0] = 15
assert (a == [[15, 1], [15, 5], [15, 9]]).all()
def test_copy_kwarg(self):
- from _numpypy import array
+ from numpy import array
x = array([1, 2, 3])
assert (array(x) == x).all()
assert array(x) is not x
@@ -1960,19 +1954,19 @@
def test_isna(self):
skip("unsupported one way or another")
- from _numpypy import isna, array
+ from numpy import isna, array
# XXX for now
assert not isna(3)
assert (isna(array([1, 2, 3, 4])) == [False, False, False, False]).all()
def test_ravel(self):
- from _numpypy import arange
+ from numpy import arange
assert (arange(3).ravel() == arange(3)).all()
assert (arange(6).reshape(2, 3).ravel() == arange(6)).all()
assert (arange(6).reshape(2, 3).T.ravel() == [0, 3, 1, 4, 2, 5]).all()
def test_take(self):
- from _numpypy import arange
+ from numpy import arange
assert (arange(10).take([1, 2, 1, 1]) == [1, 2, 1, 1]).all()
raises(IndexError, "arange(3).take([15])")
a = arange(6).reshape(2, 3)
@@ -1982,7 +1976,7 @@
assert (a[:,::2].take([3, 2, 1]) == [6, 4, 2]).all()
def test_compress(self):
- from _numpypy import arange
+ from numpy import arange
a = arange(10)
assert (a.compress([True, False, True]) == [0, 2]).all()
assert (a.compress([1, 0, 13]) == [0, 2]).all()
@@ -1992,7 +1986,7 @@
raises(IndexError, "a.compress([1] * 100)")
def test_item(self):
- from _numpypy import array
+ from numpy import array
assert array(3).item() == 3
assert type(array(3).item()) is int
assert type(array(True).item()) is bool
@@ -2020,7 +2014,7 @@
def test_fromstring(self):
import sys
- from _numpypy import fromstring, array, uint8, float32, int32
+ from numpy import fromstring, array, uint8, float32, int32
a = fromstring(self.data)
for i in range(4):
@@ -2086,7 +2080,7 @@
assert (u == [1, 0]).all()
def test_fromstring_types(self):
- from _numpypy import (fromstring, int8, int16, int32, int64, uint8,
+ from numpy import (fromstring, int8, int16, int32, int64, uint8,
uint16, uint32, float32, float64)
a = fromstring('\xFF', dtype=int8)
@@ -2111,7 +2105,7 @@
assert j[0] == 12
def test_fromstring_invalid(self):
- from _numpypy import fromstring, uint16, uint8, int32
+ from numpy import fromstring, uint16, uint8, int32
#default dtype is 64-bit float, so 3 bytes should fail
raises(ValueError, fromstring, "\x01\x02\x03")
#3 bytes is not modulo 2 bytes (int16)
@@ -2120,7 +2114,7 @@
raises(ValueError, fromstring, "\x01\x02\x03", count=5, dtype=uint8)
def test_tostring(self):
- from _numpypy import array
+ from numpy import array
assert array([1, 2, 3], 'i2').tostring() == '\x01\x00\x02\x00\x03\x00'
assert array([1, 2, 3], 'i2')[::2].tostring() == '\x01\x00\x03\x00'
assert array([1, 2, 3], '<i2')[::2].tostring() == '\x01\x00\x03\x00'
@@ -2128,7 +2122,7 @@
class AppTestRanges(BaseNumpyAppTest):
def test_arange(self):
- from _numpypy import arange, array, dtype
+ from numpy import arange, array, dtype
a = arange(3)
assert (a == [0, 1, 2]).all()
assert a.dtype is dtype(int)
@@ -2160,7 +2154,7 @@
cache.w_array_repr = None
def test_repr_str(self):
- from _numpypy import array
+ from numpy import array
assert repr(array([1, 2, 3])) == 'array([1, 2, 3])'
assert str(array([1, 2, 3])) == 'array([1, 2, 3])'
@@ -2173,7 +2167,7 @@
class AppTestRecordDtype(BaseNumpyAppTest):
def test_zeros(self):
- from _numpypy import zeros
+ from numpy import zeros
a = zeros(2, dtype=[('x', int), ('y', float)])
raises(IndexError, 'a[0]["xyz"]')
assert a[0]['x'] == 0
@@ -2188,7 +2182,7 @@
assert a[1]['y'] == 2
def test_views(self):
- from _numpypy import array
+ from numpy import array
a = array([(1, 2), (3, 4)], dtype=[('x', int), ('y', float)])
raises(ValueError, 'array([1])["x"]')
raises(ValueError, 'a["z"]')
@@ -2201,19 +2195,19 @@
assert b.dtype == float
def test_assign_tuple(self):
- from _numpypy import zeros
+ from numpy import zeros
a = zeros((2, 3), dtype=[('x', int), ('y', float)])
a[1, 2] = (1, 2)
assert a['x'][1, 2] == 1
assert a['y'][1, 2] == 2
def test_creation_and_repr(self):
- from _numpypy import array
+ from numpy import array
a = array([(1, 2), (3, 4)], dtype=[('x', int), ('y', float)])
assert repr(a[0]) == '(1, 2.0)'
def test_nested_dtype(self):
- from _numpypy import zeros
+ from numpy import zeros
a = [('x', int), ('y', float)]
b = [('x', int), ('y', a)]
arr = zeros(3, dtype=b)
@@ -2232,19 +2226,19 @@
py.test.skip("not a direct test")
def test_init_2(self):
- import _numpypy
- raises(ValueError, _numpypy.array, [[1], 2])
- raises(ValueError, _numpypy.array, [[1, 2], [3]])
- raises(ValueError, _numpypy.array, [[[1, 2], [3, 4], 5]])
- raises(ValueError, _numpypy.array, [[[1, 2], [3, 4], [5]]])
- a = _numpypy.array([[1, 2], [4, 5]])
+ import numpy
+ raises(ValueError, numpy.array, [[1], 2])
+ raises(ValueError, numpy.array, [[1, 2], [3]])
+ raises(ValueError, numpy.array, [[[1, 2], [3, 4], 5]])
+ raises(ValueError, numpy.array, [[[1, 2], [3, 4], [5]]])
+ a = numpy.array([[1, 2], [4, 5]])
assert a[0, 1] == 2
assert a[0][1] == 2
- a = _numpypy.array(([[[1, 2], [3, 4], [5, 6]]]))
+ a = numpy.array(([[[1, 2], [3, 4], [5, 6]]]))
assert (a[0, 1] == [3, 4]).all()
def test_broadcast_wrong_shapes(self):
- from _numpypy import zeros
+ from numpy import zeros
a = zeros((4, 3, 2))
b = zeros((4, 2))
exc = raises(ValueError, lambda: a + b)
diff --git a/pypy/module/micronumpy/test/test_outarg.py b/pypy/module/_numpypy/test/test_outarg.py
rename from pypy/module/micronumpy/test/test_outarg.py
rename to pypy/module/_numpypy/test/test_outarg.py
--- a/pypy/module/micronumpy/test/test_outarg.py
+++ b/pypy/module/_numpypy/test/test_outarg.py
@@ -1,9 +1,9 @@
import py
-from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.module._numpypy.test.test_base import BaseNumpyAppTest
class AppTestOutArg(BaseNumpyAppTest):
def test_reduce_out(self):
- from numpypy import arange, zeros, array
+ from numpy import arange, zeros, array
a = arange(15).reshape(5, 3)
b = arange(12).reshape(4,3)
c = a.sum(0, out=b[1])
@@ -25,14 +25,14 @@
assert (c == [True, True]).all()
def test_reduce_intermediary(self):
- from numpypy import arange, array
+ from numpy import arange, array
a = arange(15).reshape(5, 3)
b = array(range(3), dtype=bool)
c = a.prod(0, out=b)
assert(b == [False, True, True]).all()
def test_ufunc_out(self):
- from _numpypy import array, negative, zeros, sin
+ from numpy import array, negative, zeros, sin
from math import sin as msin
a = array([[1, 2], [3, 4]])
c = zeros((2,2,2))
@@ -61,7 +61,7 @@
raises(ValueError, 'negative(a, out=b)')
def test_binfunc_out(self):
- from _numpypy import array, add
+ from numpy import array, add
a = array([[1, 2], [3, 4]])
out = array([[1, 2], [3, 4]])
c = add(a, a, out=out)
@@ -85,7 +85,7 @@
assert b.dtype == out.dtype
def test_applevel(self):
- from _numpypy import array, sum, max, min
+ from numpy import array, sum, max, min
a = array([[1, 2], [3, 4]])
out = array([[0, 0], [0, 0]])
c = sum(a, axis=0, out=out[0])
@@ -98,7 +98,7 @@
assert (c != out[1]).all()
def test_ufunc_cast(self):
- from _numpypy import array, negative, add, sum
+ from numpy import array, negative, add, sum
a = array(16, dtype = int)
c = array(0, dtype = float)
b = negative(a, out=c)
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/_numpypy/test/test_ufuncs.py
rename from pypy/module/micronumpy/test/test_ufuncs.py
rename to pypy/module/_numpypy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/_numpypy/test/test_ufuncs.py
@@ -1,16 +1,16 @@
-from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.module._numpypy.test.test_base import BaseNumpyAppTest
class AppTestUfuncs(BaseNumpyAppTest):
def test_ufunc_instance(self):
- from _numpypy import add, ufunc
+ from numpy import add, ufunc
assert isinstance(add, ufunc)
assert repr(add) == "<ufunc 'add'>"
assert 'py.ufunc' in repr(ufunc)
def test_ufunc_attrs(self):
- from _numpypy import add, multiply, sin
+ from numpy import add, multiply, sin
assert add.identity == 0
assert multiply.identity == 1
@@ -21,7 +21,7 @@
assert sin.nin == 1
def test_wrong_arguments(self):
- from _numpypy import add, sin
+ from numpy import add, sin
raises(ValueError, add, 1)
raises(TypeError, add, 1, 2, 3)
@@ -29,14 +29,14 @@
raises(ValueError, sin)
def test_single_item(self):
- from _numpypy import negative, sign, minimum
+ from numpy import negative, sign, minimum
assert negative(5.0) == -5.0
assert sign(-0.0) == 0.0
assert minimum(2.0, 3.0) == 2.0
def test_sequence(self):
- from _numpypy import array, ndarray, negative, minimum
+ from numpy import array, ndarray, negative, minimum
a = array(range(3))
b = [2.0, 1.0, 0.0]
c = 1.0
@@ -70,7 +70,7 @@
assert min_c_b[i] == min(b[i], c)
def test_negative(self):
- from _numpypy import array, negative
+ from numpy import array, negative
a = array([-5.0, 0.0, 1.0])
b = negative(a)
@@ -85,7 +85,7 @@
assert negative(a + a)[3] == -6
def test_abs(self):
- from _numpypy import array, absolute
+ from numpy import array, absolute
a = array([-5.0, -0.0, 1.0])
b = absolute(a)
@@ -93,7 +93,7 @@
assert b[i] == abs(a[i])
def test_add(self):
- from _numpypy import array, add
+ from numpy import array, add
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -102,7 +102,7 @@
assert c[i] == a[i] + b[i]
def test_divide(self):
- from _numpypy import array, divide
+ from numpy import array, divide
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -114,7 +114,7 @@
def test_true_divide(self):
import math
- from _numpypy import array, true_divide
+ from numpy import array, true_divide
a = array([0, 1, 2, 3, 4, 1, -1])
b = array([4, 4, 4, 4, 4, 0, 0])
@@ -124,7 +124,7 @@
assert math.isnan(true_divide(0, 0))
def test_fabs(self):
- from _numpypy import array, fabs
+ from numpy import array, fabs
from math import fabs as math_fabs, isnan
a = array([-5.0, -0.0, 1.0])
@@ -136,7 +136,7 @@
assert isnan(fabs(float('nan')))
def test_fmax(self):
- from _numpypy import fmax
+ from numpy import fmax
import math
nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), float('-inf')
@@ -156,7 +156,7 @@
def test_fmin(self):
- from _numpypy import fmin
+ from numpy import fmin
import math
nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), float('-inf')
@@ -174,7 +174,7 @@
assert math.copysign(1., fmin(nnan, nan)) == math.copysign(1., nnan)
def test_fmod(self):
- from _numpypy import fmod
+ from numpy import fmod
import math
assert fmod(-1e-100, 1e100) == -1e-100
@@ -184,7 +184,7 @@
assert math.isnan(fmod(v, 2))
def test_minimum(self):
- from _numpypy import array, minimum
+ from numpy import array, minimum
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -193,7 +193,7 @@
assert c[i] == min(a[i], b[i])
def test_maximum(self):
- from _numpypy import array, maximum
+ from numpy import array, maximum
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -206,7 +206,7 @@
assert isinstance(x, (int, long))
def test_multiply(self):
- from _numpypy import array, multiply
+ from numpy import array, multiply
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -215,7 +215,7 @@
assert c[i] == a[i] * b[i]
def test_sign(self):
- from _numpypy import array, sign, dtype
+ from numpy import array, sign, dtype
reference = [-1.0, 0.0, 0.0, 1.0]
a = array([-5.0, -0.0, 0.0, 6.0])
@@ -229,7 +229,7 @@
assert a[i] == ref[i]
def test_signbit(self):
- from _numpypy import signbit
+ from numpy import signbit
assert (signbit([0, 0.0, 1, 1.0, float('inf')]) ==
[False, False, False, False, False]).all()
@@ -240,7 +240,7 @@
[False, True, True]).all()
def test_reciporocal(self):
- from _numpypy import array, reciprocal
+ from numpy import array, reciprocal
reference = [-0.2, float("inf"), float("-inf"), 2.0]
a = array([-5.0, 0.0, -0.0, 0.5])
@@ -249,7 +249,7 @@
assert b[i] == reference[i]
def test_subtract(self):
- from _numpypy import array, subtract
+ from numpy import array, subtract
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -258,7 +258,7 @@
assert c[i] == a[i] - b[i]
def test_floorceiltrunc(self):
- from _numpypy import array, floor, ceil, trunc
+ from numpy import array, floor, ceil, trunc
import math
ninf, inf = float("-inf"), float("inf")
a = array([ninf, -1.4, -1.5, -1.0, 0.0, 1.0, 1.4, 0.5, inf])
@@ -270,7 +270,7 @@
assert all([math.copysign(1, f(-abs(float("nan")))) == -1 for f in floor, ceil, trunc])
def test_copysign(self):
- from _numpypy import array, copysign
+ from numpy import array, copysign
reference = [5.0, -0.0, 0.0, -6.0]
a = array([-5.0, 0.0, 0.0, 6.0])
@@ -286,7 +286,7 @@
def test_exp(self):
import math
- from _numpypy import array, exp
+ from numpy import array, exp
a = array([-5.0, -0.0, 0.0, 12345678.0, float("inf"),
-float('inf'), -12343424.0])
@@ -300,7 +300,7 @@
def test_exp2(self):
import math
- from _numpypy import array, exp2
+ from numpy import array, exp2
a = array([-5.0, -0.0, 0.0, 2, 12345678.0, float("inf"),
-float('inf'), -12343424.0])
@@ -317,7 +317,7 @@
def test_expm1(self):
import math
- from _numpypy import array, expm1
+ from numpy import array, expm1
a = array([-5.0, -0.0, 0.0, 12345678.0, float("inf"),
-float('inf'), -12343424.0])
@@ -333,7 +333,7 @@
def test_sin(self):
import math
- from _numpypy import array, sin
+ from numpy import array, sin
a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
b = sin(a)
@@ -346,7 +346,7 @@
def test_cos(self):
import math
- from _numpypy import array, cos
+ from numpy import array, cos
a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
b = cos(a)
@@ -355,7 +355,7 @@
def test_tan(self):
import math
- from _numpypy import array, tan
+ from numpy import array, tan
a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
b = tan(a)
@@ -364,7 +364,7 @@
def test_arcsin(self):
import math
- from _numpypy import array, arcsin
+ from numpy import array, arcsin
a = array([-1, -0.5, -0.33, 0, 0.33, 0.5, 1])
b = arcsin(a)
@@ -378,7 +378,7 @@
def test_arccos(self):
import math
- from _numpypy import array, arccos
+ from numpy import array, arccos
a = array([-1, -0.5, -0.33, 0, 0.33, 0.5, 1])
b = arccos(a)
@@ -392,7 +392,7 @@
def test_arctan(self):
import math
- from _numpypy import array, arctan
+ from numpy import array, arctan
a = array([-3, -2, -1, 0, 1, 2, 3, float('inf'), float('-inf')])
b = arctan(a)
@@ -405,7 +405,7 @@
def test_arctan2(self):
import math
- from _numpypy import array, arctan2
+ from numpy import array, arctan2
# From the numpy documentation
assert (
@@ -420,7 +420,7 @@
def test_sinh(self):
import math
- from _numpypy import array, sinh
+ from numpy import array, sinh
a = array([-1, 0, 1, float('inf'), float('-inf')])
b = sinh(a)
@@ -429,7 +429,7 @@
def test_cosh(self):
import math
- from _numpypy import array, cosh
+ from numpy import array, cosh
a = array([-1, 0, 1, float('inf'), float('-inf')])
b = cosh(a)
@@ -438,7 +438,7 @@
def test_tanh(self):
import math
- from _numpypy import array, tanh
+ from numpy import array, tanh
a = array([-1, 0, 1, float('inf'), float('-inf')])
b = tanh(a)
@@ -447,7 +447,7 @@
def test_arcsinh(self):
import math
- from _numpypy import arcsinh
+ from numpy import arcsinh
for v in [float('inf'), float('-inf'), 1.0, math.e]:
assert math.asinh(v) == arcsinh(v)
@@ -455,7 +455,7 @@
def test_arccosh(self):
import math
- from _numpypy import arccosh
+ from numpy import arccosh
for v in [1.0, 1.1, 2]:
assert math.acosh(v) == arccosh(v)
@@ -464,7 +464,7 @@
def test_arctanh(self):
import math
- from _numpypy import arctanh
+ from numpy import arctanh
for v in [.99, .5, 0, -.5, -.99]:
assert math.atanh(v) == arctanh(v)
@@ -475,7 +475,7 @@
def test_sqrt(self):
import math
- from _numpypy import sqrt
+ from numpy import sqrt
nan, inf = float("nan"), float("inf")
data = [1, 2, 3, inf]
@@ -486,7 +486,7 @@
def test_square(self):
import math
- from _numpypy import square
+ from numpy import square
nan, inf, ninf = float("nan"), float("inf"), float("-inf")
@@ -499,7 +499,7 @@
def test_radians(self):
import math
- from _numpypy import radians, array
+ from numpy import radians, array
a = array([
-181, -180, -179,
181, 180, 179,
@@ -512,7 +512,7 @@
def test_deg2rad(self):
import math
- from _numpypy import deg2rad, array
+ from numpy import deg2rad, array
a = array([
-181, -180, -179,
181, 180, 179,
@@ -525,7 +525,7 @@
def test_degrees(self):
import math
- from _numpypy import degrees, array
+ from numpy import degrees, array
a = array([
-181, -180, -179,
181, 180, 179,
@@ -538,7 +538,7 @@
def test_rad2deg(self):
import math
- from _numpypy import rad2deg, array
+ from numpy import rad2deg, array
a = array([
-181, -180, -179,
181, 180, 179,
@@ -550,13 +550,13 @@
assert b[i] == math.degrees(a[i])
def test_reduce_errors(self):
- from _numpypy import sin, add
+ from numpy import sin, add
raises(ValueError, sin.reduce, [1, 2, 3])
assert add.reduce(1) == 1
def test_reduce_1d(self):
- from _numpypy import add, maximum, less
+ from numpy import add, maximum, less
assert less.reduce([5, 4, 3, 2, 1])
assert add.reduce([1, 2, 3]) == 6
@@ -565,21 +565,21 @@
raises(ValueError, maximum.reduce, [])
def test_reduceND(self):
- from _numpypy import add, arange
+ from numpy import add, arange
a = arange(12).reshape(3, 4)
assert (add.reduce(a, 0) == [12, 15, 18, 21]).all()
assert (add.reduce(a, 1) == [6.0, 22.0, 38.0]).all()
raises(ValueError, add.reduce, a, 2)
def test_reduce_keepdims(self):
- from _numpypy import add, arange
+ from numpy import add, arange
a = arange(12).reshape(3, 4)
b = add.reduce(a, 0, keepdims=True)
assert b.shape == (1, 4)
assert (add.reduce(a, 0, keepdims=True) == [12, 15, 18, 21]).all()
def test_bitwise(self):
- from _numpypy import bitwise_and, bitwise_or, bitwise_xor, arange, array
+ from numpy import bitwise_and, bitwise_or, bitwise_xor, arange, array
a = arange(6).reshape(2, 3)
assert (a & 1 == [[0, 1, 0], [1, 0, 1]]).all()
assert (a & 1 == bitwise_and(a, 1)).all()
@@ -589,21 +589,21 @@
raises(TypeError, 'array([1.0]) & 1')
def test_unary_bitops(self):
- from _numpypy import bitwise_not, invert, array
+ from numpy import bitwise_not, invert, array
a = array([1, 2, 3, 4])
assert (~a == [-2, -3, -4, -5]).all()
assert (bitwise_not(a) == ~a).all()
assert (invert(a) == ~a).all()
def test_shift(self):
- from _numpypy import left_shift, right_shift
+ from numpy import left_shift, right_shift
assert (left_shift([5, 1], [2, 13]) == [20, 2**13]).all()
assert (right_shift(10, range(5)) == [10, 5, 2, 1, 0]).all()
def test_comparisons(self):
import operator
- from _numpypy import equal, not_equal, less, less_equal, greater, greater_equal
+ from numpy import equal, not_equal, less, less_equal, greater, greater_equal
for ufunc, func in [
(equal, operator.eq),
@@ -628,11 +628,11 @@
assert ufunc(a, b) == func(a, b)
def test_true_divide_2(self):
- from _numpypy import arange, array, true_divide
+ from numpy import arange, array, true_divide
assert (true_divide(arange(3), array([2, 2, 2])) == array([0, 0.5, 1])).all()
def test_isnan_isinf(self):
- from _numpypy import isnan, isinf, float64, array
+ from numpy import isnan, isinf, float64, array
assert isnan(float('nan'))
assert isnan(float64(float('nan')))
assert not isnan(3)
@@ -646,7 +646,7 @@
assert isinf(array([0.2])).dtype.kind == 'b'
def test_isposinf_isneginf(self):
- from _numpypy import isneginf, isposinf
+ from numpy import isneginf, isposinf
assert isposinf(float('inf'))
assert not isposinf(float('-inf'))
assert not isposinf(float('nan'))
@@ -659,14 +659,14 @@
assert not isneginf(0.0)
def test_isfinite(self):
- from _numpypy import isfinite
+ from numpy import isfinite
assert (isfinite([0, 0.0, 1e50, -1e-50]) ==
[True, True, True, True]).all()
assert (isfinite([float('-inf'), float('inf'), float('-nan'), float('nan')]) ==
[False, False, False, False]).all()
def test_logical_ops(self):
- from _numpypy import logical_and, logical_or, logical_xor, logical_not
+ from numpy import logical_and, logical_or, logical_xor, logical_not
assert (logical_and([True, False , True, True], [1, 1, 3, 0])
== [True, False, True, False]).all()
@@ -678,7 +678,7 @@
def test_logn(self):
import math
- from _numpypy import log, log2, log10
+ from numpy import log, log2, log10
for log_func, base in [(log, math.e), (log2, 2), (log10, 10)]:
for v in [float('-nan'), float('-inf'), -1, float('nan')]:
@@ -690,7 +690,7 @@
def test_log1p(self):
import math
- from _numpypy import log1p
+ from numpy import log1p
for v in [float('-nan'), float('-inf'), -2, float('nan')]:
assert math.isnan(log1p(v))
@@ -701,7 +701,7 @@
def test_power_float(self):
import math
- from _numpypy import power, array
+ from numpy import power, array
a = array([1., 2., 3.])
b = power(a, 3)
for i in range(len(a)):
@@ -729,7 +729,7 @@
def test_power_int(self):
import math
- from _numpypy import power, array
+ from numpy import power, array
a = array([1, 2, 3])
b = power(a, 3)
for i in range(len(a)):
@@ -752,7 +752,7 @@
assert power(12345, -12345) == 0
def test_floordiv(self):
- from _numpypy import floor_divide, array
+ from numpy import floor_divide, array
a = array([1., 2., 3., 4., 5., 6., 6.01])
b = floor_divide(a, 2.5)
for i in range(len(a)):
@@ -762,7 +762,7 @@
import math
import sys
float_max, float_min = sys.float_info.max, sys.float_info.min
- from _numpypy import logaddexp
+ from numpy import logaddexp
# From the numpy documentation
prob1 = math.log(1e-50)
@@ -788,7 +788,7 @@
import math
import sys
float_max, float_min = sys.float_info.max, sys.float_info.min
- from _numpypy import logaddexp2
+ from numpy import logaddexp2
log2 = math.log(2)
# From the numpy documentation
diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/_numpypy/test/test_zjit.py
rename from pypy/module/micronumpy/test/test_zjit.py
rename to pypy/module/_numpypy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/_numpypy/test/test_zjit.py
@@ -9,10 +9,10 @@
from pypy.jit.metainterp import pyjitpl
from pypy.jit.metainterp.test.support import LLJitMixin
from pypy.jit.metainterp.warmspot import reset_stats
-from pypy.module.micronumpy import interp_boxes
-from pypy.module.micronumpy.compile import (FakeSpace,
+from pypy.module._numpypy import interp_boxes
+from pypy.module._numpypy.compile import (FakeSpace,
IntObject, Parser, InterpreterState)
-from pypy.module.micronumpy.interp_numarray import (W_NDimArray,
+from pypy.module._numpypy.interp_numarray import (W_NDimArray,
BaseArray, W_FlatIterator)
from pypy.rlib.nonconst import NonConstant
diff --git a/pypy/module/micronumpy/test/test_ztranslation.py b/pypy/module/_numpypy/test/test_ztranslation.py
rename from pypy/module/micronumpy/test/test_ztranslation.py
rename to pypy/module/_numpypy/test/test_ztranslation.py
--- a/pypy/module/micronumpy/test/test_ztranslation.py
+++ b/pypy/module/_numpypy/test/test_ztranslation.py
@@ -1,8 +1,8 @@
-from pypy.module.micronumpy import signature
+from pypy.module._numpypy import signature
from pypy.objspace.fake.checkmodule import checkmodule
def test_numpy_translates():
# XXX: If there are signatures floating around this might explode. This fix
# is ugly.
signature.known_sigs.clear()
- checkmodule('micronumpy')
+ checkmodule('_numpypy')
diff --git a/pypy/module/micronumpy/tool/numready/__init__.py b/pypy/module/_numpypy/tool/numready/__init__.py
rename from pypy/module/micronumpy/tool/numready/__init__.py
rename to pypy/module/_numpypy/tool/numready/__init__.py
diff --git a/pypy/module/micronumpy/tool/numready/__main__.py b/pypy/module/_numpypy/tool/numready/__main__.py
rename from pypy/module/micronumpy/tool/numready/__main__.py
rename to pypy/module/_numpypy/tool/numready/__main__.py
diff --git a/pypy/module/micronumpy/tool/numready/kinds.py b/pypy/module/_numpypy/tool/numready/kinds.py
rename from pypy/module/micronumpy/tool/numready/kinds.py
rename to pypy/module/_numpypy/tool/numready/kinds.py
diff --git a/pypy/module/micronumpy/tool/numready/main.py b/pypy/module/_numpypy/tool/numready/main.py
rename from pypy/module/micronumpy/tool/numready/main.py
rename to pypy/module/_numpypy/tool/numready/main.py
diff --git a/pypy/module/micronumpy/tool/numready/page.html b/pypy/module/_numpypy/tool/numready/page.html
rename from pypy/module/micronumpy/tool/numready/page.html
rename to pypy/module/_numpypy/tool/numready/page.html
diff --git a/pypy/module/micronumpy/tool/numready/search.py b/pypy/module/_numpypy/tool/numready/search.py
rename from pypy/module/micronumpy/tool/numready/search.py
rename to pypy/module/_numpypy/tool/numready/search.py
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/_numpypy/types.py
rename from pypy/module/micronumpy/types.py
rename to pypy/module/_numpypy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/_numpypy/types.py
@@ -3,7 +3,7 @@
import struct
from pypy.interpreter.error import OperationError
-from pypy.module.micronumpy import interp_boxes
+from pypy.module._numpypy import interp_boxes
from pypy.objspace.std.floatobject import float2string
from pypy.rlib import rfloat, libffi, clibffi
from pypy.rlib.objectmodel import specialize, we_are_translated
@@ -959,7 +959,7 @@
@jit.unroll_safe
def coerce(self, space, dtype, w_item):
- from pypy.module.micronumpy.interp_numarray import W_NDimArray
+ from pypy.module._numpypy.interp_numarray import W_NDimArray
if isinstance(w_item, interp_boxes.W_VoidBox):
return w_item
diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py
--- a/pypy/module/pypyjit/policy.py
+++ b/pypy/module/pypyjit/policy.py
@@ -123,7 +123,7 @@
modname, rest = modname.split('.', 1)
else:
rest = ''
- if modname in ['pypyjit', 'signal', 'micronumpy', 'math', 'exceptions',
+ if modname in ['pypyjit', 'signal', '_numpypy', 'math', 'exceptions',
'imp', 'sys', 'array', '_ffi', 'itertools', 'operator',
'posix', '_socket', '_sre', '_lsprof', '_weakref',
'__pypy__', 'cStringIO', '_collections', 'struct',
diff --git a/pypy/module/pypyjit/test/test_policy.py b/pypy/module/pypyjit/test/test_policy.py
--- a/pypy/module/pypyjit/test/test_policy.py
+++ b/pypy/module/pypyjit/test/test_policy.py
@@ -47,7 +47,7 @@
assert pypypolicy.look_inside_pypy_module('__builtin__.functional')
assert pypypolicy.look_inside_pypy_module('__builtin__.descriptor')
assert pypypolicy.look_inside_pypy_module('exceptions.interp_exceptions')
- for modname in 'pypyjit', 'signal', 'micronumpy', 'math', 'imp':
+ for modname in 'pypyjit', 'signal', '_numpypy', 'math', 'imp':
assert pypypolicy.look_inside_pypy_module(modname)
assert pypypolicy.look_inside_pypy_module(modname + '.foo')
assert not pypypolicy.look_inside_pypy_module('pypyjit.interp_resop')
diff --git a/pypy/module/test_lib_pypy/numpypy/core/test_fromnumeric.py b/pypy/module/test_lib_pypy/numpypy/core/test_fromnumeric.py
--- a/pypy/module/test_lib_pypy/numpypy/core/test_fromnumeric.py
+++ b/pypy/module/test_lib_pypy/numpypy/core/test_fromnumeric.py
@@ -1,4 +1,4 @@
-from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.module._numpypy.test.test_base import BaseNumpyAppTest
class AppTestFromNumeric(BaseNumpyAppTest):
diff --git a/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py b/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py
--- a/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py
+++ b/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py
@@ -1,5 +1,5 @@
-from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.module._numpypy.test.test_base import BaseNumpyAppTest
class AppTestBaseRepr(BaseNumpyAppTest):
diff --git a/pypy/module/test_lib_pypy/numpypy/test_numpy.py b/pypy/module/test_lib_pypy/numpypy/test_numpy.py
--- a/pypy/module/test_lib_pypy/numpypy/test_numpy.py
+++ b/pypy/module/test_lib_pypy/numpypy/test_numpy.py
@@ -2,7 +2,7 @@
class AppTestNumpy:
def setup_class(cls):
- cls.space = gettestobjspace(usemodules=['micronumpy'])
+ cls.space = gettestobjspace(usemodules=['_numpypy'])
def test_imports(self):
try:
diff --git a/pypy/translator/goal/targetnumpystandalone.py b/pypy/translator/goal/targetnumpystandalone.py
--- a/pypy/translator/goal/targetnumpystandalone.py
+++ b/pypy/translator/goal/targetnumpystandalone.py
@@ -10,7 +10,7 @@
"""
import time
-from pypy.module.micronumpy.compile import numpy_compile
+from pypy.module._numpypy.compile import numpy_compile
from pypy.jit.codewriter.policy import JitPolicy
from pypy.rpython.annlowlevel import hlstr
More information about the pypy-commit
mailing list