summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/npymath/npy_math.c.src6
-rw-r--r--numpy/core/tests/test_datetime.py4
-rw-r--r--numpy/core/tests/test_defchararray.py10
-rw-r--r--numpy/core/tests/test_deprecations.py37
-rw-r--r--numpy/core/tests/test_mem_overlap.py9
-rw-r--r--numpy/core/tests/test_memmap.py12
-rw-r--r--numpy/core/tests/test_multiarray.py30
-rw-r--r--numpy/core/tests/test_numeric.py4
-rw-r--r--numpy/core/tests/test_scalarinherit.py12
-rw-r--r--numpy/core/tests/test_shape_base.py4
-rw-r--r--numpy/core/tests/test_ufunc.py6
-rw-r--r--numpy/distutils/ccompiler.py8
-rw-r--r--numpy/lib/function_base.py4
-rw-r--r--numpy/lib/tests/test_io.py6
-rw-r--r--numpy/lib/tests/test_nanfunctions.py6
-rw-r--r--numpy/linalg/tests/test_linalg.py4
-rw-r--r--numpy/ma/tests/test_core.py42
-rw-r--r--numpy/random/mtrand/distributions.c2
-rw-r--r--numpy/random/mtrand/mtrand.pyx2
-rw-r--r--numpy/random/tests/test_random.py6
-rw-r--r--numpy/tests/test_scripts.py9
21 files changed, 121 insertions, 102 deletions
diff --git a/numpy/core/src/npymath/npy_math.c.src b/numpy/core/src/npymath/npy_math.c.src
index 7f62810d5..32fa41788 100644
--- a/numpy/core/src/npymath/npy_math.c.src
+++ b/numpy/core/src/npymath/npy_math.c.src
@@ -260,6 +260,9 @@ double npy_atanh(double x)
#endif
#ifndef HAVE_RINT
+#if defined(_MSC_VER) && (_MSC_VER == 1500) && !defined(_WIN64)
+#pragma optimize("", off)
+#endif
double npy_rint(double x)
{
double y, r;
@@ -280,6 +283,9 @@ double npy_rint(double x)
}
return y;
}
+#if defined(_MSC_VER) && (_MSC_VER == 1500) && !defined(_WIN64)
+#pragma optimize("", on)
+#endif
#endif
#ifndef HAVE_TRUNC
diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py
index 5fa281867..563aa48fb 100644
--- a/numpy/core/tests/test_datetime.py
+++ b/numpy/core/tests/test_datetime.py
@@ -571,9 +571,9 @@ class TestDateTime(TestCase):
"Verify that datetime dtype __setstate__ can handle bad arguments"
dt = np.dtype('>M8[us]')
assert_raises(ValueError, dt.__setstate__, (4, '>', None, None, None, -1, -1, 0, 1))
- assert (dt.__reduce__()[2] == np.dtype('>M8[us]').__reduce__()[2])
+ assert_(dt.__reduce__()[2] == np.dtype('>M8[us]').__reduce__()[2])
assert_raises(TypeError, dt.__setstate__, (4, '>', None, None, None, -1, -1, 0, ({}, 'xxx')))
- assert (dt.__reduce__()[2] == np.dtype('>M8[us]').__reduce__()[2])
+ assert_(dt.__reduce__()[2] == np.dtype('>M8[us]').__reduce__()[2])
def test_dtype_promotion(self):
# datetime <op> datetime computes the metadata gcd
diff --git a/numpy/core/tests/test_defchararray.py b/numpy/core/tests/test_defchararray.py
index 9ef316481..e828b879f 100644
--- a/numpy/core/tests/test_defchararray.py
+++ b/numpy/core/tests/test_defchararray.py
@@ -680,15 +680,15 @@ class TestOperations(TestCase):
dtype='S4').view(np.chararray)
sl1 = arr[:]
assert_array_equal(sl1, arr)
- assert sl1.base is arr
- assert sl1.base.base is arr.base
+ assert_(sl1.base is arr)
+ assert_(sl1.base.base is arr.base)
sl2 = arr[:, :]
assert_array_equal(sl2, arr)
- assert sl2.base is arr
- assert sl2.base.base is arr.base
+ assert_(sl2.base is arr)
+ assert_(sl2.base.base is arr.base)
- assert arr[0, 0] == asbytes('abc')
+ assert_(arr[0, 0] == asbytes('abc'))
def test_empty_indexing():
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 8f7e55d91..f6dc3d842 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -89,7 +89,7 @@ class _DeprecationTestCase(object):
if num is not None and num_found != num:
msg = "%i warnings found but %i expected." % (len(self.log), num)
lst = [w.category for w in self.log]
- raise AssertionError("\n".join([msg] + [lst]))
+ raise AssertionError("\n".join([msg] + lst))
with warnings.catch_warnings():
warnings.filterwarnings("error", message=self.message,
@@ -163,8 +163,8 @@ class TestRankDeprecation(_DeprecationTestCase):
class TestComparisonDeprecations(_DeprecationTestCase):
- """This tests the deprecation, for non-elementwise comparison logic.
- This used to mean that when an error occured during element-wise comparison
+ """This tests the deprecation, for non-element-wise comparison logic.
+ This used to mean that when an error occurred during element-wise comparison
(i.e. broadcasting) NotImplemented was returned, but also in the comparison
itself, False was given instead of the error.
@@ -192,13 +192,13 @@ class TestComparisonDeprecations(_DeprecationTestCase):
b = np.array(['a', 'b', 'c'])
assert_raises(ValueError, lambda x, y: x == y, a, b)
- # The empty list is not cast to string, this is only to document
+ # The empty list is not cast to string, as this is only to document
# that fact (it likely should be changed). This means that the
# following works (and returns False) due to dtype mismatch:
a == []
def test_none_comparison(self):
- # Test comparison of None, which should result in elementwise
+ # Test comparison of None, which should result in element-wise
# comparison in the future. [1, 2] == None should be [False, False].
with warnings.catch_warnings():
warnings.filterwarnings('always', '', FutureWarning)
@@ -211,7 +211,7 @@ class TestComparisonDeprecations(_DeprecationTestCase):
assert_raises(FutureWarning, operator.ne, np.arange(3), None)
def test_scalar_none_comparison(self):
- # Scalars should still just return false and not give a warnings.
+ # Scalars should still just return False and not give a warnings.
# The comparisons are flagged by pep8, ignore that.
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings('always', '', FutureWarning)
@@ -226,9 +226,9 @@ class TestComparisonDeprecations(_DeprecationTestCase):
assert_(np.datetime64('NaT') != None)
assert_(len(w) == 0)
- # For documentaiton purpose, this is why the datetime is dubious.
+ # For documentation purposes, this is why the datetime is dubious.
# At the time of deprecation this was no behaviour change, but
- # it has to be considered when the deprecations is done.
+ # it has to be considered when the deprecations are done.
assert_(np.equal(np.datetime64('NaT'), None))
def test_void_dtype_equality_failures(self):
@@ -277,7 +277,7 @@ class TestComparisonDeprecations(_DeprecationTestCase):
with warnings.catch_warnings() as l:
warnings.filterwarnings("always")
assert_raises(TypeError, f, arg1, arg2)
- assert not l
+ assert_(not l)
else:
# py2
assert_warns(DeprecationWarning, f, arg1, arg2)
@@ -338,8 +338,8 @@ class TestIdentityComparisonDeprecations(_DeprecationTestCase):
class TestAlterdotRestoredotDeprecations(_DeprecationTestCase):
"""The alterdot/restoredot functions are deprecated.
- These functions no longer do anything in numpy 1.10, so should not be
- used.
+ These functions no longer do anything in numpy 1.10, so
+ they should not be used.
"""
@@ -350,7 +350,7 @@ class TestAlterdotRestoredotDeprecations(_DeprecationTestCase):
class TestBooleanIndexShapeMismatchDeprecation():
"""Tests deprecation for boolean indexing where the boolean array
- does not match the input array along the given diemsions.
+ does not match the input array along the given dimensions.
"""
message = r"boolean index did not match indexed array"
@@ -400,5 +400,18 @@ class TestNonCContiguousViewDeprecation(_DeprecationTestCase):
self.assert_deprecated(np.ones((2,2)).T.view, args=(np.int8,))
+class TestTestDeprecated(object):
+ def test_assert_deprecated(self):
+ test_case_instance = _DeprecationTestCase()
+ test_case_instance.setUp()
+ assert_raises(AssertionError,
+ test_case_instance.assert_deprecated,
+ lambda: None)
+
+ def foo():
+ warnings.warn("foo", category=DeprecationWarning)
+
+ test_case_instance.assert_deprecated(foo)
+
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/core/tests/test_mem_overlap.py b/numpy/core/tests/test_mem_overlap.py
index 8d39fa4c0..a8b29ecd1 100644
--- a/numpy/core/tests/test_mem_overlap.py
+++ b/numpy/core/tests/test_mem_overlap.py
@@ -79,7 +79,8 @@ def _check_assignment(srcidx, dstidx):
cpy[dstidx] = arr[srcidx]
arr[dstidx] = arr[srcidx]
- assert np.all(arr == cpy), 'assigning arr[%s] = arr[%s]' % (dstidx, srcidx)
+ assert_(np.all(arr == cpy),
+ 'assigning arr[%s] = arr[%s]' % (dstidx, srcidx))
def test_overlapping_assignments():
@@ -129,7 +130,7 @@ def test_diophantine_fuzz():
if X is None:
# Check the simplified decision problem agrees
X_simplified = solve_diophantine(A, U, b, simplify=1)
- assert X_simplified is None, (A, U, b, X_simplified)
+ assert_(X_simplified is None, (A, U, b, X_simplified))
# Check no solution exists (provided the problem is
# small enough so that brute force checking doesn't
@@ -149,7 +150,7 @@ def test_diophantine_fuzz():
else:
# Check the simplified decision problem agrees
X_simplified = solve_diophantine(A, U, b, simplify=1)
- assert X_simplified is not None, (A, U, b, X_simplified)
+ assert_(X_simplified is not None, (A, U, b, X_simplified))
# Check validity
assert_(sum(a*x for a, x in zip(A, X)) == b)
@@ -391,7 +392,7 @@ def test_internal_overlap_slices():
s1 = tuple(random_slice(p, s) for p, s in zip(x.shape, steps))
a = x[s1].transpose(t1)
- assert not internal_overlap(a)
+ assert_(not internal_overlap(a))
cases += 1
diff --git a/numpy/core/tests/test_memmap.py b/numpy/core/tests/test_memmap.py
index 1585586ca..e41758c51 100644
--- a/numpy/core/tests/test_memmap.py
+++ b/numpy/core/tests/test_memmap.py
@@ -103,28 +103,28 @@ class TestMemmap(TestCase):
shape=self.shape)
tmp = (fp + 10)
if isinstance(tmp, memmap):
- assert tmp._mmap is not fp._mmap
+ assert_(tmp._mmap is not fp._mmap)
def test_indexing_drops_references(self):
fp = memmap(self.tmpfp, dtype=self.dtype, mode='w+',
shape=self.shape)
tmp = fp[[(1, 2), (2, 3)]]
if isinstance(tmp, memmap):
- assert tmp._mmap is not fp._mmap
+ assert_(tmp._mmap is not fp._mmap)
def test_slicing_keeps_references(self):
fp = memmap(self.tmpfp, dtype=self.dtype, mode='w+',
shape=self.shape)
- assert fp[:2, :2]._mmap is fp._mmap
+ assert_(fp[:2, :2]._mmap is fp._mmap)
def test_view(self):
fp = memmap(self.tmpfp, dtype=self.dtype, shape=self.shape)
new1 = fp.view()
new2 = new1.view()
- assert(new1.base is fp)
- assert(new2.base is fp)
+ assert_(new1.base is fp)
+ assert_(new2.base is fp)
new_array = asarray(fp)
- assert(new_array.base is fp)
+ assert_(new_array.base is fp)
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 693847273..593607954 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -3588,8 +3588,8 @@ class TestFlat(TestCase):
self.a.flat[12] = 100.0
except ValueError:
testpassed = True
- assert testpassed
- assert self.a.flat[12] == 12.0
+ assert_(testpassed)
+ assert_(self.a.flat[12] == 12.0)
def test_discontiguous(self):
testpassed = False
@@ -3597,8 +3597,8 @@ class TestFlat(TestCase):
self.b.flat[4] = 100.0
except ValueError:
testpassed = True
- assert testpassed
- assert self.b.flat[4] == 12.0
+ assert_(testpassed)
+ assert_(self.b.flat[4] == 12.0)
def test___array__(self):
c = self.a.flat.__array__()
@@ -3606,16 +3606,16 @@ class TestFlat(TestCase):
e = self.a0.flat.__array__()
f = self.b0.flat.__array__()
- assert c.flags.writeable is False
- assert d.flags.writeable is False
- assert e.flags.writeable is True
- assert f.flags.writeable is True
+ assert_(c.flags.writeable is False)
+ assert_(d.flags.writeable is False)
+ assert_(e.flags.writeable is True)
+ assert_(f.flags.writeable is True)
- assert c.flags.updateifcopy is False
- assert d.flags.updateifcopy is False
- assert e.flags.updateifcopy is False
- assert f.flags.updateifcopy is True
- assert f.base is self.b0
+ assert_(c.flags.updateifcopy is False)
+ assert_(d.flags.updateifcopy is False)
+ assert_(e.flags.updateifcopy is False)
+ assert_(f.flags.updateifcopy is True)
+ assert_(f.base is self.b0)
class TestResize(TestCase):
def test_basic(self):
@@ -5440,14 +5440,14 @@ class TestNewBufferProtocol(object):
if np.ones((10, 1), order="C").flags.f_contiguous:
c.strides = (-1, 80, 8)
- assert memoryview(c).strides == (800, 80, 8)
+ assert_(memoryview(c).strides == (800, 80, 8))
# Writing C-contiguous data to a BytesIO buffer should work
fd = io.BytesIO()
fd.write(c.data)
fortran = c.T
- assert memoryview(fortran).strides == (8, 80, 800)
+ assert_(memoryview(fortran).strides == (8, 80, 800))
arr = np.ones((1, 10))
if arr.flags.f_contiguous:
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index 43dad42f1..b7e146b5a 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -328,8 +328,8 @@ class TestSeterr(TestCase):
def log_err(*args):
self.called += 1
extobj_err = args
- assert (len(extobj_err) == 2)
- assert ("divide" in extobj_err[0])
+ assert_(len(extobj_err) == 2)
+ assert_("divide" in extobj_err[0])
with np.errstate(divide='ignore'):
np.seterrobj([20000, 3, log_err])
diff --git a/numpy/core/tests/test_scalarinherit.py b/numpy/core/tests/test_scalarinherit.py
index d8fd0acc3..e8cf7fde0 100644
--- a/numpy/core/tests/test_scalarinherit.py
+++ b/numpy/core/tests/test_scalarinherit.py
@@ -5,7 +5,7 @@
from __future__ import division, absolute_import, print_function
import numpy as np
-from numpy.testing import TestCase, run_module_suite
+from numpy.testing import TestCase, run_module_suite, assert_
class A(object):
@@ -26,17 +26,17 @@ class C0(B0):
class TestInherit(TestCase):
def test_init(self):
x = B(1.0)
- assert str(x) == '1.0'
+ assert_(str(x) == '1.0')
y = C(2.0)
- assert str(y) == '2.0'
+ assert_(str(y) == '2.0')
z = D(3.0)
- assert str(z) == '3.0'
+ assert_(str(z) == '3.0')
def test_init2(self):
x = B0(1.0)
- assert str(x) == '1.0'
+ assert_(str(x) == '1.0')
y = C0(2.0)
- assert str(y) == '2.0'
+ assert_(str(y) == '2.0')
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/core/tests/test_shape_base.py b/numpy/core/tests/test_shape_base.py
index cba083875..0d163c1dc 100644
--- a/numpy/core/tests/test_shape_base.py
+++ b/numpy/core/tests/test_shape_base.py
@@ -295,8 +295,8 @@ def test_stack():
for axis, expected_shape in zip(axes, expected_shapes):
assert_equal(np.stack(arrays, axis).shape, expected_shape)
# empty arrays
- assert stack([[], [], []]).shape == (3, 0)
- assert stack([[], [], []], axis=1).shape == (0, 3)
+ assert_(stack([[], [], []]).shape == (3, 0))
+ assert_(stack([[], [], []], axis=1).shape == (0, 3))
# edge cases
assert_raises_regex(ValueError, 'need at least one array', stack, [])
assert_raises_regex(ValueError, 'must have the same shape',
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index 934d91e7c..eb0985386 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -37,17 +37,17 @@ class TestUfuncKwargs(TestCase):
class TestUfunc(TestCase):
def test_pickle(self):
import pickle
- assert pickle.loads(pickle.dumps(np.sin)) is np.sin
+ assert_(pickle.loads(pickle.dumps(np.sin)) is np.sin)
# Check that ufunc not defined in the top level numpy namespace such as
# numpy.core.test_rational.test_add can also be pickled
- assert pickle.loads(pickle.dumps(test_add)) is test_add
+ assert_(pickle.loads(pickle.dumps(test_add)) is test_add)
def test_pickle_withstring(self):
import pickle
astring = asbytes("cnumpy.core\n_ufunc_reconstruct\np0\n"
"(S'numpy.core.umath'\np1\nS'cos'\np2\ntp3\nRp4\n.")
- assert pickle.loads(astring) is np.cos
+ assert_(pickle.loads(astring) is np.cos)
def test_reduceat_shifting_sum(self):
L = 6
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py
index ad235ed19..2f2d63b59 100644
--- a/numpy/distutils/ccompiler.py
+++ b/numpy/distutils/ccompiler.py
@@ -1,23 +1,22 @@
from __future__ import division, absolute_import, print_function
-import re
import os
+import re
import sys
import types
from copy import copy
-
-from distutils.ccompiler import *
from distutils import ccompiler
+from distutils.ccompiler import *
from distutils.errors import DistutilsExecError, DistutilsModuleError, \
DistutilsPlatformError
from distutils.sysconfig import customize_compiler
from distutils.version import LooseVersion
from numpy.distutils import log
+from numpy.distutils.compat import get_exception
from numpy.distutils.exec_command import exec_command
from numpy.distutils.misc_util import cyg2win32, is_sequence, mingw32, \
quote_args, get_num_build_jobs
-from numpy.distutils.compat import get_exception
def replace_method(klass, method_name, func):
@@ -634,7 +633,6 @@ ccompiler.gen_preprocess_options = gen_preprocess_options
# that removing this fix causes f2py problems on Windows XP (see ticket #723).
# Specifically, on WinXP when gfortran is installed in a directory path, which
# contains spaces, then f2py is unable to find it.
-import re
import string
_wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace)
_squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 9261dba22..3298789ee 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -268,14 +268,14 @@ def histogram(a, bins=10, range=None, normed=False, weights=None,
large datasets respectively. Switchover point is usually x.size~1000.
'FD' (Freedman Diaconis Estimator)
- .. math:: h = 2 \\frac{IQR}{n^{-1/3}}
+ .. math:: h = 2 \\frac{IQR}{n^{1/3}}
The binwidth is proportional to the interquartile range (IQR)
and inversely proportional to cube root of a.size. Can be too
conservative for small datasets, but is quite good
for large datasets. The IQR is very robust to outliers.
'Scott'
- .. math:: h = \\frac{3.5\\sigma}{n^{-1/3}}
+ .. math:: h = \\frac{3.5\\sigma}{n^{1/3}}
The binwidth is proportional to the standard deviation (sd) of the data
and inversely proportional to cube root of a.size. Can be too
conservative for small datasets, but is quite good
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index af904e96a..bffc5c63e 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -1815,9 +1815,9 @@ M 33 21.99
assert_equal(test.dtype.names, ['f0', 'f1', 'f2'])
- assert test.dtype['f0'] == np.float
- assert test.dtype['f1'] == np.int64
- assert test.dtype['f2'] == np.integer
+ assert_(test.dtype['f0'] == np.float)
+ assert_(test.dtype['f1'] == np.int64)
+ assert_(test.dtype['f2'] == np.integer)
assert_allclose(test['f0'], 73786976294838206464.)
assert_equal(test['f1'], 17179869184)
diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py
index f418504c2..7a7b37b98 100644
--- a/numpy/lib/tests/test_nanfunctions.py
+++ b/numpy/lib/tests/test_nanfunctions.py
@@ -395,12 +395,12 @@ class TestNanFunctions_MeanVarStd(TestCase, SharedNanFunctionsTestsMixin):
def test_dtype_error(self):
for f in self.nanfuncs:
- for dtype in [np.bool_, np.int_, np.object]:
- assert_raises(TypeError, f, _ndat, axis=1, dtype=np.int)
+ for dtype in [np.bool_, np.int_, np.object_]:
+ assert_raises(TypeError, f, _ndat, axis=1, dtype=dtype)
def test_out_dtype_error(self):
for f in self.nanfuncs:
- for dtype in [np.bool_, np.int_, np.object]:
+ for dtype in [np.bool_, np.int_, np.object_]:
out = np.empty(_ndat.shape[0], dtype=dtype)
assert_raises(TypeError, f, _ndat, axis=1, out=out)
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py
index afa098f12..fc139be19 100644
--- a/numpy/linalg/tests/test_linalg.py
+++ b/numpy/linalg/tests/test_linalg.py
@@ -61,7 +61,7 @@ def get_rtol(dtype):
class LinalgCase(object):
def __init__(self, name, a, b, exception_cls=None):
- assert isinstance(name, str)
+ assert_(isinstance(name, str))
self.name = name
self.a = a
self.b = b
@@ -267,7 +267,7 @@ def _stride_comb_iter(x):
xi = xi[slices]
xi[...] = x
xi = xi.view(x.__class__)
- assert np.all(xi == x)
+ assert_(np.all(xi == x))
yield xi, "stride_" + "_".join(["%+d" % j for j in repeats])
# generate also zero strides if possible
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index cecdedf26..e0d9f072c 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -756,47 +756,47 @@ class TestMaskedArray(TestCase):
t_ma = masked_array(data = [([1, 2, 3],)],
mask = [([False, True, False],)],
fill_value = ([999999, 999999, 999999],),
- dtype = [('a', '<i8', (3,))])
- assert str(t_ma[0]) == "([1, --, 3],)"
- assert repr(t_ma[0]) == "([1, --, 3],)"
+ dtype = [('a', '<i4', (3,))])
+ assert_(str(t_ma[0]) == "([1, --, 3],)")
+ assert_(repr(t_ma[0]) == "([1, --, 3],)")
# additonal tests with structured arrays
t_2d = masked_array(data = [([[1, 2], [3,4]],)],
mask = [([[False, True], [True, False]],)],
- dtype = [('a', '<i8', (2,2))])
- assert str(t_2d[0]) == "([[1, --], [--, 4]],)"
- assert repr(t_2d[0]) == "([[1, --], [--, 4]],)"
+ dtype = [('a', '<i4', (2,2))])
+ assert_(str(t_2d[0]) == "([[1, --], [--, 4]],)")
+ assert_(repr(t_2d[0]) == "([[1, --], [--, 4]],)")
t_0d = masked_array(data = [(1,2)],
mask = [(True,False)],
- dtype = [('a', '<i8'), ('b', '<i8')])
- assert str(t_0d[0]) == "(--, 2)"
- assert repr(t_0d[0]) == "(--, 2)"
+ dtype = [('a', '<i4'), ('b', '<i4')])
+ assert_(str(t_0d[0]) == "(--, 2)")
+ assert_(repr(t_0d[0]) == "(--, 2)")
t_2d = masked_array(data = [([[1, 2], [3,4]], 1)],
mask = [([[False, True], [True, False]], False)],
- dtype = [('a', '<i8', (2,2)), ('b', float)])
- assert str(t_2d[0]) == "([[1, --], [--, 4]], 1.0)"
- assert repr(t_2d[0]) == "([[1, --], [--, 4]], 1.0)"
+ dtype = [('a', '<i4', (2,2)), ('b', float)])
+ assert_(str(t_2d[0]) == "([[1, --], [--, 4]], 1.0)")
+ assert_(repr(t_2d[0]) == "([[1, --], [--, 4]], 1.0)")
t_ne = masked_array(data=[(1, (1, 1))],
mask=[(True, (True, False))],
- dtype = [('a', '<i8'), ('b', 'i4,i4')])
- assert str(t_ne[0]) == "(--, (--, 1))"
- assert repr(t_ne[0]) == "(--, (--, 1))"
+ dtype = [('a', '<i4'), ('b', 'i4,i4')])
+ assert_(str(t_ne[0]) == "(--, (--, 1))")
+ assert_(repr(t_ne[0]) == "(--, (--, 1))")
def test_object_with_array(self):
mx1 = masked_array([1.], mask=[True])
mx2 = masked_array([1., 2.])
mx = masked_array([mx1, mx2], mask=[False, True])
- assert mx[0] is mx1
- assert mx[1] is not mx2
- assert np.all(mx[1].data == mx2.data)
- assert np.all(mx[1].mask)
+ assert_(mx[0] is mx1)
+ assert_(mx[1] is not mx2)
+ assert_(np.all(mx[1].data == mx2.data))
+ assert_(np.all(mx[1].mask))
# check that we return a view.
mx[1].data[0] = 0.
- assert mx2[0] == 0.
+ assert_(mx2[0] == 0.)
class TestMaskedArrayArithmetic(TestCase):
@@ -4254,7 +4254,7 @@ def test_append_masked_array_along_axis():
def test_default_fill_value_complex():
# regression test for Python 3, where 'unicode' was not defined
- assert default_fill_value(1 + 1j) == 1.e20 + 0.0j
+ assert_(default_fill_value(1 + 1j) == 1.e20 + 0.0j)
###############################################################################
if __name__ == "__main__":
diff --git a/numpy/random/mtrand/distributions.c b/numpy/random/mtrand/distributions.c
index 39004178d..7c44088a7 100644
--- a/numpy/random/mtrand/distributions.c
+++ b/numpy/random/mtrand/distributions.c
@@ -188,7 +188,7 @@ double rk_beta(rk_state *state, double a, double b)
if ((a <= 1.0) && (b <= 1.0))
{
double U, V, X, Y;
- /* Use Jonk's algorithm */
+ /* Use Johnk's algorithm */
while (1)
{
diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/mtrand/mtrand.pyx
index 080591e5e..d6ba58bb2 100644
--- a/numpy/random/mtrand/mtrand.pyx
+++ b/numpy/random/mtrand/mtrand.pyx
@@ -1280,7 +1280,7 @@ cdef class RandomState:
Random values in a given shape.
- Create an array of the given shape and propagate it with
+ Create an array of the given shape and populate it with
random samples from a uniform distribution
over ``[0, 1)``.
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
index ab7f90d82..193844030 100644
--- a/numpy/random/tests/test_random.py
+++ b/numpy/random/tests/test_random.py
@@ -26,12 +26,12 @@ class TestSeed(TestCase):
assert_equal(s.randint(1000), 265)
def test_invalid_scalar(self):
- # seed must be a unsigned 32 bit integers
+ # seed must be an unsigned 32 bit integer
assert_raises(TypeError, np.random.RandomState, -0.5)
assert_raises(ValueError, np.random.RandomState, -1)
def test_invalid_array(self):
- # seed must be a unsigned 32 bit integers
+ # seed must be an unsigned 32 bit integer
assert_raises(TypeError, np.random.RandomState, [-0.5])
assert_raises(ValueError, np.random.RandomState, [-1])
assert_raises(ValueError, np.random.RandomState, [4294967296])
@@ -129,7 +129,7 @@ class TestSetState(TestCase):
self.prng.negative_binomial(0.5, 0.5)
class TestRandomDist(TestCase):
- # Make sure the random distrobution return the correct value for a
+ # Make sure the random distribution returns the correct value for a
# given seed
def setUp(self):
diff --git a/numpy/tests/test_scripts.py b/numpy/tests/test_scripts.py
index 552383d77..74efd2650 100644
--- a/numpy/tests/test_scripts.py
+++ b/numpy/tests/test_scripts.py
@@ -64,11 +64,12 @@ def test_f2py():
if sys.platform == 'win32':
f2py_cmd = r"%s\Scripts\f2py.py" % dirname(sys.executable)
code, stdout, stderr = run_command([sys.executable, f2py_cmd, '-v'])
- assert_equal(stdout.strip(), asbytes('2'))
+ success = stdout.strip() == asbytes('2')
+ assert_(success, "Warning: f2py not found in path")
else:
# unclear what f2py cmd was installed as, check plain (f2py) and
# current python version specific one (f2py3.4)
- f2py_cmds = ['f2py', 'f2py' + basename(sys.executable)[6:]]
+ f2py_cmds = ('f2py', 'f2py' + basename(sys.executable)[6:])
success = False
for f2py_cmd in f2py_cmds:
try:
@@ -76,6 +77,6 @@ def test_f2py():
assert_equal(stdout.strip(), asbytes('2'))
success = True
break
- except FileNotFoundError:
+ except OSError:
pass
- assert_(success, "wasn't able to find f2py or %s on commandline" % f2py_cmds[1])
+ assert_(success, "Warning: neither %s nor %s found in path" % f2py_cmds)