summaryrefslogtreecommitdiff
path: root/numpy/testing/tests/test_utils.py
Commit message (Collapse)AuthorAgeFilesLines
...
* TST: Switch to using pytest markersCharles Harris2018-04-041-1/+2
| | | | | | | | | | | Use standard pytest markers everywhere in the numpy tests. At this point there should be no nose dependency. However, nose is required to test the legacy decorators if so desired. At this point, numpy test cannot be run in the way with runtests, rather installed numpy can be tested with `pytest --pyargs numpy` as long as that is not run from the repo. Run it from the tools directory or some such.
* MAINT: Remove use of unittest in NumPy tests.xoviat2018-03-211-209/+169
| | | | | | | | | | | | | | | | This removes a few left over uses of unittest. The main changes apart from removal of Test case are: * `setUp` replaced by nose and pytest compatible `setup` * `tearDown` replaced by nose and pytest compatible `teardown` * `assertRaises` replaced by `assert_raises` * `assertEqual` replaced by `assert_equal` The last two are in `numpy/testings/tests/test_utils.py`, so may seem a but circular, but at least are limited to those two functions. The use of `setup` and `teardown`, can be fixed up with the pytest equivalents after we have switched to pytest.
* MAINT: Fix test_utils.py for Python 3.7.Charles Harris2018-03-191-14/+29
| | | | | | The contents of the module warnings registries was made more module specific in Python 3.7 and consequently the tests of the context managers clear_and_catch_warnings and suppress_warnings need updating.
* MAINT: Increase range in float16 almost equal nulp test.Charles Harris2018-03-131-2/+4
|
* TST: Fixing bug in assert near equality of float16 arrays (#10697)Aaron Critchley2018-03-101-0/+28
|
* MAINT/BUG: Simplify _formatArray, fixing array_repr(matrix) in the processEric Wieser2017-12-061-1/+3
| | | | | | | | Now: * Has one recursive base case * Is fewer lines of code * Does not rstrip the result of format_function (none of the builtin ones have trailing spaces anyway) * Recurses in the index, instead of the value, which handles `dtype=object` arrays without the need for the rank argument. This fixes #8442.
* MAINT: Simplify IntegerFormatterEric Wieser2017-11-281-6/+9
| | | | | | This essentially reverts 83accefd143a0e3ee8b3160d0927b3ff616743de, which presumably worked around a bug in an ancient version of python Similarly, the try/excepts here were to handle `IntegerFormatter` being called on the wrong type of array, which no longer happens
* BUG: Fix assert_equal on time-like objectsEric Wieser2017-11-261-0/+20
| | | | | | Also does some cleanup on the float assert_equal to make it look more similar. Fixes #10081
* Merge pull request #9645 from xoviat/appveyorCharles Harris2017-09-301-9/+12
|\ | | | | ENH: enable OpenBLAS on windows.
| * TST: utils: fix string continuationxoviat2017-09-091-6/+6
| |
| * :art:xoviat2017-09-091-1/+1
| |
| * TST: util: fix test_error_messagexoviat2017-09-091-1/+1
| | | | | | use the correct replace() order
| * TST: utils: fix test_error_msgxoviat2017-09-091-7/+8
| | | | | | Allow the error message to contain "large" arrays.
| * TST: fix failures:xoviat2017-09-041-1/+3
| | | | | | | | | | | | 1. fail tests related to DLL load failure as they were previously untested. 2. fix have_compiler to return false on old compilers 3. xfail some tests that were not working on old Python versions.
* | TST: update tests to remove unneeded whitespaceAllan Haldane2017-09-251-12/+12
|/
* MAINT/DOC: Use builtin when np.{x} is builtins.{x}.Eric Wieser2017-08-051-3/+3
| | | | | | | This is the case for x in {int, bool, str, float, complex, object}. Using the np.{x} version is deceptive as it suggests that there is a difference. This change doesn't affect any external behaviour. The `long` type is missing in python 3, so np.long is still useful
* BUG: Remove warning filters from comparison assert functionsSebastian Berg2017-05-071-1/+36
| | | | | | | | | 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.
* Ensure inf/nan removal in assert_array_compare is matrix-safe.Marten van Kerkwijk2017-01-111-0/+28
|
* BUG assert_almost_equal fails on subclasses that cannot handle boolMarten van Kerkwijk2017-01-091-3/+33
| | | | | | | | | | | | 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.
* TST: Added test that np.inf is not approx. -np.infJonathan Tammo Siebert2017-01-041-0/+5
| | | | | This failed to raise AssertionError in an earlier rewrite of assert_array_compare and is thus tested explicitly now.
* TST: Added unit tests for assert_array_lessJonathan Tammo Siebert2017-01-041-0/+140
| | | | | | | | | Added tests for simple arrays/elements, tests that ensure that nans are not compared when they are in the same position in both arrays but raise AssertionError when they are not, and tests that ensure inf logic (-np.inf < np.inf, 1.0 < np.inf, -np.inf < 1.0) and that all other cases fail.
* MAINT: make `assert_allclose` behavior on `nan`s match pre 1.12Josh Wilson2016-10-191-2/+14
|
* TST: Add tests for assert_allclose(..., equal_nan={True|False})Antti Kaihola2016-10-171-0/+12
|
* ENH: Make warning testing context managers more specificSebastian Berg2016-09-021-7/+5
| | | | | | | 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.
* STY: Small PEP8 cleanups.Charles Harris2016-08-281-2/+2
|
* ENH,TST: Add new warning suppression/filtering contextSebastian Berg2016-08-281-4/+182
| | | | | | 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: Make assert_almost_equal & assert_array_almost_equal consistent.Charles Harris2016-06-191-1/+35
| | | | | | | | | | | | | | | | | | 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.
* Clarify error on repr failure in assert_equal.Antony Lee2016-02-191-0/+13
| | | | | | | | | | | | | | 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-31/+2
|\ | | | | Revert "Merge pull request #7001 from shoyer/NaT-comparison"
| * Revert "Merge pull request #7001 from shoyer/NaT-comparison"Charles Harris2016-01-161-31/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | TST: Make assert_warns an optional contextmanagerStephan Hoyer2016-01-141-0/+15
|/
* TST, ENH: make all comparisons with NaT falseStephan Hoyer2016-01-141-2/+31
| | | | | | | | | 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
* MAINT: Use temppath in test_not_closing_opened_fid.Charles Harris2015-12-201-2/+6
| | | | | The test is in numpy/lib/tests/test_io.py. This commit is intended as a demonstration of using temppath.
* ENH: Add context manager `temppath` to manage a temporary file.Charles Harris2015-12-191-1/+32
| | | | | | | | | | | | 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`.
* BUG: testing: fix a bug in assert_string_equalPauli Virtanen2015-11-141-1/+18
|
* MAINT: pyflakes for numpy/testing, numpy/testing/tests.Charles Harris2015-07-051-5/+27
|
* STY: PEP8 fixes for numpy/testing numpy/testing/tests.Charles Harris2015-07-051-15/+14
|
* ENH: add clear_and_catch_warnings context managerMatthew Brett2015-03-141-1/+69
| | | | | | | 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.
* TST: Update assert_array_almost_equal_nulp testsRyan Nelson2015-01-111-39/+164
| | | | | | | | | | | | | | | | This fix addresses Issue #347. All of the tests in this class were using random numbers generated without a seed. This broke `test_simple` in a nondeterministic manner. Rewrote all tests for this function. Instead of using random numbers, well-defined arrays of widely varying amplitude were created instead. Changed the array modification values so that the test arrays were either just above or just below the NULP threshold. Added tests for float64, float32, complex128, and complex64 dtypes, and added both addition and subtraction tests. Tried to standardize the code for all tests.
* Merge pull request #5048 from juliantaylor/subclass-test-fixCharles Harris2014-09-041-0/+8
|\ | | | | BUG: fix array_almost_equal for array subclasses
| * BUG: fix array_almost_equal for array subclassesJulian Taylor2014-09-051-0/+8
| | | | | | | | introduced in gh-4105/ab04e1ae0e8eca717bc7e42f3b0a60c9ff764289
* | Use more portable test methods.Patrick Peglar2014-09-021-1/+5
| |
* | BUG: fix percentage reporting when testing.assert_allclose fails.Patrick Peglar2014-08-311-0/+5
|/
* TST: Change tests to look at array formatting onlyYoshiki Vázquez Baeza2014-03-251-7/+9
| | | | | | The tests were looking at the formatting of other elements in the string which is not relevant for the things testsed in this case. By looking only at the array formatting, we guarantee consistency across systems.
* TST: Remove test that makes no senseYoshiki Vázquez Baeza2014-03-251-12/+0
| | | | | It's silly to check scalars when their string representations will vary so much from system to system.
* BUG: Fix non-compatible py3 propertyYoshiki Vázquez Baeza2014-03-251-3/+3
|
* TST: Add exception message formatting testsYoshiki Vázquez Baeza2014-03-251-0/+35
| | | | | | assert_approx_equal & assert_almost_equal make internal use of build_err_msg so a few tests have been added to check that the errors are formatted correctly.
* TST: Add tests for build_err_msgYoshiki Vázquez Baeza2014-03-241-0/+43
|
* BUG: Force allclose logic to use inexact typeSebastian Berg2014-02-161-0/+8
| | | | | | Casting y to an inexact type fixes problems such as abs(MIN_INT) < 0, and generally makes sense since the allclose logic is inherently for float types.
* STY: Giant comma spacing fixup.Charles Harris2013-08-181-1/+1
| | | | | | | Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.