summaryrefslogtreecommitdiff
path: root/numpy/testing/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: Rearrange files in numpy/testing module.Charles Harris2017-07-041-2213/+5
| | | | | | | | | | | | | | | | | The aim here is to separate out the nose dependent files prior to adding pytest support. This could be done by adding new files to the general numpy/testing directory, but I felt that it was to have the relevant files separated out as it makes it easier to completely remove nose dependencies when needed. Many places were accessing submodules in numpy/testing directly, and in some cases incorrectly. That presented a backwards compatibility problem. The solution adapted here is to have "dummy" files whose contents will depend on whether of not pytest is active. That way the module looks the same as before from the outside. In the case of numpy itself, direct accesses have been fixed. Having proper `__all__` lists in the submodules helped in that.
* BUG: KeyboardInterrupt is swallowed all over the placeEric Wieser2017-06-031-2/+2
| | | | Bare except is very rarely the right thing
* BUG: Remove warning filters from comparison assert functionsSebastian Berg2017-05-071-37/+39
| | | | | | | | | These warning filters are not threadsafe, while it is nicer if the comparison functions can be called in a threaded environment since they do no explicite warning checking. Less filters are also cleaner in general, though may also mean that downstream projects see warnings that were previously hidden.
* Add missing __tracebackhide__ to testing functions.Antony Lee2017-02-041-0/+2
|
* Ensure inf/nan removal in assert_array_compare is matrix-safe.Marten van Kerkwijk2017-01-111-8/+16
|
* BUG assert_almost_equal fails on subclasses that cannot handle boolMarten van Kerkwijk2017-01-091-14/+7
| | | | | | | | | | | | gh-8410 breaks a large number of astropy tests, because it sets up a boolean array for values that should actually be compared (i.e., are not `nan` or `inf`) using `zeros_like`. The latter means that for subclasses, the boolean test array is not a plain `ndarray` but the subclass. But for astropy's `Quantity`, the `all` method is undefined. This commit ensures the test arrays from `isinf` and `isnan` are used directly.
* BUG: corrected behavior for assert_array_lessJonathan Tammo Siebert2017-01-041-18/+20
| | | | | | | | | | | | | | | | See issue #2418 assert_array_less does now treat inf/nan correctly, namely: -inf < x < inf for any real number x nans still are not compared, when they occur at the same position To achieve this without breaking any other functions relying on assert_array_compare, an additional parameter (equal_inf) was introduced that defaults to the old behavior (analogous to equal_nan).
* DEP: Fix escaped string characters deprecated in Python 3.6.Charles Harris2016-12-141-2/+2
| | | | | | | In Python 3.6 a number of escape sequences that were previously accepted -- for instance "\(" that was translated to "\\(" -- are deprecated. To retain the previous behavior either raw strings must be used or the backslash must be properly escaped itself.
* BUG: Fix suppress_warnings (again) for Python 3.6.Charles Harris2016-12-071-10/+0
| | | | | The Python 3.6 changes that resulted in the 6b49167c fix has been fixed in Python 3.6.0rc1. So revert our fixes.
* MAINT: make `assert_allclose` behavior on `nan`s match pre 1.12Josh Wilson2016-10-191-1/+1
|
* MAINT: Add python 3.6 support to suppress_warningsSebastian Berg2016-10-191-3/+26
| | | | | | | | | | | | Python 3.6 has two methods for showing warnings, so we have to support both ways (strictly speaking, on python 3.6 itself only the new would probably be needed). Also adds the _filters_mutated() call to replace manual registry clearing. This is basically the fix that newer python versions have to avoid the issue making the manual clearing unnecessary. Closes gh-8176
* BUG: Make assert_allclose(..., equal_nan=False) work.Antti Kaihola2016-10-171-9/+13
| | | | | | | | | As discussed in my comments for issue #8145, this patch adds the equal_nan argument to assert_array_compare(), and assert_allclose() passes the value it receives for the same argument through to assert_array_compare(). Closes #8142.
* MAINT: fix assert_raises_regex when used as a context managerStephan Hoyer2016-09-261-8/+13
| | | | | Formerly, I got DeprecationWarnings about callable being None when I tested on Python 3.
* Update somethingaboutorange URL to nose.readthedocs.ionaveenarun2016-09-211-1/+1
|
* Merge pull request #7099 from seberg/suppressed_warningsCharles Harris2016-09-021-12/+12
|\ | | | | Suppressed warnings
| * BUG: Suppress common NaT warningsSebastian Berg2016-09-021-4/+9
| | | | | | | | | | | | | | | | | | Printing of datetime arrays used to cause warning due to comparison warnings in NaT. This is circumvented by using views to integer values. Part of this should be simplified when the deprecation is over. Also fixes a bug with non-native byteorder.
| * ENH: Make warning testing context managers more specificSebastian Berg2016-09-021-8/+3
| | | | | | | | | | | | | | This means that warnings of different origin then the one tested for behave normally. If the normal behaviour is to igonre them this might decrease specificity in rare cases. In most cases the specificity will be slightly higher.
* | TST: fix inplace case of alignment data generatorJulian Taylor2016-09-011-3/+6
|/ | | | | | | | Due to the lambdas used it didn't actually generate inplace cases. Fix a few tests that now break due to assuming that the cases are always out of place. Also update some numbers to make it more likely to find issues like loading from wrong array.
* STY: Small PEP8 cleanups.Charles Harris2016-08-281-0/+1
|
* ENH,TST: Add new warning suppression/filtering contextSebastian Berg2016-08-281-14/+303
| | | | | | This context has a couple of advantages over the typical one, and can ensure that warnings are cleanly filtered without side effect for later tests.
* ENH: skip or avoid gc/objectmodel differences btwn pypy and cpythonmattip2016-08-151-1/+6
|
* Merge pull request #7791 from bertrand-l/feature/f2py-issues-7683Charles Harris2016-07-181-7/+2
|\ | | | | f2py.compile issues (#7683)
| * MAINT,DOC: add to compat.py3k a function to load modules. Fix some doc for ↵bertrand2016-07-171-7/+2
| | | | | | | | f2py.compile (issue #7683)
* | ENH: Make assert_almost_equal & assert_array_almost_equal consistent.Charles Harris2016-06-191-14/+19
|/ | | | | | | | | | | | | | | | | | This changes the check for scalars in assert_almost_equal so that abs(actual - desired) < 1.5 * 10**(-decimal) Note that the previous documentation claimed that the functions were equivalent to abs(actual - desired) < .5 * 10**(-decimal) but that was not how they behaved in practice. Due to the change in implementation, some very delicate tests may fail that did not fail before. No extra failures were noted in scipy. Closes #5200.
* MAINT: clean up testing.assert_raises_regexp, 2.6-specific code removed.Ralf Gommers2016-05-141-63/+12
| | | | The global also was ugly and not useful.
* STY: PEP8, two blank lines between top level function definitions.Charles Harris2016-04-041-1/+22
|
* MAINT: Remove nose.SkipTest import.Charles Harris2016-04-041-11/+3
| | | | | This was only needed for Python 2.6 as it is available from unittest in later Python versions.
* Clarify error on repr failure in assert_equal.Antony Lee2016-02-191-2/+2
| | | | | | | | | | | | | | assert_equal(np.array([0, 1]), np.matrix([0, 1])) used to print x: array([0, 1]) y: [repr failed] now prints x: array([0, 1]) y: [repr failed for <matrix>: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()]
* Merge pull request #7042 from charris/revert-7001Charles Harris2016-01-161-45/+4
|\ | | | | Revert "Merge pull request #7001 from shoyer/NaT-comparison"
| * Revert "Merge pull request #7001 from shoyer/NaT-comparison"Charles Harris2016-01-161-45/+4
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7141f40b58ed1e7071cde78ab7bc8ab37e9c5983, reversing changes made to 8fa6e3bef26a6d4a2c92f2824129aa4409be2590. The original broke some pandas tests. The current plan to get this in is * reversion * issue FutureWarning in 1.11 and 1.12 * make the change in 1.13.
* | DOC: document changes to assert_warnsStephan Hoyer2016-01-161-0/+4
| |
* | TST: Make assert_warns an optional contextmanagerStephan Hoyer2016-01-141-18/+51
|/
* TST, ENH: make all comparisons with NaT falseStephan Hoyer2016-01-141-4/+45
| | | | | | | | | Now, NaT compares like NaN: - NaT != NaT -> True - NaT == NaT (and all other comparisons) -> False We discussed this on the mailing list back in October: https://mail.scipy.org/pipermail/numpy-discussion/2015-October/073968.html
* DEP: deprecate np.testing.randEvgeni Burovski2016-01-041-0/+3
|
* Merge pull request #6866 from charris/tempfile-context-managerCharles Harris2015-12-201-4/+27
|\ | | | | ENH: Tempfile context manager
| * ENH: Add context manager `temppath` to manage a temporary file.Charles Harris2015-12-191-4/+27
| | | | | | | | | | | | | | | | | | | | | | | | Context manager intended for use when the same temporary file needs to be opened and closed more than once. The context manager creates the file, closes it, and returns the path to the file. On exit from the context block the file is removed. The file should be closed before exiting the context as an error will be raised on windows if not. Also fix up the `tempdir` context manager to deal with exceptions. Tests are added for both `temppath` and `tempdir`.
* | DOC: Use print only as function when print_function is imported from __future__gfyoung2015-12-191-1/+1
|/ | | | Closes gh-6863.
* ENH: testing: add SkipTest and KnownFailureExceptionEvgeni Burovski2015-11-161-2/+19
| | | | | | | | * use SkipTest in numpy tests instead of importing it from nose * add a KnownFailureException as an alias for KnownFailureTest (the former is preferred, but the latter is kept for backcompat) * rename the KnownFailure nose plugin into KnownFailurePlugin, and keep the old name for backcompat
* BUG: testing: fix a bug in assert_string_equalPauli Virtanen2015-11-141-5/+6
|
* DOC: document that assert_raises can be used as a context managerEvgeni Burovski2015-11-121-0/+12
|
* Merge pull request #5773 from ml31415/pytest_traceback_hidePauli Virtanen2015-10-171-0/+15
|\ | | | | ENH: Hide testing helper tracebacks when using them with pytest
| * PEP8 applied to commentsMichael Löffler2015-05-141-15/+15
| |
| * Comments addedMichael Löffler2015-04-201-15/+15
| |
| * pytest traceback hide markers set for testing helpersMichael Löffler2015-04-191-0/+15
| |
* | BUG: Fixed import error on Windows from not correctly defining aIan Henriksen2015-07-131-20/+23
| | | | | | | | function listed in __all__ for numpy/testing/utils.py.
* | MAINT: pyflakes for numpy/testing, numpy/testing/tests.Charles Harris2015-07-051-45/+61
| |
* | STY: PEP8 fixes for numpy/testing numpy/testing/tests.Charles Harris2015-07-051-33/+40
| |
* | MAINT: move the special case for void comparison before the regular caseNathaniel J. Smith2015-06-131-3/+26
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | The ndarray richcompare function has special case code for handling void dtypes (esp. structured dtypes), since there are no ufuncs for this. Previously, we would attempt to call the relevant ufunc (e.g. np.equal), and then when this failed (as signaled by the ufunc returning NotImplemented), we would fall back on the special case code. This commit moves the special case code to before the regular code, so that it no longer requires ufuncs to return NotImplemented. Technically, it is possible to define ufunc loops for void dtypes using PyUFunc_RegisterLoopForDescr, so technically I think this commit changes behaviour: if someone had registered a ufunc loop for one of these operations, then previously it might have been found and pre-empted the special case fallback code; now, we use the special-case code without even checking for any ufunc. But the only possible use of this functionality would have been if someone wanted to redefine what == or != meant for a particular structured dtype -- like, they decided that equality for 2-tuples of float32's should be different from the obvious thing. This does not seem like an important capability to preserve. There were also several cases here where on error, an array comparison would return a scalar instead of raising. This is supposedly deprecated, but there were call paths that did this that had no deprecation warning. I added those warnings.
* ENH: add clear_and_catch_warnings context managerMatthew Brett2015-03-141-1/+63
| | | | | | | Add context manager for tests that, on entry, clears record of any previous warnings from given modules, so that any warning raised in the context block does get raised, rather than suppressed by a previous warning causing an entry in the `__warningregistry_`` of the module.
* DOC: Reconcile docstrings and function signatures where they disagreeRobert McGibbon2015-03-021-0/+2
| | | | | Fixed typos in docstrings were updated for functions where the parameter names in the docstring didn't match the function signature.