summaryrefslogtreecommitdiff
path: root/numpy/testing
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: Use np.errstate context manager.Charles Harris2013-07-111-15/+5
| | | | | | | | | | | | | Now that Python < 2.6 is no longer supported we can use the errstate context manager in places where constructs like ``` old = seterr(invalid='ignore') try: blah finally: seterr(**old) ``` were used.
* DEP: Deprecate the oldnumeric and numarray modules.Charles Harris2013-06-102-0/+4
| | | | | | | | | The numarray and oldnumeric modules are deprecated. This is a bit tricky as raising a DeprecationWarning on import causes an error when tests are run. To deal with that, a ModuleDeprecationWarning class is added to numpy and NoseTester is modified to ignore that warning during testing. Closes #2905
* MAINT: fix shape mismatch issue in alignment data generatorJulian Taylor2013-06-081-4/+4
|
* ENH: vectorize sqrt ufunc using SSE2Julian Taylor2013-05-251-0/+67
| | | | | | | | | | | | | | | | | | specialize the sqrt ufunc for float and double and vectorize it using SSE2. improves performance by 4/2 for float/double if one is not memory bound due to non-cached data. performance is always better on all tested machines (amd phenom X2, intel xeon 5xxx/7xxx, core2duo, corei7) This version will not set errno on invalid input, but numpy only checks the fpu flags so the behavior is the same. In principle the compiler could autovectorize it when setting ffast-math (for no errno) and specializing the loop for the vectorizable strides and giving it some hints (restrict, __builtin_assume_aligned, etc.), but its simpler and more reliable to simply vectorize it by hand.
* BUG: testing: always enable --exePauli Virtanen2013-05-091-0/+8
| | | | | | Setuptools tends to set +x to the installed test scripts, which makes numpy.test() to not run any tests. Having --exe always enabled is not problematic because only files matching 'test_*.py' are looked into.
* 2to3: Apply types fixer.Charles Harris2013-04-141-4/+3
| | | | | | | | | | | | | | | | | | | | Python 3 removes the builtin types from the types module. The types fixer replaces such references with the builtin types where possible and also takes care of some special cases: types.TypeNone <- type(None) types.NotImplementedType <- type(NotImplemented) types.EllipsisType <- type(Ellipsis) The only two tricky substitutions are types.StringType <- bytes types.LongType <- int These are fixed up to support both Python 3 and Python 2 code by importing the long and bytes types from numpy.compat. Closes #3240.
* Merge pull request #3237 from charris/2to3-apply-basestringCharles Harris2013-04-141-0/+1
|\ | | | | 2to3: Apply basestring fixer.
| * 2to3: Apply basestring fixer.Charles Harris2013-04-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | The basestring class is not defined in Python 3 and the fixer replaces it with str. In order to have a common code base we define basestring in numpy/compat/py3k.py to be str when the Python version is >= 3, otherwise basestring and import it where needed. That works for most cases, but there are a few files where the version dependent define needs to be in the file. Closes #3042.
* | ENH: testing: remove an annoying line feed from skipif decoratorPauli Virtanen2013-04-131-2/+2
|/ | | | | The line feed is annoying as it makes Nose's verbose test output not print one line per one test.
* 2to3: Apply `map` fixer.Charles Harris2013-04-101-1/+2
| | | | | | | | | | | | | | | | | | | In Python 3 `map` is an iterator while in Python 2 it returns a list. The simple fix applied by the fixer is to inclose all instances of map with `list(...)`. This is not needed in all cases, and even where appropriate list comprehensions may be preferred for their clarity. Consequently, this patch attempts to use list comprehensions where it makes sense. When the mapped function has two arguments there is another problem that can arise. In Python 3 map stops execution when the shortest argument list is exhausted, while in Python 2 it stops when the longest argument list is exhausted. Consequently the two argument case might need special care. However, we have been running Python3 converted versions of numpy since 1.5 without problems, so it is probably not something that affects us. Closes #3068
* 2to3: Apply `repr` fixer.Charles Harris2013-04-081-4/+4
| | | | | | | | | | | | This replaces python backtics with repr(...). The backtics were mostly used to generate strings for printing with a string format and it is tempting to replace `'%s' % repr(x)` with `'%r' % x`. That would work except where `x` happened to be a tuple or a dictionary but, because it would be significant work to guarantee that and because there are not many places where backtics are used, the safe path is to let the repr replacements stand. Closes #3083.
* 2to3: Apply `print` fixer.Charles Harris2013-04-0612-47/+47
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* Merge pull request #3191 from charris/2to3-apply-imports-fixerCharles Harris2013-04-061-2/+6
|\ | | | | 2to3: Apply `imports` fixer.
| * 2to3: Apply `imports` fixer.Charles Harris2013-04-021-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `imports` fixer deals with the standard packages that have been renamed, removed, or methods that have moved. cPickle -- removed, use pickle commands -- removed, getoutput, getstatusoutput moved to subprocess urlparse -- removed, urlparse moved to urllib.parse cStringIO -- removed, use StringIO or io.StringIO copy_reg -- renamed copyreg _winreg -- renamed winreg ConfigParser -- renamed configparser __builtin__ -- renamed builtins In the case of `cPickle`, it is imported as `pickle` when python < 3 and performance may be a consideration, but otherwise plain old `pickle` is used. Dealing with `StringIO` is a bit tricky. There is an `io.StringIO` function in the `io` module, available since Python 2.6, but it expects unicode whereas `StringIO.StringIO` expects ascii. The Python 3 equivalent is then `io.BytesIO`. What I have done here is used BytesIO for anything that is emulating a file for testing purposes. That is more explicit than using a redefined StringIO as was done before we dropped support for Python 2.4 and 2.5. Closes #3180.
* | Merge pull request #460 from endolith/regex_formattingCharles Harris2013-04-031-1/+1
|\ \ | |/ |/| DOC: Formatting fixes using regex
| * DOC: Used regex to find colons missing spaces which render wrong online, ↵endolith2013-03-191-1/+1
| | | | | | | | also other spacing or formatting mistakes
* | 2to3: Use absolute imports.Charles Harris2013-03-2811-25/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172
* | 2to3: Replace xrange by range and use list(range(...)) where neededCharles Harris2013-03-272-5/+5
|/ | | | | | | | | | | | | | | In python3 range is an iterator and `xrange` has been removed. This has two consequence for code: 1) Where a list is needed `list(range(...))` must be used. 2) `xrange` must be replaced by `range` Both of these changes also work in python2 and this patch makes both. There are three places fixed that do not need it, but I left them in so that the result would be `xrange` clean. Closes #3092
* Merge pull request #3026 from charris/2to3-fix-printCharles Harris2013-03-0112-3/+28
|\ | | | | 2to3: Put `from __future__ import division` in every python file.
| * 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-0112-3/+28
| | | | | | | | | | | | | | | | This should be harmless, as we already are division clean. However, placement of this import takes some care. In the future a script can be used to append new features without worry, at least until such time as it exceeds a single line. Having that ability will make it easier to deal with absolute imports and printing updates.
* | Merge pull request #3099 from charris/2to3-methodattrsnjsmith2013-03-011-2/+2
|\ \ | |/ |/| 2to3: Apply `methodattrs` fixes.
| * 2to3: Apply `methodattrs` fixes.Charles Harris2013-03-011-2/+2
| | | | | | | | | | Replaces old style `f.im_func` and `f.im_class` method attributes with `f.__func__` and `f.__class__`. Closes #3070.
* | Merge pull request #3056 from charris/2to3-filterCharles Harris2013-03-011-1/+1
|\ \ | |/ |/| 2to3: Apply `filter` fixes. Closes #3053.
| * REF: Replace filters with list comprehensions.Charles Harris2013-02-281-1/+1
| | | | | | | | | | | | 2to3 does a lot of list(filter(...)) sort of thing which can be avoided by using list comprehensions instead of filters. This also seems to clarify the code to a considerable degree.
| * 2to3: Apply `filter` fixes. Closes #3053.Charles Harris2013-02-281-1/+1
| | | | | | | | | | Generally, this involves using list comprehension, or explicit list construction as `filter` is an iterator in Python 3.
* | Merge pull request #3047 from charris/2to3-callablenjsmith2013-02-281-3/+4
|\ \ | | | | | | 2to3: Fix callable.
| * | 2to3: Fix callable.Charles Harris2013-02-281-3/+4
| |/
* | Merge pull request #3059 from charris/2to3-funcattrsnjsmith2013-02-281-1/+1
|\ \ | | | | | | 2to3: Apply `funcattrs` fixer. Closes #3058.
| * | 2to3: Apply `funcattrs` fixer. Closes #3058.Charles Harris2013-02-281-1/+1
| |/ | | | | | | | | This replaces the `b.func_xxxx` with newer `__xxxx__` attribute names For example, `f.__name__` replaces `f.func_name`
* | 2to3: apply exec fixer results.Charles Harris2013-02-282-3/+3
|/ | | | This changes the `exec` command to the `exec` function.
* 2to3: Use modern exception syntax.Charles Harris2013-02-262-2/+2
| | | | Example: except ValueError,msg: -> except ValueError as msg:
* DEP: Remove more references to scons related files.Charles Harris2013-01-141-2/+0
| | | | | | | These references were in MANIFEST.in, doc/summarize.py, release.sh, and numpy/testing/noseclasses.py and involved scons files that have been removed, mostly setupscons.py and setupsconsegg.py that were in the top level.
* DEP: Remove scons related files and code.Charles Harris2013-01-131-16/+0
| | | | | | | | | This removes files and code supporting scons builds. After this change numpy will only support builds using distutils or bento. The removal of scons has been discussed on the list several times and a decision has been made that scons support is no longer needed. This was originally discussed for numpy 1.7 and because the distutils and bento methods are still available we are skipping the usual deprecation period.
* TST: also filter Cython warnings in NoseTester. See PR-432.Ralf Gommers2012-11-211-0/+2
| | | | There a resetwarnings() call, so need to add back these filters.
* ENH: More capable test functions for warningsNathaniel J. Smith2012-09-202-4/+42
| | | | | | | 1) New function assert_no_warnings 2) Make assert_warns and assert_no_warnings pass through the function's return value on success, so that it can be checked as well.
* Merge pull request #348 from njsmith/fix-shufflenjsmith2012-07-171-4/+7
|\ | | | | [FIX] Make np.random.shuffle less brain-dead
| * [FIX] Make np.random.shuffle less brain-deadNathaniel J. Smith2012-07-171-4/+7
| | | | | | | | | | | | | | | | | | The logic in np.random.shuffle was... not very sensible. Fixes trac ticket #2074. This patch also exposes a completely unrelated issue in numpy.testing. Filed as Github issue #347 and marked as knownfail for now.
* | ENH: np.testing.decorators: Use Py3k compatible raise syntaxBradley M. Froehle2012-07-121-1/+1
|/
* DOC: merge wiki edits. Add percentile to statistics routines (ML suggestion).Ralf Gommers2012-07-071-5/+6
|
* Remove maskna API from ndarray, and all (and only) the code supporting itNathaniel J. Smith2012-06-161-37/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original masked-NA-NEP branch contained a large number of changes in addition to the core NA support. For example: - ufunc.__call__ support for where= argument - nditer support for arbitrary masks (in support of where=) - ufunc.reduce support for simultaneous reduction over multiple axes - a new "array assignment API" - ndarray.diagonal() returning a view in all cases - bug-fixes in __array_priority__ handling - datetime test changes etc. There's no consensus yet on what should be done with the maskna-related part of this branch, but the rest is generally useful and uncontroversial, so the goal of this branch is to identify exactly which code changes are involved in maskna support. The basic strategy used to create this patch was: - Remove the new masking-related fields from ndarray, so no arrays are masked - Go through and remove all the code that this makes dead/inaccessible/irrelevant, in a largely mechanical fashion. So for example, if I saw 'if (PyArray_HASMASK(a)) { ... }' then that whole block was obviously just dead code if no arrays have masks, and I removed it. Likewise for function arguments like skipna that are useless if there aren't any NAs to skip. This changed the signature of a number of functions that were newly exposed in the numpy public API. I've removed all such functions from the public API, since releasing them with the NA-less signature in 1.7 would create pointless compatibility hassles later if and when we add back the NA-related functionality. Most such functions are removed by this commit; the exception is PyArray_ReduceWrapper, which requires more extensive surgery, and will be handled in followup commits. I also removed the new ndarray.setasflat method. Reason: a comment noted that the only reason this was added was to allow easier testing of one branch of PyArray_CopyAsFlat. That branch is now the main branch, so that isn't an issue. Nonetheless this function is arguably useful, so perhaps it should have remained, but I judged that since numpy's API is already hairier than we would like, it's not a good idea to add extra hair "just in case". (Also AFAICT the test for this method in test_maskna was actually incorrect, as noted here: https://github.com/njsmith/numpyNEP/blob/master/numpyNEP.py so I'm not confident that it ever worked in master, though I haven't had a chance to follow-up on this.) I also removed numpy.count_reduce_items, since without skipna it became trivial. I believe that these are the only exceptions to the "remove dead code" strategy.
* BUG: fix running tests with coverage=True.Ralf Gommers2012-05-101-1/+1
| | | | | | | The --cover-inclusive argument means that coverage.py tries to include every single .py file in the source tree in the coverage report. This leads to test errors, because it tries to import files like setupscons.py (which will of course directly fail for anyone not having numscons installed).
* FIX: Implement Ralph's suggestion of removing category.Charles Harris2012-04-151-6/+2
|
* BUG: Fix testing failure on missing ImportWarning in Python 2.4.Charles Harris2012-04-151-14/+18
|
* TST: filter ImportWarnings in NoseTester.Ralf Gommers2012-04-141-0/+3
| | | | | | | | | | Warnings show up when a directory with the same name as a Python file or compiled extension is seen which doesn't have an __init__.py file in it. This situation is very common, for example in SciPy where many extensions are created from source files located under a directory with the same name. This filter is located within a context manager, so only filters when running tests.
* DOC: minor correction to NoseTester doc.Ralf Gommers2012-03-041-1/+1
|
* TST: add some string kw options to simplify switching NoseTester behavior.Ralf Gommers2012-03-041-15/+22
|
* TST: add "raise on warning" behavior to NoseTester constructor.Ralf Gommers2012-03-041-19/+31
| | | | | Also document that behavior has to be switched for a release, and remove comments on turning on deprecation warnings that don't apply anymore.
* WRN: A small tweak to make deprecation warnings always at least printMark Wiebe2012-03-041-0/+3
|
* TST,WRN: Add a parameter to control which warnings raise during testingMark Wiebe2012-03-041-7/+14
| | | | | | The default is set to (RuntimeWarning, DeprecationWarning), and the intent is to leave it as this on master, but change it to () immediately after branching for 1.7 in that branch.
* TST: Make RuntimeWarning raise an error during tests, same asMark Wiebe2012-02-081-0/+2
| | | | RegressionWarning