On Thu, Oct 21, 2021 at 07:20:33AM +0200, Bjorn Ketelaars wrote:
> On Wed 20/10/2021 23:11, Stuart Henderson wrote:
> > hmm, looks like we're going to need a bigger jump to work with python 3.9
> > though
>
> You are right, testing of python3.9 seems to have started with
> py-numpy-1.19.1. py-numpy>=1.19.3 supports python3.9.
>
> I had a quick look at 1.19.5 (last release in the 1.19.x cycle), and got
> it to work/test. I currently only tested work related stuff.
> py-numpy-1.19.5 requires a newer version of devel/py-hypothesis (TDEP)
> than we have in ports. Nevertheless, 'make test' seems to run just fine
> with no new failing tests.
>
> Future wise, having py-numpy-1.19.5 in ports is a better choice than
> having 1.17.5. Both will need testing, so choosing for the newer one
> does make sense.
This is great, a newer numpy makes life much easier. Testing on arm64 looks
promising. Test log attached. I also did a bit of testing with my ports.
-m
cd /home/martin/ports/pobj/py-numpy-1.19.5-python3 && CC=cc PYTHONUSERBASE=
PORTSDIR="/home/martin/ports" LIBTOOL="/usr/bin/libtool"
PATH='/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin'
PREFIX='/usr/local' LOCALBASE='/usr/local' X11BASE='/usr/X11R6' CFLAGS='-O2
-pipe -D CYTHON_SMALL_CODE=' TRUEPREFIX='/usr/local' DESTDIR=''
HOME='/py-numpy-1.19.5_writes_to_HOME' PICFLAG="-fpic" BINGRP=bin BINOWN=root
BINMODE=755 NONBINMODE=644 DIRMODE=755 INSTALL_COPY=-c INSTALL_STRIP=-s
MANGRP=bin MANOWN=root MANMODE=644
BSD_INSTALL_PROGRAM="/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin/install
-c -s -m 755"
BSD_INSTALL_SCRIPT="/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin/install
-c -m 755"
BSD_INSTALL_DATA="/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin/install
-c -m 644"
BSD_INSTALL_MAN="/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin/install -c
-m 644"
BSD_INSTALL_PROGRAM_DIR="/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin/install
-d -m 755"
BSD_INSTALL_SCRIPT_DIR="/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin/install
-d -m 755"
BSD_INSTALL_DATA_DIR="/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin/install
-d -m 755"
BSD_INSTALL_MAN_DIR="/home/martin/ports/pobj/py-numpy-1.19.5-python3/bin/install
-d -m 755" /usr/local/bin/python3.8 -c 'import numpy ; numpy.test()'
NumPy version 1.19.5
NumPy relaxed strides checking option: True
.............................................................x.......... [ 0%]
.....................................................sss................ [ 1%]
............................................................FFF......... [ 1%]
..FFF.................................F................................. [ 2%]
...................................................x..........x..x...... [ 3%]
....x................................................................... [ 3%]
........................................................................ [ 4%]
..................................ssss................................x. [ 5%]
........................................................................ [ 5%]
........................................................................ [ 6%]
........................................................................ [ 7%]
........................................................................ [ 7%]
........................................................................ [ 8%]
........................................................................ [ 9%]
........................................................................ [ 9%]
........................................................................ [ 10%]
........................................................................ [ 11%]
........................................................................ [ 11%]
........................................................FF.............. [ 12%]
......................................................................F. [ 13%]
........................................................................ [ 13%]
.....Fsssss.s......ssss.sss............................................. [ 14%]
........................................................................ [ 15%]
.............................xx......................................... [ 15%]
........................................................................ [ 16%]
.............s.......................................................... [ 17%]
........................................................................ [ 17%]
........................................................................ [ 18%]
........................................................................ [ 18%]
........................................................................ [ 19%]
........................................................................ [ 20%]
........................................................................ [ 20%]
...............................................x...x.................... [ 21%]
..FF.FF................................................................. [ 22%]
...............................................xx....................... [ 22%]
........F............................................................... [ 23%]
........................................................................ [ 24%]
........................................................................ [ 24%]
.............F.......................................................... [ 25%]
.........................F.............................................. [ 26%]
........................................................................ [ 26%]
........................................................................ [ 27%]
..................................s....................................F [ 28%]
........................................................................ [ 28%]
...............s...........................................Fs........... [ 29%]
........................................................................ [ 30%]
......................................F................................. [ 30%]
..........................F............................................. [ 31%]
........................................................................ [ 32%]
........................................................................ [ 32%]
........................................................................ [ 33%]
.........................................F.........FFF..FFF..F.......... [ 34%]
........................................................................ [ 34%]
................................FFF.FFF.........................s.ss.s.. [ 35%]
s.......s............................................................... [ 36%]
........................................................................ [ 36%]
........................................................................ [ 37%]
........................................................................ [ 37%]
........................................................................ [ 38%]
............................................F.........s...........ssssss [ 39%]
sssssssss...............sssssssssssssss................................. [ 39%]
........................................................................ [ 40%]
........................................................................ [ 41%]
........................................................................ [ 41%]
........................................................................ [ 42%]
........................................................................ [ 43%]
........................................................................ [ 43%]
........................................................................ [ 44%]
........................................................................ [ 45%]
........................................................................ [ 45%]
...............x........................................................ [ 46%]
........................................................................ [ 47%]
........................................................................ [ 47%]
........................................................................ [ 48%]
........................................................................ [ 49%]
........................................................................ [ 49%]
........................................................................ [ 50%]
........................................................................ [ 51%]
...................................s.................................... [ 51%]
........................................................................ [ 52%]
.......................................x................................ [ 53%]
........................................................................ [ 53%]
..........................F............................................. [ 54%]
........................................................................ [ 55%]
........................................................................ [ 55%]
........................................................................ [ 56%]
........................................................................ [ 56%]
........................................................................ [ 57%]
........................................................................ [ 58%]
........................................................................ [ 58%]
........................................................................ [ 59%]
........................................................................ [ 60%]
....................................................x................... [ 60%]
........................................................................ [ 61%]
........................................................................ [ 62%]
............................................................s........... [ 62%]
........................................................................ [ 63%]
........................................................................ [ 64%]
........................................FFFFFFFFF.FF.FF................. [ 64%]
...............................................F....................x... [ 65%]
........................................................................ [ 66%]
........................................................................ [ 66%]
........................................................................ [ 67%]
........................................................................ [ 68%]
........................................................................ [ 68%]
........................................................................ [ 69%]
........................................................................ [ 70%]
........................................................................ [ 70%]
........................................................................ [ 71%]
........................................................................ [ 72%]
........................................................................ [ 72%]
........................................................................ [ 73%]
........................................................................ [ 73%]
........................................................................ [ 74%]
........................................................................ [ 75%]
........................................................................ [ 75%]
........................................................................ [ 76%]
........................................................................ [ 77%]
........................................................................ [ 77%]
...................................................................xx... [ 78%]
........................................................................ [ 79%]
........................................................................ [ 79%]
........................................................................ [ 80%]
........................................................................ [ 81%]
........................................................................ [ 81%]
........................................................................ [ 82%]
........................................................................ [ 83%]
........................................................................ [ 83%]
........................................................................ [ 84%]
........................................................................ [ 85%]
........................................................................ [ 85%]
........................................................................ [ 86%]
........................................................................ [ 87%]
........................................................................ [ 87%]
........................................................................ [ 88%]
........s................s................s.................s....ss..... [ 89%]
........................................................................ [ 89%]
...................................................................FFF.. [ 90%]
........................................................................ [ 91%]
........................................................................ [ 91%]
........................................................................ [ 92%]
........................................................................ [ 92%]
........................................................................ [ 93%]
............................................................s........... [ 94%]
........................................................................ [ 94%]
........................................................................ [ 95%]
........................................................................ [ 96%]
....................................ss.................................. [ 96%]
........................................................................ [ 97%]
........................................................................ [ 98%]
............ssssssss.................................................... [ 98%]
..............................sss....................................... [ 99%]
................................................xxX. [100%]
=================================== FAILURES ===================================
__________ TestDateTime.test_timedelta_floor_div_warnings[op10-op20] ___________
self = <numpy.core.tests.test_datetime.TestDateTime object at 0x1ab585b7c0>
op1 = numpy.timedelta64(10,'us'), op2 = numpy.timedelta64(0,'us')
@pytest.mark.parametrize("op1, op2", [
# div by 0
(np.timedelta64(10, 'us'),
np.timedelta64(0, 'us')),
# div with NaT
(np.timedelta64('NaT'),
np.timedelta64(50, 'us')),
# special case for int64 min
# in integer floor division
(np.timedelta64(np.iinfo(np.int64).min),
np.timedelta64(-1)),
])
def test_timedelta_floor_div_warnings(self, op1, op2):
with assert_warns(RuntimeWarning):
actual = op1 // op2
assert_equal(actual, 0)
> assert_equal(actual.dtype, np.int64)
actual = 0
op1 = numpy.timedelta64(10,'us')
op2 = numpy.timedelta64(0,'us')
self = <numpy.core.tests.test_datetime.TestDateTime object at
0x1ab585b7c0>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_datetime.py:1212:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x1ab585bf10>, type = None
value = None, traceback = None
def __exit__(self, type, value, traceback):
if type is None:
try:
> next(self.gen)
E AssertionError: No warning raised
self = <contextlib._GeneratorContextManager object at 0x1ab585bf10>
traceback = None
type = None
value = None
/usr/local/lib/python3.8/contextlib.py:120: AssertionError
__________ TestDateTime.test_timedelta_floor_div_warnings[op11-op21] ___________
self = <numpy.core.tests.test_datetime.TestDateTime object at 0x1a66185280>
op1 = numpy.timedelta64('NaT'), op2 = numpy.timedelta64(50,'us')
@pytest.mark.parametrize("op1, op2", [
# div by 0
(np.timedelta64(10, 'us'),
np.timedelta64(0, 'us')),
# div with NaT
(np.timedelta64('NaT'),
np.timedelta64(50, 'us')),
# special case for int64 min
# in integer floor division
(np.timedelta64(np.iinfo(np.int64).min),
np.timedelta64(-1)),
])
def test_timedelta_floor_div_warnings(self, op1, op2):
with assert_warns(RuntimeWarning):
actual = op1 // op2
assert_equal(actual, 0)
> assert_equal(actual.dtype, np.int64)
actual = 0
op1 = numpy.timedelta64('NaT')
op2 = numpy.timedelta64(50,'us')
self = <numpy.core.tests.test_datetime.TestDateTime object at
0x1a66185280>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_datetime.py:1212:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x1afb48bd60>, type = None
value = None, traceback = None
def __exit__(self, type, value, traceback):
if type is None:
try:
> next(self.gen)
E AssertionError: No warning raised
self = <contextlib._GeneratorContextManager object at 0x1afb48bd60>
traceback = None
type = None
value = None
/usr/local/lib/python3.8/contextlib.py:120: AssertionError
__________ TestDateTime.test_timedelta_floor_div_warnings[op12-op22] ___________
self = <numpy.core.tests.test_datetime.TestDateTime object at 0x1afb48b5e0>
op1 = numpy.timedelta64('NaT'), op2 = numpy.timedelta64(-1)
@pytest.mark.parametrize("op1, op2", [
# div by 0
(np.timedelta64(10, 'us'),
np.timedelta64(0, 'us')),
# div with NaT
(np.timedelta64('NaT'),
np.timedelta64(50, 'us')),
# special case for int64 min
# in integer floor division
(np.timedelta64(np.iinfo(np.int64).min),
np.timedelta64(-1)),
])
def test_timedelta_floor_div_warnings(self, op1, op2):
with assert_warns(RuntimeWarning):
actual = op1 // op2
assert_equal(actual, 0)
> assert_equal(actual.dtype, np.int64)
actual = 0
op1 = numpy.timedelta64('NaT')
op2 = numpy.timedelta64(-1)
self = <numpy.core.tests.test_datetime.TestDateTime object at
0x1afb48b5e0>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_datetime.py:1212:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x1ab4be1eb0>, type = None
value = None, traceback = None
def __exit__(self, type, value, traceback):
if type is None:
try:
> next(self.gen)
E AssertionError: No warning raised
self = <contextlib._GeneratorContextManager object at 0x1ab4be1eb0>
traceback = None
type = None
value = None
/usr/local/lib/python3.8/contextlib.py:120: AssertionError
____________ TestDateTime.test_timedelta_divmod_warnings[op10-op20] ____________
self = <numpy.core.tests.test_datetime.TestDateTime object at 0x1a9a64b250>
op1 = numpy.timedelta64(10,'us'), op2 = numpy.timedelta64(0,'us')
@pytest.mark.parametrize("op1, op2", [
# reuse cases from floordiv
# div by 0
(np.timedelta64(10, 'us'),
np.timedelta64(0, 'us')),
# div with NaT
(np.timedelta64('NaT'),
np.timedelta64(50, 'us')),
# special case for int64 min
# in integer floor division
(np.timedelta64(np.iinfo(np.int64).min),
np.timedelta64(-1)),
])
def test_timedelta_divmod_warnings(self, op1, op2):
with assert_warns(RuntimeWarning):
> expected = (op1 // op2, op1 % op2)
expected = (0, numpy.timedelta64('NaT','us'))
op1 = numpy.timedelta64(10,'us')
op2 = numpy.timedelta64(0,'us')
self = <numpy.core.tests.test_datetime.TestDateTime object at
0x1a9a64b250>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_datetime.py:1285:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x1a9a64b370>, type = None
value = None, traceback = None
def __exit__(self, type, value, traceback):
if type is None:
try:
> next(self.gen)
E AssertionError: No warning raised
self = <contextlib._GeneratorContextManager object at 0x1a9a64b370>
traceback = None
type = None
value = None
/usr/local/lib/python3.8/contextlib.py:120: AssertionError
____________ TestDateTime.test_timedelta_divmod_warnings[op11-op21] ____________
self = <numpy.core.tests.test_datetime.TestDateTime object at 0x1afb49f220>
op1 = numpy.timedelta64('NaT'), op2 = numpy.timedelta64(50,'us')
@pytest.mark.parametrize("op1, op2", [
# reuse cases from floordiv
# div by 0
(np.timedelta64(10, 'us'),
np.timedelta64(0, 'us')),
# div with NaT
(np.timedelta64('NaT'),
np.timedelta64(50, 'us')),
# special case for int64 min
# in integer floor division
(np.timedelta64(np.iinfo(np.int64).min),
np.timedelta64(-1)),
])
def test_timedelta_divmod_warnings(self, op1, op2):
with assert_warns(RuntimeWarning):
> expected = (op1 // op2, op1 % op2)
expected = (0, numpy.timedelta64('NaT','us'))
op1 = numpy.timedelta64('NaT')
op2 = numpy.timedelta64(50,'us')
self = <numpy.core.tests.test_datetime.TestDateTime object at
0x1afb49f220>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_datetime.py:1285:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x1afb49fc70>, type = None
value = None, traceback = None
def __exit__(self, type, value, traceback):
if type is None:
try:
> next(self.gen)
E AssertionError: No warning raised
self = <contextlib._GeneratorContextManager object at 0x1afb49fc70>
traceback = None
type = None
value = None
/usr/local/lib/python3.8/contextlib.py:120: AssertionError
____________ TestDateTime.test_timedelta_divmod_warnings[op12-op22] ____________
self = <numpy.core.tests.test_datetime.TestDateTime object at 0x1afb4bf0a0>
op1 = numpy.timedelta64('NaT'), op2 = numpy.timedelta64(-1)
@pytest.mark.parametrize("op1, op2", [
# reuse cases from floordiv
# div by 0
(np.timedelta64(10, 'us'),
np.timedelta64(0, 'us')),
# div with NaT
(np.timedelta64('NaT'),
np.timedelta64(50, 'us')),
# special case for int64 min
# in integer floor division
(np.timedelta64(np.iinfo(np.int64).min),
np.timedelta64(-1)),
])
def test_timedelta_divmod_warnings(self, op1, op2):
with assert_warns(RuntimeWarning):
> expected = (op1 // op2, op1 % op2)
expected = (0, numpy.timedelta64('NaT'))
op1 = numpy.timedelta64('NaT')
op2 = numpy.timedelta64(-1)
self = <numpy.core.tests.test_datetime.TestDateTime object at
0x1afb4bf0a0>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_datetime.py:1285:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x1afb4bf9d0>, type = None
value = None, traceback = None
def __exit__(self, type, value, traceback):
if type is None:
try:
> next(self.gen)
E AssertionError: No warning raised
self = <contextlib._GeneratorContextManager object at 0x1afb4bf9d0>
traceback = None
type = None
value = None
/usr/local/lib/python3.8/contextlib.py:120: AssertionError
_______________ TestDateTime.test_timedelta_modulus_div_by_zero ________________
self = <numpy.core.tests.test_datetime.TestDateTime object at 0x1affce6580>
def test_timedelta_modulus_div_by_zero(self):
with assert_warns(RuntimeWarning):
actual = np.timedelta64(10, 's') % np.timedelta64(0, 's')
> assert_equal(actual, np.timedelta64('NaT'))
actual = numpy.timedelta64('NaT','s')
self = <numpy.core.tests.test_datetime.TestDateTime object at
0x1affce6580>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_datetime.py:1897:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x1affce6be0>, type = None
value = None, traceback = None
def __exit__(self, type, value, traceback):
if type is None:
try:
> next(self.gen)
E AssertionError: No warning raised
self = <contextlib._GeneratorContextManager object at 0x1affce6be0>
traceback = None
type = None
value = None
/usr/local/lib/python3.8/contextlib.py:120: AssertionError
__________________________ TestErrstate.test_invalid ___________________________
self = <numpy.core.tests.test_errstate.TestErrstate object at 0x1aaff69f40>
@pytest.mark.skipif(arm_softfloat,
reason='platform/cpu issue with FPU (gh-413,-15562)')
def test_invalid(self):
with np.errstate(all='raise', under='ignore'):
a = -np.arange(3)
# This should work
with np.errstate(invalid='ignore'):
np.sqrt(a)
# While this should fail!
with assert_raises(FloatingPointError):
> np.sqrt(a)
a = array([ 0, -1, -2])
self = <numpy.core.tests.test_errstate.TestErrstate object at
0x1aaff69f40>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_errstate.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:227: in __exit__
self._raiseFailure("{} not raised".format(exc_name))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b266d83d0>
standardMsg = 'FloatingPointError not raised'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: FloatingPointError not raised
msg = 'FloatingPointError not raised'
self = <unittest.case._AssertRaisesContext object at 0x1b266d83d0>
standardMsg = 'FloatingPointError not raised'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
___________________________ TestErrstate.test_divide ___________________________
self = <numpy.core.tests.test_errstate.TestErrstate object at 0x1afd4ee790>
@pytest.mark.skipif(arm_softfloat,
reason='platform/cpu issue with FPU (gh-15562)')
def test_divide(self):
with np.errstate(all='raise', under='ignore'):
a = -np.arange(3)
# This should work
with np.errstate(divide='ignore'):
a // 0
# While this should fail!
with assert_raises(FloatingPointError):
> a // 0
a = array([ 0, -1, -2])
self = <numpy.core.tests.test_errstate.TestErrstate object at
0x1afd4ee790>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_errstate.py:37:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:227: in __exit__
self._raiseFailure("{} not raised".format(exc_name))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b332b15e0>
standardMsg = 'FloatingPointError not raised'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: FloatingPointError not raised
msg = 'FloatingPointError not raised'
self = <unittest.case._AssertRaisesContext object at 0x1b332b15e0>
standardMsg = 'FloatingPointError not raised'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
____________________________ TestHalf.test_half_fpe ____________________________
self = <numpy.core.tests.test_half.TestHalf object at 0x1a485ea070>
@pytest.mark.skipif(platform.machine() == "armv5tel",
reason="See gh-413.")
def test_half_fpe(self):
with np.errstate(all='raise'):
sx16 = np.array((1e-4,), dtype=float16)
bx16 = np.array((1e4,), dtype=float16)
sy16 = float16(1e-4)
by16 = float16(1e4)
# Underflow errors
> assert_raises_fpe('underflow', lambda a, b:a*b, sx16, sx16)
bx16 = array([10000.], dtype=float16)
by16 = 10000.0
self = <numpy.core.tests.test_half.TestHalf object at 0x1a485ea070>
sx16 = array([0.0001], dtype=float16)
sy16 = 0.0001
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_half.py:472:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
strmatch = 'underflow'
callable = <function TestHalf.test_half_fpe.<locals>.<lambda> at 0x1aaff84f70>
args = (array([0.0001], dtype=float16), array([0.0001], dtype=float16))
kwargs = {}
def assert_raises_fpe(strmatch, callable, *args, **kwargs):
try:
callable(*args, **kwargs)
except FloatingPointError as exc:
assert_(str(exc).find(strmatch) >= 0,
"Did not raise floating point %s error" % strmatch)
else:
> assert_(False,
"Did not raise floating point %s error" % strmatch)
E AssertionError: Did not raise floating point underflow error
args = (array([0.0001], dtype=float16), array([0.0001], dtype=float16))
callable = <function TestHalf.test_half_fpe.<locals>.<lambda> at 0x1aaff84f70>
kwargs = {}
strmatch = 'underflow'
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_half.py:16:
AssertionError
_____________________________ test_repr_roundtrip ______________________________
@pytest.mark.skipif(LD_INFO.precision + 2 >= repr_precision,
reason="repr precision not enough to show eps")
def test_repr_roundtrip():
# We will only see eps in repr if within printing precision.
o = 1 + LD_INFO.eps
> assert_equal(np.longdouble(repr(o)), o, "repr was %s" % repr(o))
E AssertionError:
E Items are not equal: repr was 1.0000000000000000000000000000000002
E ACTUAL: 1.0
E DESIRED: 1.0000000000000000000000000000000002
o = 1.0000000000000000000000000000000002
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_longdouble.py:37:
AssertionError
__________________________ TestSeterr.test_divide_err __________________________
self = <numpy.core.tests.test_numeric.TestSeterr object at 0x1b127431c0>
@pytest.mark.skipif(platform.machine() == "armv5tel", reason="See gh-413.")
def test_divide_err(self):
with np.errstate(divide='raise'):
with assert_raises(FloatingPointError):
> np.array([1.]) / np.array([0.])
self = <numpy.core.tests.test_numeric.TestSeterr object at 0x1b127431c0>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:533:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:227: in __exit__
self._raiseFailure("{} not raised".format(exc_name))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b12743340>
standardMsg = 'FloatingPointError not raised'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: FloatingPointError not raised
msg = 'FloatingPointError not raised'
self = <unittest.case._AssertRaisesContext object at 0x1b12743340>
standardMsg = 'FloatingPointError not raised'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
____________________________ TestSeterr.test_errobj ____________________________
self = <numpy.core.tests.test_numeric.TestSeterr object at 0x1b1274c4c0>
def test_errobj(self):
olderrobj = np.geterrobj()
self.called = 0
try:
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with np.errstate(divide='warn'):
np.seterrobj([20000, 1, None])
np.array([1.]) / np.array([0.])
> assert_equal(len(w), 1)
E AssertionError:
E Items are not equal:
E ACTUAL: 0
E DESIRED: 1
olderrobj = [8192, 521, None]
self = <numpy.core.tests.test_numeric.TestSeterr object at 0x1b1274c4c0>
w = []
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:547:
AssertionError
_________________ TestFloatExceptions.test_floating_exceptions _________________
self = <numpy.core.tests.test_numeric.TestFloatExceptions object at
0x1b37007f70>
def test_floating_exceptions(self):
# Test basic arithmetic function errors
with np.errstate(all='raise'):
# Test for all real and complex float types
for typecode in np.typecodes['AllFloat']:
ftype = np.obj2sctype(typecode)
if np.dtype(ftype).kind == 'f':
# Get some extreme values for the type
fi = np.finfo(ftype)
ft_tiny = fi.tiny
ft_max = fi.max
ft_eps = fi.eps
underflow = 'underflow'
divbyzero = 'divide by zero'
else:
# 'c', complex, corresponding real dtype
rtype = type(ftype(0).real)
fi = np.finfo(rtype)
ft_tiny = ftype(fi.tiny)
ft_max = ftype(fi.max)
ft_eps = ftype(fi.eps)
# The complex types raise different exceptions
underflow = ''
divbyzero = ''
overflow = 'overflow'
invalid = 'invalid'
> self.assert_raises_fpe(underflow,
lambda a, b: a/b, ft_tiny, ft_max)
divbyzero = 'divide by zero'
fi = finfo(resolution=0.001, min=-6.55040e+04, max=6.55040e+04,
dtype=float16)
ft_eps = 0.000977
ft_max = 65500.0
ft_tiny = 6.104e-05
ftype = <class 'numpy.float16'>
invalid = 'invalid'
overflow = 'overflow'
self = <numpy.core.tests.test_numeric.TestFloatExceptions object at
0x1b37007f70>
typecode = 'e'
underflow = 'underflow'
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:637:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <numpy.core.tests.test_numeric.TestFloatExceptions object at
0x1b37007f70>
fpeerr = 'underflow'
flop = <function TestFloatExceptions.test_floating_exceptions.<locals>.<lambda>
at 0x1abf111430>
x = 6.104e-05, y = 65500.0
def assert_raises_fpe(self, fpeerr, flop, x, y):
ftype = type(x)
try:
flop(x, y)
> assert_(False,
"Type %s did not raise fpe error '%s'." % (ftype, fpeerr))
E AssertionError: Type <class 'numpy.float16'> did not raise
fpe error 'underflow'.
flop = <function
TestFloatExceptions.test_floating_exceptions.<locals>.<lambda> at 0x1abf111430>
fpeerr = 'underflow'
ftype = <class 'numpy.float16'>
self = <numpy.core.tests.test_numeric.TestFloatExceptions object at
0x1b37007f70>
x = 6.104e-05
y = 65500.0
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:592:
AssertionError
______________________ TestFloatExceptions.test_warnings _______________________
self = <numpy.core.tests.test_numeric.TestFloatExceptions object at
0x1b37014b50>
def test_warnings(self):
# test warning code path
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with np.errstate(all="warn"):
np.divide(1, 0.)
> assert_equal(len(w), 1)
E AssertionError:
E Items are not equal:
E ACTUAL: 0
E DESIRED: 1
self = <numpy.core.tests.test_numeric.TestFloatExceptions object at
0x1b37014b50>
w = []
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:670:
AssertionError
________________________ TestLikeFuncs.test_filled_like ________________________
self = <numpy.core.tests.test_numeric.TestLikeFuncs object at 0x1aa2250700>
def test_filled_like(self):
self.check_like_function(np.full_like, 0, True)
self.check_like_function(np.full_like, 1, True)
self.check_like_function(np.full_like, 1000, True)
self.check_like_function(np.full_like, 123.456, True)
> self.check_like_function(np.full_like, np.inf, True)
self = <numpy.core.tests.test_numeric.TestLikeFuncs object at
0x1aa2250700>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2667:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2578:
in check_like_function
self.compare_array_value(dz, value, fill_value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <numpy.core.tests.test_numeric.TestLikeFuncs object at 0x1aa2250700>
dz = array([[9223372036854775807, 9223372036854775807, 9223372036854775807],
[9223372036854775807, 9223372036854775807, 9223372036854775807]])
value = inf, fill_value = True
def compare_array_value(self, dz, value, fill_value):
if value is not None:
if fill_value:
try:
z = dz.dtype.type(value)
except OverflowError:
pass
else:
> assert_(np.all(dz == z))
E AssertionError
dz = array([[9223372036854775807, 9223372036854775807,
9223372036854775807],
[9223372036854775807, 9223372036854775807, 9223372036854775807]])
fill_value = True
self = <numpy.core.tests.test_numeric.TestLikeFuncs object at
0x1aa2250700>
value = inf
z = 0
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_numeric.py:2557:
AssertionError
______________ TestCommaDecimalPointLocale.test_locale_longdouble ______________
self = <numpy.core.tests.test_print.TestCommaDecimalPointLocale object at
0x1a769d78e0>
def test_locale_longdouble(self):
> assert_equal(str(np.longdouble('1.2')), str(float(1.2)))
E AssertionError:
E Items are not equal:
E ACTUAL: '1.1999999999999999555910790149937384'
E DESIRED: '1.2'
self = <numpy.core.tests.test_print.TestCommaDecimalPointLocale object at
0x1a769d78e0>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_print.py:200:
AssertionError
___________________ TestRegression.test_nonarray_assignment ____________________
self = <numpy.core.tests.test_regression.TestRegression object at 0x1ac691be20>
def test_nonarray_assignment(self):
# See also Issue gh-2870, test for non-array assignment
# and equivalent unsafe casted array assignment
a = np.arange(10)
b = np.ones(10, dtype=bool)
r = np.arange(10)
def assign(a, b, c):
a[b] = c
> assert_raises(ValueError, assign, a, b, np.nan)
a = array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
assign = <function TestRegression.test_nonarray_assignment.<locals>.assign
at 0x1a5992ec10>
b = array([ True, True, True, True, True, True, True, True,
True,
True])
r = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
self = <numpy.core.tests.test_regression.TestRegression object at
0x1ac691be20>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_regression.py:350:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1ac692c070>
standardMsg = 'ValueError not raised by assign'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: ValueError not raised by assign
msg = 'ValueError not raised by assign'
self = <unittest.case._AssertRaisesContext object at 0x1ac692c070>
standardMsg = 'ValueError not raised by assign'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_______ TestAsIntegerRatio.test_roundtrip[float128-frac_vals3-exp_vals3] _______
self = <numpy.core.tests.test_scalar_methods.TestAsIntegerRatio object at
0x1a7d93d340>
ftype = <class 'numpy.float128'>
frac_vals = [0.0, 0.20492557202724854, 0.4277180662199366, 0.9888085019891495,
0.9620175814461964]
exp_vals = [0, -7400, 14266, -7822, -8721]
@pytest.mark.parametrize("ftype, frac_vals, exp_vals", [
# dtype test cases generated using hypothesis
# first five generated cases per dtype
(np.half, [0.0, 0.01154830649280303, 0.31082276347447274,
0.527350517124794, 0.8308562335072596],
[0, 1, 0, -8, 12]),
(np.single, [0.0, 0.09248576989263226, 0.8160498218131407,
0.17389442853722373, 0.7956044195067877],
[0, 12, 10, 17, -26]),
(np.double, [0.0, 0.031066908499895136, 0.5214135908877832,
0.45780736035689296, 0.5906586745934036],
[0, -801, 51, 194, -653]),
pytest.param(
np.longdouble,
[0.0, 0.20492557202724854, 0.4277180662199366, 0.9888085019891495,
0.9620175814461964],
[0, -7400, 14266, -7822, -8721],
marks=[
pytest.mark.skipif(
np.finfo(np.double) == np.finfo(np.longdouble),
reason="long double is same as double"),
pytest.mark.skipif(
platform.machine().startswith("ppc"),
reason="IBM double double"),
]
)
])
def test_roundtrip(self, ftype, frac_vals, exp_vals):
for frac, exp in zip(frac_vals, exp_vals):
f = np.ldexp(frac, exp, dtype=ftype)
n, d = f.as_integer_ratio()
try:
# workaround for gh-9968
nf = np.longdouble(str(n))
df = np.longdouble(str(d))
except (OverflowError, RuntimeWarning):
# the values may not fit in any float type
pytest.skip("longdouble too small on this platform")
> assert_equal(nf / df, f, "{}/{}".format(n, d))
E AssertionError:
E Items are not equal:
E
3691610919282409/754375680691097236033584094668765944067705441889753674869485796085770092515607327880959819087415077310180831709250071778801287977936115798436742371143992368453309871339424824507370309612423991424025874726454403135880239672556286954660294121782394806511373424058465039879202642605192131185743309561773056658185643547491539724788761769210570449719361033472835592719630976282559609730666069011705207542835117783529456159976771068263443230862911070356085655512183568229525202212897582406915374431067163048920606924662447046633826157512843858040924984315002169964536919904833881600804823521998389050496201243764285020447088741911345402883776356409423618880520468699696461129565113383915078637888733348216610096416629009182140275042468304535253989090448531420190513342250077305957003590418954211756405910688496208336958811080736128883827111614802254709920609202253178469621573457448759462719349118711156981864214570260508501086198368460193729395300772852011148550274868441005428390349180473804178677855504742682719953569150709524928692141975992287146458274133866411756809197929729769982812952002538493837333502552947090842216481359257075037724248961524397639883688816153646148628194727053307179727164298352718970844091417026255969094016476863206390918289333298449771866559630416885921333953743755493548839734888473604855021779585195333732043601711181668030053412580029770776192004858284404501049116419958516004280221863344539130718890716799847298773006561233919104469517725028712116182966271984150326053820625659202133419895341643186410353978237088665855990317609669897114719909146571036161198418024588113758379810073902705587813521979935291050562779838944606837754397025785661345639033424453056427885477427402278247912504082637379955585065327609406091875295801383271067322140033858622268255767636731544112870609623732470608795732545842544909415005476326698182515362320822724958131487825195570623952649884606742148812903910210714982986036413200478042831492804684264633275837769140282453505276667858585847988388110379917363524869040482763991338620804822859199828168115455114341494723055337599462542402834637455880078429265889822008874978612108568914036745145011041758569845539707668192653549132816696385729078204249119162383710467822172412843323817984
E ACTUAL: 0.0
E DESIRED: 4.8935974657884746723709777503783506e-2229
d = 754375680691097236...2172412843323817984
df = inf
exp = -7400
exp_vals = [0, -7400, 14266, -7822, -8721]
f = 4.8935974657884746723709777503783506e-2229
frac = 0.20492557202724854
frac_vals = [0.0, 0.20492557202724854, 0.4277180662199366, 0.9888085019891495,
0.9620175814461964]
ftype = <class 'numpy.float128'>
n = 3691610919282409
nf = 3691610919282409.0
self = <numpy.core.tests.test_scalar_methods.TestAsIntegerRatio object at
0x1a7d93d340>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_scalar_methods.py:103:
AssertionError
____________________ TestRealScalars.test_dragon4_interface ____________________
self = <numpy.core.tests.test_scalarprint.TestRealScalars object at
0x1a642b8280>
def test_dragon4_interface(self):
tps = [np.float16, np.float32, np.float64]
if hasattr(np, 'float128'):
tps.append(np.float128)
fpos = np.format_float_positional
fsci = np.format_float_scientific
for tp in tps:
# test padding
assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), " 1. ")
assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), " -1. ")
> assert_equal(fpos(tp('-10.2'),
pad_left=4, pad_right=4), " -10.2 ")
E AssertionError:
E Items are not equal:
E ACTUAL: ' -10.199999999999999289457264239899814'
E DESIRED: ' -10.2 '
fpos = <function format_float_positional at 0x1a6cd81940>
fsci = <function format_float_scientific at 0x1a6cd818b0>
self = <numpy.core.tests.test_scalarprint.TestRealScalars object at
0x1a642b8280>
tp = <class 'numpy.float128'>
tps = [<class 'numpy.float16'>, <class 'numpy.float32'>, <class
'numpy.float64'>, <class 'numpy.float128'>]
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_scalarprint.py:217:
AssertionError
_______ TestUfuncGenericLoops.test_unary_PyUFunc_O_O_method_full[ufunc2] _______
self = <numpy.core.tests.test_ufunc.TestUfuncGenericLoops object at
0x1b1c9da970>
ufunc = <ufunc 'arccosh'>
@pytest.mark.parametrize("ufunc", UNARY_OBJECT_UFUNCS)
def test_unary_PyUFunc_O_O_method_full(self, ufunc):
"""Compare the result of the object loop with non-object one"""
val = np.float64(np.pi/4)
class MyFloat(np.float64):
def __getattr__(self, attr):
try:
return super().__getattr__(attr)
except AttributeError:
return lambda: getattr(np.core.umath, attr)(val)
num_arr = np.array([val], dtype=np.float64)
obj_arr = np.array([MyFloat(val)], dtype="O")
with np.errstate(all="raise"):
try:
res_num = ufunc(num_arr)
except Exception as exc:
with assert_raises(type(exc)):
ufunc(obj_arr)
else:
res_obj = ufunc(obj_arr)
> assert_array_equal(res_num.astype("O"), res_obj)
E AssertionError:
E Arrays are not equal
E
E Mismatched elements: 1 / 1 (100%)
E Max absolute difference: nan
E Max relative difference: nan
E x: array([nan], dtype=object)
E y: array([nan], dtype=object)
MyFloat = <class
'numpy.core.tests.test_ufunc.TestUfuncGenericLoops.test_unary_PyUFunc_O_O_method_full.<locals>.MyFloat'>
num_arr = array([0.78539816])
obj_arr = array([0.7853981633974483], dtype=object)
res_num = array([nan])
res_obj = array([nan], dtype=object)
self = <numpy.core.tests.test_ufunc.TestUfuncGenericLoops object at
0x1b1c9da970>
ufunc = <ufunc 'arccosh'>
val = 0.7853981633974483
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_ufunc.py:177:
AssertionError
______________________________ TestUfunc.test_sum ______________________________
self = <numpy.core.tests.test_ufunc.TestUfunc object at 0x1b1c9c00a0>
def test_sum(self):
for dt in (int, np.float16, np.float32, np.float64, np.longdouble):
for v in (0, 1, 2, 7, 8, 9, 15, 16, 19, 127,
128, 1024, 1235):
tgt = dt(v * (v + 1) / 2)
d = np.arange(1, v + 1, dtype=dt)
# warning if sum overflows, which it does in float16
overflow = not np.isfinite(tgt)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
assert_almost_equal(np.sum(d), tgt)
> assert_equal(len(w), 1 * overflow)
E AssertionError:
E Items are not equal:
E ACTUAL: 0
E DESIRED: 1
d = array([1.000e+00, 2.000e+00, 3.000e+00, ..., 1.022e+03, 1.023e+03,
1.024e+03], dtype=float16)
dt = <class 'numpy.float16'>
overflow = True
self = <numpy.core.tests.test_ufunc.TestUfunc object at 0x1b1c9c00a0>
tgt = inf
v = 1024
w = []
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_ufunc.py:515:
AssertionError
__________________________ TestLog2.test_log2_special __________________________
self = <numpy.core.tests.test_umath.TestLog2 object at 0x1a6208d820>
def test_log2_special(self):
assert_equal(np.log2(1.), 0.)
assert_equal(np.log2(np.inf), np.inf)
assert_(np.isnan(np.log2(np.nan)))
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings('always', '', RuntimeWarning)
assert_(np.isnan(np.log2(-1.)))
assert_(np.isnan(np.log2(-np.inf)))
assert_equal(np.log2(0.), -np.inf)
> assert_(w[0].category is RuntimeWarning)
E IndexError: list index out of range
self = <numpy.core.tests.test_umath.TestLog2 object at 0x1a6208d820>
w = []
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:586:
IndexError
______________________ TestSpecialFloats.test_exp_values _______________________
self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0x1a6208deb0>
def test_exp_values(self):
x = [np.nan, np.nan, np.inf, 0.]
y = [np.nan, -np.nan, np.inf, -np.inf]
for dt in ['f', 'd', 'g']:
xf = np.array(x, dtype=dt)
yf = np.array(y, dtype=dt)
assert_equal(np.exp(yf), xf)
with np.errstate(over='raise'):
> assert_raises(FloatingPointError, np.exp, np.float32(100.))
dt = 'g'
self = <numpy.core.tests.test_umath.TestSpecialFloats object at
0x1a6208deb0>
x = [nan, nan, inf, 0.0]
xf = array([nan, nan, inf, 0.], dtype=float128)
y = [nan, nan, inf, -inf]
yf = array([ nan, nan, inf, -inf], dtype=float128)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:690:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1a6208dfa0>
standardMsg = 'FloatingPointError not raised by exp'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: FloatingPointError not raised by exp
msg = 'FloatingPointError not raised by exp'
self = <unittest.case._AssertRaisesContext object at 0x1a6208dfa0>
standardMsg = 'FloatingPointError not raised by exp'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
______________________ TestSpecialFloats.test_log_values _______________________
self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0x1a94b08790>
def test_log_values(self):
with np.errstate(all='ignore'):
x = [np.nan, np.nan, np.inf, np.nan, -np.inf, np.nan]
y = [np.nan, -np.nan, np.inf, -np.inf, 0., -1.0]
for dt in ['f', 'd', 'g']:
xf = np.array(x, dtype=dt)
yf = np.array(y, dtype=dt)
assert_equal(np.log(yf), xf)
with np.errstate(divide='raise'):
> assert_raises(FloatingPointError, np.log, np.float32(0.))
dt = 'g'
self = <numpy.core.tests.test_umath.TestSpecialFloats object at
0x1a94b08790>
x = [nan, nan, inf, nan, -inf, nan]
xf = array([ nan, nan, inf, nan, -inf, nan], dtype=float128)
y = [nan, nan, inf, -inf, 0.0, -1.0]
yf = array([ nan, nan, inf, -inf, 0., -1.], dtype=float128)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:705:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1a94b08730>
standardMsg = 'FloatingPointError not raised by log'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: FloatingPointError not raised by log
msg = 'FloatingPointError not raised by log'
self = <unittest.case._AssertRaisesContext object at 0x1a94b08730>
standardMsg = 'FloatingPointError not raised by log'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________________ TestSpecialFloats.test_sincos_values _____________________
self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0x1a94b08be0>
def test_sincos_values(self):
with np.errstate(all='ignore'):
x = [np.nan, np.nan, np.nan, np.nan]
y = [np.nan, -np.nan, np.inf, -np.inf]
for dt in ['f', 'd', 'g']:
xf = np.array(x, dtype=dt)
yf = np.array(y, dtype=dt)
assert_equal(np.sin(yf), xf)
assert_equal(np.cos(yf), xf)
with np.errstate(invalid='raise'):
> assert_raises(FloatingPointError, np.sin, np.float32(-np.inf))
dt = 'g'
self = <numpy.core.tests.test_umath.TestSpecialFloats object at
0x1a94b08be0>
x = [nan, nan, nan, nan]
xf = array([nan, nan, nan, nan], dtype=float128)
y = [nan, nan, inf, -inf]
yf = array([ nan, nan, inf, -inf], dtype=float128)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:727:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1a94b08b50>
standardMsg = 'FloatingPointError not raised by sin'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: FloatingPointError not raised by sin
msg = 'FloatingPointError not raised by sin'
self = <unittest.case._AssertRaisesContext object at 0x1a94b08b50>
standardMsg = 'FloatingPointError not raised by sin'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________________ TestSpecialFloats.test_square_values _____________________
self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0x1b36cbc3a0>
def test_square_values(self):
x = [np.nan, np.nan, np.inf, np.inf]
y = [np.nan, -np.nan, np.inf, -np.inf]
with np.errstate(all='ignore'):
for dt in ['f', 'd', 'g']:
xf = np.array(x, dtype=dt)
yf = np.array(y, dtype=dt)
assert_equal(np.square(yf), xf)
with np.errstate(over='raise'):
> assert_raises(FloatingPointError, np.square, np.array(1E32,
> dtype='f'))
dt = 'g'
self = <numpy.core.tests.test_umath.TestSpecialFloats object at
0x1b36cbc3a0>
x = [nan, nan, inf, inf]
xf = array([nan, nan, inf, inf], dtype=float128)
y = [nan, nan, inf, -inf]
yf = array([ nan, nan, inf, -inf], dtype=float128)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:763:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b36cbc5b0>
standardMsg = 'FloatingPointError not raised by square'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: FloatingPointError not raised by square
msg = 'FloatingPointError not raised by square'
self = <unittest.case._AssertRaisesContext object at 0x1b36cbc5b0>
standardMsg = 'FloatingPointError not raised by square'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
___________________ TestSpecialFloats.test_reciprocal_values ___________________
self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0x1b36cbca90>
def test_reciprocal_values(self):
with np.errstate(all='ignore'):
x = [np.nan, np.nan, 0.0, -0.0, np.inf, -np.inf]
y = [np.nan, -np.nan, np.inf, -np.inf, 0., -0.]
for dt in ['f', 'd', 'g']:
xf = np.array(x, dtype=dt)
yf = np.array(y, dtype=dt)
assert_equal(np.reciprocal(yf), xf)
with np.errstate(divide='raise'):
for dt in ['f', 'd', 'g']:
> assert_raises(FloatingPointError, np.reciprocal, np.array(-0.0,
> dtype=dt))
dt = 'f'
self = <numpy.core.tests.test_umath.TestSpecialFloats object at
0x1b36cbca90>
x = [nan, nan, 0.0, -0.0, inf, -inf]
xf = array([ nan, nan, 0., -0., inf, -inf], dtype=float128)
y = [nan, nan, inf, -inf, 0.0, -0.0]
yf = array([ nan, nan, inf, -inf, 0., -0.], dtype=float128)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:777:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b36cbce20>
standardMsg = 'FloatingPointError not raised by reciprocal'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: FloatingPointError not raised by reciprocal
msg = 'FloatingPointError not raised by reciprocal'
self = <unittest.case._AssertRaisesContext object at 0x1b36cbce20>
standardMsg = 'FloatingPointError not raised by reciprocal'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
______________________ TestAVXUfuncs.test_avx_based_ufunc ______________________
self = <numpy.core.tests.test_umath.TestAVXUfuncs object at 0x1b083bb490>
def test_avx_based_ufunc(self):
strides = np.array([-4,-3,-2,-1,1,2,3,4])
np.random.seed(42)
for func, prop in avx_ufuncs.items():
maxulperr = prop[0]
minval = prop[1]
maxval = prop[2]
# various array sizes to ensure masking in AVX is tested
for size in range(1,32):
myfunc = getattr(np, func)
x_f32 = np.float32(np.random.uniform(low=minval, high=maxval,
size=size))
x_f64 = np.float64(x_f32)
x_f128 = np.longdouble(x_f32)
y_true128 = myfunc(x_f128)
if maxulperr == 0:
assert_equal(myfunc(x_f32), np.float32(y_true128))
assert_equal(myfunc(x_f64), np.float64(y_true128))
else:
assert_array_max_ulp(myfunc(x_f32), np.float32(y_true128),
maxulp=maxulperr)
> assert_array_max_ulp(myfunc(x_f64), np.float64(y_true128),
maxulp=maxulperr)
E AssertionError: Arrays are not almost equal up to 1 ULP
(max difference is 8 ULP)
func = 'sqrt'
maxulperr = 1
maxval = 100.0
minval = 0.0
myfunc = <ufunc 'sqrt'>
prop = [1, 0.0, 100.0]
self = <numpy.core.tests.test_umath.TestAVXUfuncs object at 0x1b083bb490>
size = 2
strides = array([-4, -3, -2, -1, 1, 2, 3, 4])
x_f128 = array([95.07143402, 73.19939423], dtype=float128)
x_f32 = array([95.071434, 73.199394], dtype=float32)
x_f64 = array([95.07143402, 73.19939423])
y_true128 = array([9.75045814, 8.55566445], dtype=float128)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:811:
AssertionError
_______________ TestAVXFloat32Transcendental.test_sincos_float32 _______________
self = <numpy.core.tests.test_umath.TestAVXFloat32Transcendental object at
0x1a93e26970>
def test_sincos_float32(self):
np.random.seed(42)
N = 1000000
M = np.int_(N/20)
index = np.random.randint(low=0, high=N, size=M)
x_f32 = np.float32(np.random.uniform(low=-100.,high=100.,size=N))
# test coverage for elements > 117435.992f for which glibc is used
x_f32[index] = np.float32(10E+10*np.random.rand(M))
x_f64 = np.float64(x_f32)
> assert_array_max_ulp(np.sin(x_f32), np.float32(np.sin(x_f64)), maxulp=2)
E AssertionError: Arrays are not almost equal up to 2 ULP (max difference
is 67 ULP)
M = 50000
N = 1000000
index = array([121958, 671155, 131932, ..., 738271, 310195, 233966])
self = <numpy.core.tests.test_umath.TestAVXFloat32Transcendental object
at 0x1a93e26970>
x_f32 = array([-10.577719, -35.353283, -97.29114 , ..., -80.99214 ,
-42.875526,
-87.8052 ], dtype=float32)
x_f64 = array([-10.57771873, -35.35328293, -97.2911377 , ..., -80.99214172,
-42.87552643, -87.80519867])
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:843:
AssertionError
_______________ TestComplexFunctions.test_precisions_consistent ________________
actual =
(1.0612750619050375271103744084046337+0.9045568943023814371944297819484702j)
desired = (1.0612750619050357+0.9045568943023814j), decimal = 15
err_msg = "fch-fcl <ufunc 'arccosh'>", verbose = True
def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True):
"""
Raises an AssertionError if two items are not equal up to desired
precision.
.. note:: It is recommended to use one of `assert_allclose`,
`assert_array_almost_equal_nulp` or `assert_array_max_ulp`
instead of this function for more consistent floating point
comparisons.
The test verifies that the elements of ``actual`` and ``desired``
satisfy.
``abs(desired-actual) < 1.5 * 10**(-decimal)``
That is a looser test than originally documented, but agrees with what
the
actual implementation in `assert_array_almost_equal` did up to rounding
vagaries. An exception is raised at conflicting values. For ndarrays
this
delegates to assert_array_almost_equal
Parameters
----------
actual : array_like
The object to check.
desired : array_like
The expected object.
decimal : int, optional
Desired precision, default is 7.
err_msg : str, optional
The error message to be printed in case of failure.
verbose : bool, optional
If True, the conflicting values are appended to the error message.
Raises
------
AssertionError
If actual and desired are not equal up to specified precision.
See Also
--------
assert_allclose: Compare two array_like objects for equality with
desired
relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
Examples
--------
>>> import numpy.testing as npt
>>> npt.assert_almost_equal(2.3333333333333, 2.33333334)
>>> npt.assert_almost_equal(2.3333333333333, 2.33333334, decimal=10)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 10 decimals
ACTUAL: 2.3333333333333
DESIRED: 2.33333334
>>> npt.assert_almost_equal(np.array([1.0,2.3333333333333]),
... np.array([1.0,2.33333334]), decimal=9)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 9 decimals
<BLANKLINE>
Mismatched elements: 1 / 2 (50%)
Max absolute difference: 6.66669964e-09
Max relative difference: 2.85715698e-09
x: array([1. , 2.333333333])
y: array([1. , 2.33333334])
"""
__tracebackhide__ = True # Hide traceback for py.test
from numpy.core import ndarray
from numpy.lib import iscomplexobj, real, imag
# Handle complex numbers: separate into real/imag to handle
# nan/inf/negative zero correctly
# XXX: catch ValueError for subclasses of ndarray where iscomplex fail
try:
usecomplex = iscomplexobj(actual) or iscomplexobj(desired)
except ValueError:
usecomplex = False
def _build_err_msg():
header = ('Arrays are not almost equal to %d decimals' % decimal)
return build_err_msg([actual, desired], err_msg, verbose=verbose,
header=header)
if usecomplex:
if iscomplexobj(actual):
actualr = real(actual)
actuali = imag(actual)
else:
actualr = actual
actuali = 0
if iscomplexobj(desired):
desiredr = real(desired)
desiredi = imag(desired)
else:
desiredr = desired
desiredi = 0
try:
> assert_almost_equal(actualr, desiredr, decimal=decimal)
__tracebackhide__ = True
_build_err_msg = <function assert_almost_equal.<locals>._build_err_msg at
0x1abf111310>
actual =
(1.0612750619050375271103744084046337+0.9045568943023814371944297819484702j)
actuali = 0.9045568943023814371944297819484702
actualr = 1.0612750619050375271103744084046337
decimal = 15
desired = (1.0612750619050357+0.9045568943023814j)
desiredi = 0.9045568943023814
desiredr = 1.0612750619050357
err_msg = "fch-fcl <ufunc 'arccosh'>"
imag = <function imag at 0x1adf886a60>
iscomplexobj = <function iscomplexobj at 0x1adf886e50>
ndarray = <class 'numpy.ndarray'>
real = <function real at 0x1adf8868b0>
usecomplex = True
verbose = True
/usr/local/lib/python3.8/site-packages/numpy/testing/_private/utils.py:572:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
actual = 1.0612750619050375271103744084046337, desired = 1.0612750619050357
decimal = 15, err_msg = '', verbose = True
def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True):
"""
Raises an AssertionError if two items are not equal up to desired
precision.
.. note:: It is recommended to use one of `assert_allclose`,
`assert_array_almost_equal_nulp` or `assert_array_max_ulp`
instead of this function for more consistent floating point
comparisons.
The test verifies that the elements of ``actual`` and ``desired``
satisfy.
``abs(desired-actual) < 1.5 * 10**(-decimal)``
That is a looser test than originally documented, but agrees with what
the
actual implementation in `assert_array_almost_equal` did up to rounding
vagaries. An exception is raised at conflicting values. For ndarrays
this
delegates to assert_array_almost_equal
Parameters
----------
actual : array_like
The object to check.
desired : array_like
The expected object.
decimal : int, optional
Desired precision, default is 7.
err_msg : str, optional
The error message to be printed in case of failure.
verbose : bool, optional
If True, the conflicting values are appended to the error message.
Raises
------
AssertionError
If actual and desired are not equal up to specified precision.
See Also
--------
assert_allclose: Compare two array_like objects for equality with
desired
relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
Examples
--------
>>> import numpy.testing as npt
>>> npt.assert_almost_equal(2.3333333333333, 2.33333334)
>>> npt.assert_almost_equal(2.3333333333333, 2.33333334, decimal=10)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 10 decimals
ACTUAL: 2.3333333333333
DESIRED: 2.33333334
>>> npt.assert_almost_equal(np.array([1.0,2.3333333333333]),
... np.array([1.0,2.33333334]), decimal=9)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 9 decimals
<BLANKLINE>
Mismatched elements: 1 / 2 (50%)
Max absolute difference: 6.66669964e-09
Max relative difference: 2.85715698e-09
x: array([1. , 2.333333333])
y: array([1. , 2.33333334])
"""
__tracebackhide__ = True # Hide traceback for py.test
from numpy.core import ndarray
from numpy.lib import iscomplexobj, real, imag
# Handle complex numbers: separate into real/imag to handle
# nan/inf/negative zero correctly
# XXX: catch ValueError for subclasses of ndarray where iscomplex fail
try:
usecomplex = iscomplexobj(actual) or iscomplexobj(desired)
except ValueError:
usecomplex = False
def _build_err_msg():
header = ('Arrays are not almost equal to %d decimals' % decimal)
return build_err_msg([actual, desired], err_msg, verbose=verbose,
header=header)
if usecomplex:
if iscomplexobj(actual):
actualr = real(actual)
actuali = imag(actual)
else:
actualr = actual
actuali = 0
if iscomplexobj(desired):
desiredr = real(desired)
desiredi = imag(desired)
else:
desiredr = desired
desiredi = 0
try:
assert_almost_equal(actualr, desiredr, decimal=decimal)
assert_almost_equal(actuali, desiredi, decimal=decimal)
except AssertionError:
raise AssertionError(_build_err_msg())
if isinstance(actual, (ndarray, tuple, list)) \
or isinstance(desired, (ndarray, tuple, list)):
return assert_array_almost_equal(actual, desired, decimal, err_msg)
try:
# If one of desired/actual is not finite, handle it specially here:
# check that both are nan if any is a nan, and test for equality
# otherwise
if not (gisfinite(desired) and gisfinite(actual)):
if gisnan(desired) or gisnan(actual):
if not (gisnan(desired) and gisnan(actual)):
raise AssertionError(_build_err_msg())
else:
if not desired == actual:
raise AssertionError(_build_err_msg())
return
except (NotImplementedError, TypeError):
pass
if abs(desired - actual) >= 1.5 * 10.0**(-decimal):
> raise AssertionError(_build_err_msg())
E AssertionError:
E Arrays are not almost equal to 15 decimals
E ACTUAL: 1.0612750619050375271103744084046337
E DESIRED: 1.0612750619050357
__tracebackhide__ = True
_build_err_msg = <function assert_almost_equal.<locals>._build_err_msg at
0x1aa2241940>
actual = 1.0612750619050375271103744084046337
decimal = 15
desired = 1.0612750619050357
err_msg = ''
imag = <function imag at 0x1adf886a60>
iscomplexobj = <function iscomplexobj at 0x1adf886e50>
ndarray = <class 'numpy.ndarray'>
real = <function real at 0x1adf8868b0>
usecomplex = False
verbose = True
/usr/local/lib/python3.8/site-packages/numpy/testing/_private/utils.py:595:
AssertionError
During handling of the above exception, another exception occurred:
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x1a93e26280>
def test_precisions_consistent(self):
z = 1 + 1j
for f in self.funcs:
fcf = f(np.csingle(z))
fcd = f(np.cdouble(z))
fcl = f(np.clongdouble(z))
assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s' % f)
> assert_almost_equal(fcl, fcd, decimal=15, err_msg='fch-fcl %s' % f)
E AssertionError:
E Arrays are not almost equal to 15 decimals fch-fcl <ufunc 'arccosh'>
E ACTUAL:
(1.0612750619050375271103744084046337+0.9045568943023814371944297819484702j)
E DESIRED: (1.0612750619050357+0.9045568943023814j)
f = <ufunc 'arccosh'>
fcd = (1.0612750619050357+0.9045568943023814j)
fcf = (1.0612751+0.9045569j)
fcl =
(1.0612750619050375271103744084046337+0.9045568943023814371944297819484702j)
self = <numpy.core.tests.test_umath.TestComplexFunctions object at
0x1a93e26280>
z = (1+1j)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2745:
AssertionError
____________________ TestComplexFunctions.test_branch_cuts _____________________
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x1a603d13a0>
def test_branch_cuts(self):
# check branch cuts and continuity on them
_check_branch_cut(np.log, -0.5, 1j, 1, -1, True)
_check_branch_cut(np.log2, -0.5, 1j, 1, -1, True)
_check_branch_cut(np.log10, -0.5, 1j, 1, -1, True)
_check_branch_cut(np.log1p, -1.5, 1j, 1, -1, True)
_check_branch_cut(np.sqrt, -0.5, 1j, 1, -1, True)
_check_branch_cut(np.arcsin, [ -2, 2], [1j, 1j], 1, -1, True)
_check_branch_cut(np.arccos, [ -2, 2], [1j, 1j], 1, -1, True)
> _check_branch_cut(np.arctan, [0-2j, 2j], [1, 1], -1, 1, True)
self = <numpy.core.tests.test_umath.TestComplexFunctions object at
0x1a603d13a0>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2757:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
f = <ufunc 'arctan'>, x0 = array([0.-2.j, 0.+2.j]), dx = array([1.+0.j, 1.+0.j])
re_sign = -1, im_sign = 1, sig_zero_ok = True, dtype = <class 'complex'>
def _check_branch_cut(f, x0, dx, re_sign=1, im_sign=-1, sig_zero_ok=False,
dtype=complex):
"""
Check for a branch cut in a function.
Assert that `x0` lies on a branch cut of function `f` and `f` is
continuous from the direction `dx`.
Parameters
----------
f : func
Function to check
x0 : array-like
Point on branch cut
dx : array-like
Direction to check continuity in
re_sign, im_sign : {1, -1}
Change of sign of the real or imaginary part expected
sig_zero_ok : bool
Whether to check if the branch cut respects signed zero (if
applicable)
dtype : dtype
Dtype to check (should be complex)
"""
x0 = np.atleast_1d(x0).astype(dtype)
dx = np.atleast_1d(dx).astype(dtype)
if np.dtype(dtype).char == 'F':
scale = np.finfo(dtype).eps * 1e2
atol = np.float32(1e-2)
else:
scale = np.finfo(dtype).eps * 1e3
atol = 1e-4
y0 = f(x0)
yp = f(x0 + dx*scale*np.absolute(x0)/np.absolute(dx))
ym = f(x0 - dx*scale*np.absolute(x0)/np.absolute(dx))
> assert_(np.all(np.absolute(y0.real - yp.real) < atol), (y0, yp))
E AssertionError: (array([-1.57079633e+000-5.49306144e-001j,
E 1.00000000e+308+1.00000000e+308j]),
array([1.57079633-0.54930614j, 1.57079633+0.54930614j]))
atol = 0.0001
dtype = <class 'complex'>
dx = array([1.+0.j, 1.+0.j])
f = <ufunc 'arctan'>
im_sign = 1
re_sign = -1
scale = 2.220446049250313e-13
sig_zero_ok = True
x0 = array([0.-2.j, 0.+2.j])
y0 = array([-1.57079633e+000-5.49306144e-001j,
1.00000000e+308+1.00000000e+308j])
ym = array([-1.57079633-0.54930614j, -1.57079633+0.54930614j])
yp = array([1.57079633-0.54930614j, 1.57079633+0.54930614j])
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:3002:
AssertionError
_______________ TestComplexFunctions.test_branch_cuts_complex64 ________________
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x1a603ad940>
def test_branch_cuts_complex64(self):
# check branch cuts and continuity on them
_check_branch_cut(np.log, -0.5, 1j, 1, -1, True, np.complex64)
_check_branch_cut(np.log2, -0.5, 1j, 1, -1, True, np.complex64)
_check_branch_cut(np.log10, -0.5, 1j, 1, -1, True, np.complex64)
_check_branch_cut(np.log1p, -1.5, 1j, 1, -1, True, np.complex64)
_check_branch_cut(np.sqrt, -0.5, 1j, 1, -1, True, np.complex64)
_check_branch_cut(np.arcsin, [ -2, 2], [1j, 1j], 1, -1, True,
np.complex64)
_check_branch_cut(np.arccos, [ -2, 2], [1j, 1j], 1, -1, True,
np.complex64)
> _check_branch_cut(np.arctan, [0-2j, 2j], [1, 1], -1, 1, True,
> np.complex64)
self = <numpy.core.tests.test_umath.TestComplexFunctions object at
0x1a603ad940>
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2782:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
f = <ufunc 'arctan'>, x0 = array([0.-2.j, 0.+2.j], dtype=complex64)
dx = array([1.+0.j, 1.+0.j], dtype=complex64), re_sign = -1, im_sign = 1
sig_zero_ok = True, dtype = <class 'numpy.complex64'>
def _check_branch_cut(f, x0, dx, re_sign=1, im_sign=-1, sig_zero_ok=False,
dtype=complex):
"""
Check for a branch cut in a function.
Assert that `x0` lies on a branch cut of function `f` and `f` is
continuous from the direction `dx`.
Parameters
----------
f : func
Function to check
x0 : array-like
Point on branch cut
dx : array-like
Direction to check continuity in
re_sign, im_sign : {1, -1}
Change of sign of the real or imaginary part expected
sig_zero_ok : bool
Whether to check if the branch cut respects signed zero (if
applicable)
dtype : dtype
Dtype to check (should be complex)
"""
x0 = np.atleast_1d(x0).astype(dtype)
dx = np.atleast_1d(dx).astype(dtype)
if np.dtype(dtype).char == 'F':
scale = np.finfo(dtype).eps * 1e2
atol = np.float32(1e-2)
else:
scale = np.finfo(dtype).eps * 1e3
atol = 1e-4
y0 = f(x0)
yp = f(x0 + dx*scale*np.absolute(x0)/np.absolute(dx))
ym = f(x0 - dx*scale*np.absolute(x0)/np.absolute(dx))
> assert_(np.all(np.absolute(y0.real - yp.real) < atol), (y0, yp))
E AssertionError: (array([-1.5707964e+00-5.4930615e-01j,
9.9999997e+37+9.9999997e+37j],
E dtype=complex64), array([1.5707884-0.54930615j,
1.5707884+0.54930615j], dtype=complex64))
atol = 0.01
dtype = <class 'numpy.complex64'>
dx = array([1.+0.j, 1.+0.j], dtype=complex64)
f = <ufunc 'arctan'>
im_sign = 1
re_sign = -1
scale = 1.1920928955078125e-05
sig_zero_ok = True
x0 = array([0.-2.j, 0.+2.j], dtype=complex64)
y0 = array([-1.5707964e+00-5.4930615e-01j,
9.9999997e+37+9.9999997e+37j],
dtype=complex64)
ym = array([-1.5707884-0.54930615j, -1.5707884+0.54930615j],
dtype=complex64)
yp = array([1.5707884-0.54930615j, 1.5707884+0.54930615j],
dtype=complex64)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:3002:
AssertionError
____________ TestComplexFunctions.test_loss_of_precision[complex64] ____________
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x1b3456b910>
dtype = <class 'numpy.complex64'>
@pytest.mark.parametrize('dtype', [np.complex64, np.complex_,
np.longcomplex])
def test_loss_of_precision(self, dtype):
"""Check loss of precision in complex arc* functions"""
# Check against known-good functions
info = np.finfo(dtype)
real_dtype = dtype(0.).real.dtype
eps = info.eps
def check(x, rtol):
x = x.astype(real_dtype)
z = x.astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsinh'))
z = (1j*x).astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsin(z).imag - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsin'))
z = x.astype(dtype)
d = np.absolute(np.arctanh(x)/np.arctanh(z).real - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arctanh'))
z = (1j*x).astype(dtype)
d = np.absolute(np.arctanh(x)/np.arctan(z).imag - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arctan'))
# The switchover was chosen as 1e-3; hence there can be up to
# ~eps/1e-3 of relative cancellation error before it
x_series = np.logspace(-20, -3.001, 200)
x_basic = np.logspace(-2.999, 0, 10, endpoint=False)
if dtype is np.longcomplex:
# It's not guaranteed that the system-provided arc functions
# are accurate down to a few epsilons. (Eg. on Linux 64-bit)
# So, give more leeway for long complex tests here:
# Can use 2.1 for > Ubuntu LTS Trusty (2014), glibc = 2.19.
if skip_longcomplex_msg:
pytest.skip(skip_longcomplex_msg)
check(x_series, 50.0*eps)
else:
> check(x_series, 2.1*eps)
check = <function
TestComplexFunctions.test_loss_of_precision.<locals>.check at 0x1abf1113a0>
dtype = <class 'numpy.complex64'>
eps = 1.1920929e-07
info = finfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38,
dtype=float32)
real_dtype = dtype('float32')
self = <numpy.core.tests.test_umath.TestComplexFunctions object at
0x1b3456b910>
x_basic = array([0.00100231, 0.0019994 , 0.00398841, 0.0079561 , 0.01587084,
0.0316592 , 0.06315387, 0.12597953, 0.25130435, 0.50130265])
x_series = array([1.00000000e-20, 1.21736864e-20, 1.48198641e-20,
1.80412378e-20,
2.19628372e-20, 2.67368693e-20, 3.254862...3.06526013e-04,
3.73155156e-04, 4.54267386e-04,
5.53010871e-04, 6.73218092e-04, 8.19554595e-04, 9.97700064e-04])
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2864:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = array([9.99999968e-21, 1.21736865e-20, 1.48198648e-20, 1.80412373e-20,
2.19628376e-20, 2.67368701e-20, 3.254862...55170e-04, 4.54267400e-04,
5.53010846e-04, 6.73218106e-04, 8.19554611e-04, 9.97700030e-04],
dtype=float32)
rtol = 2.5033950805664064e-07
def check(x, rtol):
x = x.astype(real_dtype)
z = x.astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
> assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsinh'))
E AssertionError: (0, 1e-20, inf, 'arcsinh')
d = array([ inf, inf, inf,
inf,
inf, inf, ...17506e-04, 8.02278519e-05,
6.28232956e-05, 6.73532486e-06, 1.53779984e-05, 4.31537628e-05],
dtype=float32)
dtype = <class 'numpy.complex64'>
real_dtype = dtype('float32')
rtol = 2.5033950805664064e-07
x = array([9.99999968e-21, 1.21736865e-20, 1.48198648e-20,
1.80412373e-20,
2.19628376e-20, 2.67368701e-20, 3.254862...55170e-04, 4.54267400e-04,
5.53010846e-04, 6.73218106e-04, 8.19554611e-04, 9.97700030e-04],
dtype=float32)
z = array([9.99999968e-21+0.j, 1.21736865e-20+0.j, 1.48198648e-20+0.j,
1.80412373e-20+0.j, 2.19628376e-20+0.j, 2.67...67400e-04+0.j,
5.53010846e-04+0.j, 6.73218106e-04+0.j,
8.19554611e-04+0.j, 9.97700030e-04+0.j], dtype=complex64)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2831:
AssertionError
___________ TestComplexFunctions.test_loss_of_precision[complex128] ____________
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x1b36cbcd30>
dtype = <class 'numpy.complex128'>
@pytest.mark.parametrize('dtype', [np.complex64, np.complex_,
np.longcomplex])
def test_loss_of_precision(self, dtype):
"""Check loss of precision in complex arc* functions"""
# Check against known-good functions
info = np.finfo(dtype)
real_dtype = dtype(0.).real.dtype
eps = info.eps
def check(x, rtol):
x = x.astype(real_dtype)
z = x.astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsinh'))
z = (1j*x).astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsin(z).imag - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsin'))
z = x.astype(dtype)
d = np.absolute(np.arctanh(x)/np.arctanh(z).real - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arctanh'))
z = (1j*x).astype(dtype)
d = np.absolute(np.arctanh(x)/np.arctan(z).imag - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arctan'))
# The switchover was chosen as 1e-3; hence there can be up to
# ~eps/1e-3 of relative cancellation error before it
x_series = np.logspace(-20, -3.001, 200)
x_basic = np.logspace(-2.999, 0, 10, endpoint=False)
if dtype is np.longcomplex:
# It's not guaranteed that the system-provided arc functions
# are accurate down to a few epsilons. (Eg. on Linux 64-bit)
# So, give more leeway for long complex tests here:
# Can use 2.1 for > Ubuntu LTS Trusty (2014), glibc = 2.19.
if skip_longcomplex_msg:
pytest.skip(skip_longcomplex_msg)
check(x_series, 50.0*eps)
else:
> check(x_series, 2.1*eps)
check = <function
TestComplexFunctions.test_loss_of_precision.<locals>.check at 0x1aa225daf0>
dtype = <class 'numpy.complex128'>
eps = 2.220446049250313e-16
info = finfo(resolution=1e-15, min=-1.7976931348623157e+308,
max=1.7976931348623157e+308, dtype=float64)
real_dtype = dtype('float64')
self = <numpy.core.tests.test_umath.TestComplexFunctions object at
0x1b36cbcd30>
x_basic = array([0.00100231, 0.0019994 , 0.00398841, 0.0079561 , 0.01587084,
0.0316592 , 0.06315387, 0.12597953, 0.25130435, 0.50130265])
x_series = array([1.00000000e-20, 1.21736864e-20, 1.48198641e-20,
1.80412378e-20,
2.19628372e-20, 2.67368693e-20, 3.254862...3.06526013e-04,
3.73155156e-04, 4.54267386e-04,
5.53010871e-04, 6.73218092e-04, 8.19554595e-04, 9.97700064e-04])
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2864:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = array([1.00000000e-20, 1.21736864e-20, 1.48198641e-20, 1.80412378e-20,
2.19628372e-20, 2.67368693e-20, 3.254862...3.06526013e-04,
3.73155156e-04, 4.54267386e-04,
5.53010871e-04, 6.73218092e-04, 8.19554595e-04, 9.97700064e-04])
rtol = 4.662936703425658e-16
def check(x, rtol):
x = x.astype(real_dtype)
z = x.astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
> assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsinh'))
E AssertionError: (0, 1.0000000000000001e-20, inf, 'arcsinh')
d = array([ inf, inf, inf,
inf,
inf, inf, ...1.10356169e-13,
5.87307980e-14, 9.10382880e-14,
9.85878046e-14, 1.76303416e-13, 2.36699549e-13, 5.06261699e-14])
dtype = <class 'numpy.complex128'>
real_dtype = dtype('float64')
rtol = 4.662936703425658e-16
x = array([1.00000000e-20, 1.21736864e-20, 1.48198641e-20,
1.80412378e-20,
2.19628372e-20, 2.67368693e-20, 3.254862...3.06526013e-04,
3.73155156e-04, 4.54267386e-04,
5.53010871e-04, 6.73218092e-04, 8.19554595e-04, 9.97700064e-04])
z = array([1.00000000e-20+0.j, 1.21736864e-20+0.j, 1.48198641e-20+0.j,
1.80412378e-20+0.j, 2.19628372e-20+0.j, 2.67...0.j,
4.54267386e-04+0.j, 5.53010871e-04+0.j, 6.73218092e-04+0.j,
8.19554595e-04+0.j, 9.97700064e-04+0.j])
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2831:
AssertionError
___________ TestComplexFunctions.test_loss_of_precision[complex256] ____________
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x1a620af490>
dtype = <class 'numpy.complex256'>
@pytest.mark.parametrize('dtype', [np.complex64, np.complex_,
np.longcomplex])
def test_loss_of_precision(self, dtype):
"""Check loss of precision in complex arc* functions"""
# Check against known-good functions
info = np.finfo(dtype)
real_dtype = dtype(0.).real.dtype
eps = info.eps
def check(x, rtol):
x = x.astype(real_dtype)
z = x.astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsinh'))
z = (1j*x).astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsin(z).imag - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsin'))
z = x.astype(dtype)
d = np.absolute(np.arctanh(x)/np.arctanh(z).real - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arctanh'))
z = (1j*x).astype(dtype)
d = np.absolute(np.arctanh(x)/np.arctan(z).imag - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arctan'))
# The switchover was chosen as 1e-3; hence there can be up to
# ~eps/1e-3 of relative cancellation error before it
x_series = np.logspace(-20, -3.001, 200)
x_basic = np.logspace(-2.999, 0, 10, endpoint=False)
if dtype is np.longcomplex:
# It's not guaranteed that the system-provided arc functions
# are accurate down to a few epsilons. (Eg. on Linux 64-bit)
# So, give more leeway for long complex tests here:
# Can use 2.1 for > Ubuntu LTS Trusty (2014), glibc = 2.19.
if skip_longcomplex_msg:
pytest.skip(skip_longcomplex_msg)
> check(x_series, 50.0*eps)
check = <function
TestComplexFunctions.test_loss_of_precision.<locals>.check at 0x1b3e14caf0>
dtype = <class 'numpy.complex256'>
eps = 1.9259299443872358530559779425849273e-34
info = finfo(resolution=1e-33,
min=-1.189731495357231765085759326628007e+4932,
max=1.189731495357231765085759326628007e+4932, dtype=float128)
real_dtype = dtype('float128')
self = <numpy.core.tests.test_umath.TestComplexFunctions object at
0x1a620af490>
x_basic = array([0.00100231, 0.0019994 , 0.00398841, 0.0079561 , 0.01587084,
0.0316592 , 0.06315387, 0.12597953, 0.25130435, 0.50130265])
x_series = array([1.00000000e-20, 1.21736864e-20, 1.48198641e-20,
1.80412378e-20,
2.19628372e-20, 2.67368693e-20, 3.254862...3.06526013e-04,
3.73155156e-04, 4.54267386e-04,
5.53010871e-04, 6.73218092e-04, 8.19554595e-04, 9.97700064e-04])
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2862:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = array([1.00000000e-20, 1.21736864e-20, 1.48198641e-20, 1.80412378e-20,
2.19628372e-20, 2.67368693e-20, 3.254862...5156e-04, 4.54267386e-04,
5.53010871e-04, 6.73218092e-04, 8.19554595e-04, 9.97700064e-04],
dtype=float128)
rtol = 9.629649721936179265279889712924637e-33
def check(x, rtol):
x = x.astype(real_dtype)
z = x.astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
> assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsinh'))
E AssertionError: (199, 0.0009977000638225535979891622773152449,
4.426258578570200775904969253094376e-19, 'arcsinh')
d = array([0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.000000...2994e-34, 2.01643610e-19,
1.92592994e-34, 2.98767642e-19, 3.63657112e-19, 4.42625858e-19],
dtype=float128)
dtype = <class 'numpy.complex256'>
real_dtype = dtype('float128')
rtol = 9.629649721936179265279889712924637e-33
x = array([1.00000000e-20, 1.21736864e-20, 1.48198641e-20,
1.80412378e-20,
2.19628372e-20, 2.67368693e-20, 3.254862...5156e-04, 4.54267386e-04,
5.53010871e-04, 6.73218092e-04, 8.19554595e-04, 9.97700064e-04],
dtype=float128)
z = array([1.00000000e-20+0.j, 1.21736864e-20+0.j, 1.48198641e-20+0.j,
1.80412378e-20+0.j, 2.19628372e-20+0.j, 2.67...7386e-04+0.j,
5.53010871e-04+0.j, 6.73218092e-04+0.j,
8.19554595e-04+0.j, 9.97700064e-04+0.j], dtype=complex256)
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_umath.py:2831:
AssertionError
__________________________ TestExecCommand.test_basic __________________________
self = <numpy.distutils.tests.test_exec_command.TestExecCommand object at
0x1b0cdba220>
def test_basic(self):
with redirect_stdout(StringIO()):
with redirect_stderr(StringIO()):
with assert_warns(DeprecationWarning):
if os.name == "posix":
> self.check_posix(use_tee=0)
self = <numpy.distutils.tests.test_exec_command.TestExecCommand object at
0x1b0cdba220>
/usr/local/lib/python3.8/site-packages/numpy/distutils/tests/test_exec_command.py:208:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <numpy.distutils.tests.test_exec_command.TestExecCommand object at
0x1b0cdba220>
kws = {'use_tee': 0}, s = 1, o = 'This account is currently not available.'
def check_posix(self, **kws):
s, o = exec_command.exec_command("echo Hello", **kws)
> assert_(s == 0)
E AssertionError
kws = {'use_tee': 0}
o = 'This account is currently not available.'
s = 1
self = <numpy.distutils.tests.test_exec_command.TestExecCommand object at
0x1b0cdba220>
/usr/local/lib/python3.8/site-packages/numpy/distutils/tests/test_exec_command.py:112:
AssertionError
____________________________ TestMedian.test_empty _____________________________
self = <numpy.lib.tests.test_function_base.TestMedian object at 0x1b21991d90>
def test_empty(self):
# mean(empty array) emits two warnings: empty slice and divide by 0
a = np.array([], dtype=float)
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings('always', '', RuntimeWarning)
assert_equal(np.median(a), np.nan)
assert_(w[0].category is RuntimeWarning)
> assert_equal(len(w), 2)
E AssertionError:
E Items are not equal:
E ACTUAL: 1
E DESIRED: 2
a = array([], dtype=float64)
self = <numpy.lib.tests.test_function_base.TestMedian object at
0x1b21991d90>
w = [<warnings.WarningMessage object at 0x1a7f9a91c0>]
/usr/local/lib/python3.8/site-packages/numpy/lib/tests/test_function_base.py:3265:
AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt0] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1b1b02e370>
dt = dtype('bool')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('bool')
mat = array([[ True, False],
[False, False]])
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1b1b02e370>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b1b02e4f0>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1b1b02e4f0>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt1] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1aba8e4760>
dt = dtype('int8')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('int8')
mat = array([[1, 0],
[0, 0]], dtype=int8)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1aba8e4760>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1aba8e4970>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1aba8e4970>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt2] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1a623b2580>
dt = dtype('uint8')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('uint8')
mat = array([[1, 0],
[0, 0]], dtype=uint8)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1a623b2580>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1a623b28b0>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1a623b28b0>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt3] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1a623b2c70>
dt = dtype('int16')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('int16')
mat = array([[1, 0],
[0, 0]], dtype=int16)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1a623b2c70>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1a623b2e50>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1a623b2e50>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt4] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1b1b0340a0>
dt = dtype('uint16')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('uint16')
mat = array([[1, 0],
[0, 0]], dtype=uint16)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1b1b0340a0>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b1b034d30>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1b1b034d30>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt5] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1ae7b72730>
dt = dtype('int32')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('int32')
mat = array([[1, 0],
[0, 0]], dtype=int32)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1ae7b72730>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1ae7b729a0>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1ae7b729a0>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt6] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1ad371d520>
dt = dtype('uint32')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('uint32')
mat = array([[1, 0],
[0, 0]], dtype=uint32)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1ad371d520>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1ad371d790>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1ad371d790>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt7] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1ae7b72a30>
dt = dtype('int64')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('int64')
mat = array([[1, 0],
[0, 0]], dtype=int64)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1ae7b72a30>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1ae7b72d30>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1ae7b72d30>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt8] ______________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1a623aa4c0>
dt = dtype('uint64')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('uint64')
mat = array([[1, 0],
[0, 0]], dtype=uint64)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1a623aa4c0>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1a623aa0d0>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1a623aa0d0>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt10] _____________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1a623aa6a0>
dt = dtype('float32')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('float32')
mat = array([[1., 0.],
[0., 0.]], dtype=float32)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1a623aa6a0>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1a623aa280>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1a623aa280>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt11] _____________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1a68dce070>
dt = dtype('float64')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('float64')
mat = array([[1., 0.],
[0., 0.]])
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1a68dce070>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1a68dce6a0>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1a68dce6a0>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt13] _____________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1aff444280>
dt = dtype('complex64')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('complex64')
mat = array([[1.+0.j, 0.+0.j],
[0.+0.j, 0.+0.j]], dtype=complex64)
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1aff444280>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1aff444970>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1aff444970>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_____________ TestMatrixPower.test_exceptions_not_invertible[dt14] _____________
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at 0x1b35c4f5b0>
dt = dtype('complex128')
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
> assert_raises(LinAlgError, matrix_power, mat, -1)
dt = dtype('complex128')
mat = array([[1.+0.j, 0.+0.j],
[0.+0.j, 0.+0.j]])
self = <numpy.linalg.tests.test_linalg.TestMatrixPower object at
0x1b35c4f5b0>
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b35c4f7c0>
standardMsg = 'LinAlgError not raised by matrix_power'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by matrix_power
msg = 'LinAlgError not raised by matrix_power'
self = <unittest.case._AssertRaisesContext object at 0x1b35c4f7c0>
standardMsg = 'LinAlgError not raised by matrix_power'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_______________________ test_generalized_raise_multiloop _______________________
def test_generalized_raise_multiloop():
# It should raise an error even if the error doesn't occur in the
# last iteration of the ufunc inner loop
invertible = np.array([[1, 2], [3, 4]])
non_invertible = np.array([[1, 1], [1, 1]])
x = np.zeros([4, 4, 2, 2])[1::2]
x[...] = invertible
x[0, 0] = non_invertible
> assert_raises(np.linalg.LinAlgError, np.linalg.inv, x)
invertible = array([[1, 2],
[3, 4]])
non_invertible = array([[1, 1],
[1, 1]])
x = array([[[[1., 1.],
[1., 1.]],
[[1., 2.],
[3., 4.]],
[[1., 2.],
[3., 4.]],... [[1., 2.],
[3., 4.]],
[[1., 2.],
[3., 4.]],
[[1., 2.],
[3., 4.]]]])
/usr/local/lib/python3.8/site-packages/numpy/linalg/tests/test_linalg.py:1787:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b29dc27f0>
standardMsg = 'LinAlgError not raised by inv'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by inv
msg = 'LinAlgError not raised by inv'
self = <unittest.case._AssertRaisesContext object at 0x1b29dc27f0>
standardMsg = 'LinAlgError not raised by inv'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
_________________ TestRandomDist.test_multivariate_normal[svd] _________________
self = <numpy.random.tests.test_generator_mt19937.TestRandomDist object at
0x1b32170cd0>
method = 'svd'
@pytest.mark.parametrize("method", ["svd", "eigh", "cholesky"])
def test_multivariate_normal(self, method):
random = Generator(MT19937(self.seed))
mean = (.123456789, 10)
cov = [[1, 0], [0, 1]]
size = (3, 2)
actual = random.multivariate_normal(mean, cov, size, method=method)
desired = np.array([[[-1.747478062846581, 11.25613495182354 ],
[-0.9967333370066214, 10.342002097029821 ]],
[[ 0.7850019631242964, 11.181113712443013 ],
[ 0.8901349653255224, 8.873825399642492 ]],
[[ 0.7130260107430003, 9.551628690083056 ],
[ 0.7127098726541128, 11.991709234143173 ]]])
assert_array_almost_equal(actual, desired, decimal=15)
# Check for default size, was raising deprecation warning
actual = random.multivariate_normal(mean, cov, method=method)
desired = np.array([0.233278563284287, 9.424140804347195])
assert_array_almost_equal(actual, desired, decimal=15)
# Check that non symmetric covariance input raises exception when
# check_valid='raises' if using default svd method.
mean = [0, 0]
cov = [[1, 2], [1, 2]]
assert_raises(ValueError, random.multivariate_normal, mean, cov,
check_valid='raise')
# Check that non positive-semidefinite covariance warns with
# RuntimeWarning
cov = [[1, 2], [2, 1]]
assert_warns(RuntimeWarning, random.multivariate_normal, mean, cov)
assert_warns(RuntimeWarning, random.multivariate_normal, mean, cov,
method='eigh')
> assert_raises(LinAlgError, random.multivariate_normal, mean, cov,
method='cholesky')
actual = array([0.23327856, 9.4241408 ])
cov = [[1, 2], [2, 1]]
desired = array([0.23327856, 9.4241408 ])
mean = [0, 0]
method = 'svd'
random = Generator(MT19937) at 0x1AF63159A0
self = <numpy.random.tests.test_generator_mt19937.TestRandomDist object
at 0x1b32170cd0>
size = (3, 2)
/usr/local/lib/python3.8/site-packages/numpy/random/tests/test_generator_mt19937.py:1325:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b3217b0d0>
standardMsg = 'LinAlgError not raised by multivariate_normal'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by multivariate_normal
msg = 'LinAlgError not raised by multivariate_normal'
self = <unittest.case._AssertRaisesContext object at 0x1b3217b0d0>
standardMsg = 'LinAlgError not raised by multivariate_normal'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
________________ TestRandomDist.test_multivariate_normal[eigh] _________________
self = <numpy.random.tests.test_generator_mt19937.TestRandomDist object at
0x1b2d708340>
method = 'eigh'
@pytest.mark.parametrize("method", ["svd", "eigh", "cholesky"])
def test_multivariate_normal(self, method):
random = Generator(MT19937(self.seed))
mean = (.123456789, 10)
cov = [[1, 0], [0, 1]]
size = (3, 2)
actual = random.multivariate_normal(mean, cov, size, method=method)
desired = np.array([[[-1.747478062846581, 11.25613495182354 ],
[-0.9967333370066214, 10.342002097029821 ]],
[[ 0.7850019631242964, 11.181113712443013 ],
[ 0.8901349653255224, 8.873825399642492 ]],
[[ 0.7130260107430003, 9.551628690083056 ],
[ 0.7127098726541128, 11.991709234143173 ]]])
assert_array_almost_equal(actual, desired, decimal=15)
# Check for default size, was raising deprecation warning
actual = random.multivariate_normal(mean, cov, method=method)
desired = np.array([0.233278563284287, 9.424140804347195])
assert_array_almost_equal(actual, desired, decimal=15)
# Check that non symmetric covariance input raises exception when
# check_valid='raises' if using default svd method.
mean = [0, 0]
cov = [[1, 2], [1, 2]]
assert_raises(ValueError, random.multivariate_normal, mean, cov,
check_valid='raise')
# Check that non positive-semidefinite covariance warns with
# RuntimeWarning
cov = [[1, 2], [2, 1]]
assert_warns(RuntimeWarning, random.multivariate_normal, mean, cov)
assert_warns(RuntimeWarning, random.multivariate_normal, mean, cov,
method='eigh')
> assert_raises(LinAlgError, random.multivariate_normal, mean, cov,
method='cholesky')
actual = array([0.23327856, 9.4241408 ])
cov = [[1, 2], [2, 1]]
desired = array([0.23327856, 9.4241408 ])
mean = [0, 0]
method = 'eigh'
random = Generator(MT19937) at 0x1AF6315400
self = <numpy.random.tests.test_generator_mt19937.TestRandomDist object
at 0x1b2d708340>
size = (3, 2)
/usr/local/lib/python3.8/site-packages/numpy/random/tests/test_generator_mt19937.py:1325:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b2d7085e0>
standardMsg = 'LinAlgError not raised by multivariate_normal'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by multivariate_normal
msg = 'LinAlgError not raised by multivariate_normal'
self = <unittest.case._AssertRaisesContext object at 0x1b2d7085e0>
standardMsg = 'LinAlgError not raised by multivariate_normal'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
______________ TestRandomDist.test_multivariate_normal[cholesky] _______________
self = <numpy.random.tests.test_generator_mt19937.TestRandomDist object at
0x1b14072580>
method = 'cholesky'
@pytest.mark.parametrize("method", ["svd", "eigh", "cholesky"])
def test_multivariate_normal(self, method):
random = Generator(MT19937(self.seed))
mean = (.123456789, 10)
cov = [[1, 0], [0, 1]]
size = (3, 2)
actual = random.multivariate_normal(mean, cov, size, method=method)
desired = np.array([[[-1.747478062846581, 11.25613495182354 ],
[-0.9967333370066214, 10.342002097029821 ]],
[[ 0.7850019631242964, 11.181113712443013 ],
[ 0.8901349653255224, 8.873825399642492 ]],
[[ 0.7130260107430003, 9.551628690083056 ],
[ 0.7127098726541128, 11.991709234143173 ]]])
assert_array_almost_equal(actual, desired, decimal=15)
# Check for default size, was raising deprecation warning
actual = random.multivariate_normal(mean, cov, method=method)
desired = np.array([0.233278563284287, 9.424140804347195])
assert_array_almost_equal(actual, desired, decimal=15)
# Check that non symmetric covariance input raises exception when
# check_valid='raises' if using default svd method.
mean = [0, 0]
cov = [[1, 2], [1, 2]]
assert_raises(ValueError, random.multivariate_normal, mean, cov,
check_valid='raise')
# Check that non positive-semidefinite covariance warns with
# RuntimeWarning
cov = [[1, 2], [2, 1]]
assert_warns(RuntimeWarning, random.multivariate_normal, mean, cov)
assert_warns(RuntimeWarning, random.multivariate_normal, mean, cov,
method='eigh')
> assert_raises(LinAlgError, random.multivariate_normal, mean, cov,
method='cholesky')
actual = array([0.23327856, 9.4241408 ])
cov = [[1, 2], [2, 1]]
desired = array([0.23327856, 9.4241408 ])
mean = [0, 0]
method = 'cholesky'
random = Generator(MT19937) at 0x1AF63159A0
self = <numpy.random.tests.test_generator_mt19937.TestRandomDist object
at 0x1b14072580>
size = (3, 2)
/usr/local/lib/python3.8/site-packages/numpy/random/tests/test_generator_mt19937.py:1325:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/unittest/case.py:816: in assertRaises
return context.handle('assertRaises', args, kwargs)
/usr/local/lib/python3.8/unittest/case.py:202: in handle
callable_obj(*args, **kwargs)
/usr/local/lib/python3.8/unittest/case.py:224: in __exit__
self._raiseFailure("{} not raised by {}".format(exc_name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x1b14072820>
standardMsg = 'LinAlgError not raised by multivariate_normal'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: LinAlgError not raised by multivariate_normal
msg = 'LinAlgError not raised by multivariate_normal'
self = <unittest.case._AssertRaisesContext object at 0x1b14072820>
standardMsg = 'LinAlgError not raised by multivariate_normal'
/usr/local/lib/python3.8/unittest/case.py:164: AssertionError
=============================== warnings summary ===============================
/usr/local/lib/python3.8/site-packages/numpy/core/getlimits.py:401
/usr/local/lib/python3.8/site-packages/numpy/core/getlimits.py:401:
UserWarning: Signature
b'\x00\x00\x00\x00\x00\x00\x00\xa0\x99\x99\x99\x99\x99\x99\xfb\xbf' for <class
'numpy.float128'> does not match any known type: falling back to type probe
function
machar = _get_machar(dtype)
core/tests/test_scalar_methods.py::TestAsIntegerRatio::test_roundtrip[float128-frac_vals3-exp_vals3]
/usr/local/lib/python3.8/site-packages/numpy/core/tests/test_scalar_methods.py:98:
RuntimeWarning: overflow encountered in conversion from string
df = np.longdouble(str(d))
-- Docs: https://docs.pytest.org/en/latest/warnings.html
55 failed, 10837 passed, 83 skipped, 108 deselected, 20 xfailed, 1 xpassed, 2
warnings in 1974.97 seconds