summaryrefslogtreecommitdiff
path: root/numpy/testing/_private/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* assert_array_compareMaxwell Aladago2019-09-061-7/+8
|
* BUG: Fixed maximum relative error reporting in assert_allclose (gh-13802)CakeWithSteak2019-09-051-2/+7
| | | | | | Fixed maximum relative error reporting in assert_allclose: In cases where the two arrays have zeros at the same positions it will no longer report nan as the max relative error
* DEP: numpy.testing.rand (#14325)Maxwell Aladago2019-08-221-18/+1
| | | * Deprecation: numpy.testing.rand
* ENH: Improve mismatch message of np.testing.assert_array_equal (#14203)Tim Hoffmann2019-08-151-2/+5
| | | | | The original message included "Mismatch: 33.3%". It's not obvious what this percentage means. This commit changes the text to "Mismatched elements: 1 / 3 (33.3%)".
* MAINT: Replace integers in places where booleans are expectedMSeifert042019-07-011-1/+1
|
* MAINT: Misc. typo fixes (#13664)luzpaz2019-05-311-2/+2
| | | | | | * DOC, MAINT: Misc. typo fixes Found via `codespell`
* BUG: special case object arrays when printing rel-, abs-errormattip2019-05-271-4/+12
|
* Merge pull request #13518 from hmaarrfk/faster_array_compareEric Wieser2019-05-121-4/+3
|\ | | | | MAINT: implement assert_array_compare without converting array to python list
| * Ensure that reduced is a 1D arrayMark Harfouche2019-05-121-1/+1
| |
| * Fixup: address eric-wieser's commentsMark Harfouche2019-05-121-5/+3
| |
| * MNT: implement assert_array_compare without converting array to python list.Mark Harfouche2019-05-091-4/+5
| |
* | DOC: testing: Mention the handling of nan in the assert_equal docstring.Warren Weckesser2019-05-051-0/+10
|/
* DOC: defaults in allclose not the same as in assert_allclose (#13395)Dieter Werthmüller2019-04-251-3/+3
| | | * DOC: defaults in allclose not the same as in assert_allclose
* MAINT: move gc.collect to function (from review)mattip2019-04-191-1/+19
|
* DEV: add pypy3 to azure CImattip2019-04-161-0/+1
|
* ENH: add "max difference" messages to np.testing.assert_array_equal (#12591)Stephan Hoyer2019-01-011-82/+121
| | | | | | | | | | | | | | | | | | | | | | Example behavior: >>> x = np.array([1, 2, 3]) >>> y = np.array([1, 2, 3.0001]) >>> np.testing.assert_allclose(x, y) AssertionError: Not equal to tolerance rtol=1e-07, atol=0 Mismatch: 33.3% Max absolute difference: 0.0001 Max relative difference: 3.33322223e-05 x: array([1, 2, 3]) y: array([1. , 2. , 3.0001]) Motivation: when writing numerical algorithms, I frequently find myself experimenting to pick the right value of `atol` and `rtol` for `np.testing.assert_allclose()`. If I make the tolerance too generous, I risk missing regressions in accuracy, so I usually try to pick the smallest values for which tests pass. This change immediately reveals appropriate values to use for these parameters, so I don't need to guess and check.
* TST, DOC: enable refguide_checkTyler Reddy2018-12-141-3/+0
| | | | | | | | * ported the refguide_check module from SciPy for usage in NumPy docstring execution/ verification; added the refguide_check run to Azure Mac OS CI * adjusted NumPy docstrings such that refguide_check passes
* MAINT: Review F401,F841,F842 flake8 errors (unused variables and imports) ↵Roman Yurchak2018-12-061-3/+2
| | | | | | | | | | | | (#12448) * Review F401,F841,F842 flake8 errors (unused variables, imports) * Review comments * More tests in test_installed_npymath_ini * Review comments
* Merge pull request #12243 from liwt31/fix_misleading_msgMatti Picus2018-10-231-3/+6
|\ | | | | BUG: Fix misleading assert message in assert_almost_equal #12200
| * BUG: Fix misleading assert message in assert_almost_equal #12200wtli@Dirac2018-10-231-3/+6
| | | | | | | | | | Fixes #12200 by making a copy of the matrix before NaN's are excluded. Add a test for it.
* | ENH: __array_function__ support for np.lib, part 2/2 (#12119)Stephan Hoyer2018-10-221-11/+16
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ENH: __array_function__ support for np.lib, part 2 xref GH12028 np.lib.npyio through np.lib.ufunclike * Fix failures in numpy/core/tests/test_overrides.py * CLN: handle depreaction in dispatchers for np.lib.ufunclike * CLN: fewer dispatchers in lib.twodim_base * CLN: fewer dispatchers in lib.shape_base * CLN: more dispatcher consolidation * BUG: fix test failure * Use all method instead of function in assert_equal * DOC: indicate n is array_like in scimath.logn * MAINT: updates per review * MAINT: more conservative changes in assert_array_equal * MAINT: add back in comment * MAINT: casting tweaks in assert_array_equal * MAINT: fixes and tests for assert_array_equal on subclasses
* MAINT: Make assert_array_compare more generic.Charles Harris2018-08-171-6/+15
| | | | | | | Use np.all instead of the *.all method to be a bit more robust against bad subclasses of ndarray that may change the behavior of the method. Closes #11743.
* BUG: Make assert_string_equal check str equality simply without regexSho Nakamura2018-07-141-2/+2
|
* HTTP -> HTTPS, and other linkrot fixesMike Toews2018-06-161-4/+4
|
* Merge pull request #11122 from mhvk/assert-array-comparison-with-maskedCharles Harris2018-06-071-41/+35
|\ | | | | BUG,MAINT: Ensure masked elements can be tested against nan and inf.
| * MAINT: clean up assert_array_compare a bit further.Marten van Kerkwijk2018-06-041-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This brought to light two bugs in tests, which are fixed here, viz., that a sample ndarray subclass that tested propagation of an added parameter was incomplete, in that in propagating the parameter in __array_wrap__ it assumed it was there on self, but that assumption could be broken when a view of self was taken (as is done by x[~flagged] in the test routine), since there was no __array_finalize__ defined. The other subclass bug counted, incorrectly, on only needing to provide one type of comparison, the __lt__ being explicitly tested. But flags are compared with __eq__ and those flags will have the same subclass.
| * BUG,MAINT: Ensure masked elements can be tested against nan and inf.Marten van Kerkwijk2018-05-271-38/+29
| | | | | | | | | | | | | | The removal of nan and inf from arrays that are compared using test routines like assert_array_equal treated the two arrays separately, which for masked arrays meant that some elements would not be removed when they should have been. This PR corrects this.
* | BUG: Import WarningMessage from warnings.Charles Harris2018-06-041-0/+1
| |
* | MAINT: Remove dead code backporting py2.6 warningsEric Wieser2018-06-041-92/+0
|/ | | | Since this is now in `np.testing._private`, it's no longer usable by the outside world anyway
* TST: disable gc in refcount test (#11158)Matti Picus2018-05-241-5/+9
| | | | | | | The vectorize version of this test was failing consistently on several of the Appveyor builds, ever since a recent pytest upgrade. Our theory is that by random chance, things changed so that during the call to vectorize(op).__call__, python started running a garbage collection, which perturbed the refcounts that this test is checking. (Specifically this test is doing a weird thing and checking that the refcount of the object 1 doesn't decrease, and it's very plausible that some random bit of garbage was holding a reference to this object.) Disabling the gc during the test makes this kind of refcount assertion more reliable, and seems to have fixed the appveyor builds, so I guess it's good.
* BUG: Ensure that fully masked arrays pass assert_array_equal.Marten van Kerkwijk2018-05-191-1/+5
| | | | | The underlying problem is that ma.all() evaluates to masked, which is falsy, and thus triggers test failures.
* BUG: Ensure the garbage is clear first in assert_no_gc_cyclesEric Wieser2018-04-151-1/+8
| | | | It's not always possible to guarantee this, so also adds a test to verify that we don't hang
* ENH: Show the full list of leaked objectsEric Wieser2018-04-121-2/+21
| | | | | | | | | An example output for the test added in the previous commit is: AssertionError: Reference cycles were found when calling make_cycle: 1 objects were collected, of which 1 are shown below: list object with id=2279664872136: [<Recursion on list with id=2279664872136>, <Recursion on list with id=2279664872136>]
* TST: Extract a helper function to test for reference cyclesEric Wieser2018-04-121-1/+63
| | | | | | This also means we can now test that our test is actually able to detect the type of failure we expect Trying to give myself some tools to debug the failure at https://github.com/numpy/numpy/pull/10882/files#r180813166
* MAINT: Rearrange numpy/testing files.Charles Harris2018-03-291-0/+2274
This is to prepare for the switch to pytest. * Rename `numpy/testing/nose_tools` to `numpy/testing/_private`. * Redirect imports as needed. * Copy `_testutils.py` from scipy to `numpy/testing/_private`. * Rename `_testutils.py` to `_pytester.py` and remove unneeded bits.