summaryrefslogtreecommitdiff
path: root/numpy/polynomial/tests/test_polynomial.py
Commit message (Collapse)AuthorAgeFilesLines
* Added pickle test for polynomialsMatteo Raso2022-11-261-0/+6
|
* BUG: Polynomials now copy properly (#22669)Matteo Raso2022-11-251-0/+5
| | | | | | | | On line 502, self.symbol.copy() was called, which causes an AttributeError, since self.symbol is a string, so it doesn't have a copy() method. To fix it, I simply removed the copy() and directly assigned the string.
* TST: Branch coverage improvement for `np.polynomial` (#18499)jbCodeHub2021-02-281-0/+7
| | | | | | | * added tests for vander_nd in test_polyutils to cover some of the missed branches * added tests to polyline and vander to improve branch coverage * added tests to test_legendre.py to improve branch coverage
* Updated files in polynomial/ to use fstringsAnton Ritter-Gogerly2020-01-271-5/+5
|
* MAINT: Ragged cleanup (#15085)Matti Picus2020-01-151-3/+5
| | | | | | | | | | | | * TST: refactor sorter tests, use proper ragged array creation syntax * MAINT: code never hit the exception, but would error when iterating * MAINT: pytest.mark.parametrize did not add much, removing (from review) * MAINT: use asanyarray and generalize (from review) Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-8/+8
| | | | | | | Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-031-2/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* TST: hit the deprecationwarningpatto902019-07-141-1/+3
|
* DEP: polynomial: Be stricter about integral argumentsEric Wieser2019-03-161-3/+3
| | | | | | | | | | | | | | | | | | | This changes the behavior for: * The `deg` and `axis` arguments of `<type>der` * The `deg` and `axis` arguments of `<type>int` * The `deg` argument of `<type>gauss` * The `deg` argument of `<type>vander2d` * The `deg` argument of `<type>vander3d` The old behavior was: * Raise `ValueError` if the argument is a float, but not an integral one * Allow a float like `1.0` to mean `1`. This is inconsistent with most other integer-accepting APIs in numpy, which require these to be actual integers, and raise TypeError when they are not. The new behavior is: * Raise `TypeError` if the argument is a float, but not an integral one * Emit a `DeprecationWarning` if a float like `1.0` is passed, continuing to allow it its old meaning.
* BUG: polyval returned Non-Masked Arrays for Masked Input.Joachim Hereth2018-10-211-1/+14
| | | | | | | | This fix will preserve subtypes of ndarray when given as input (x) to the polyval function. In particular, the results for masked values of a masked array will be masked. Fixes #2477.
* MAINT: use reduce's defaul param rather than a ternary operatorJeffrey Yancey2018-08-261-1/+1
|
* TST: add missing tests for all polynomial subclass pow fns.Jeffrey Yancey2018-08-261-0/+11
|
* MAINT: Remove all uses of run_module_suite.Charles Harris2018-04-061-5/+0
| | | | | That function is nose specific and has not worked since `__init__` files were added to the tests directories.
* TST: Add tests for `lbnd` and `scl` in polynomial integration.Charles Harris2017-10-261-0/+3
| | | | | | The `lbnd` and `scl` parameters of the various polynomial integration functions are documented to be scalars. Add tests that those parameters are checked and ValueError raised when it is not so.
* TST: Remove unittest dependencies in numpy/polynomial/tests.Charles Harris2017-07-241-10/+11
|
* MAINT: refactor and small fixes to polyvalfromroots.Charles Harris2016-06-121-10/+15
| | | | | | | | | Simplify the logic a bit and make behavior consistent with polyval. Note that this adds a check that the number of dimensions of the array of the evaluation points is less than the number of dimensions of the array of roots when tensor=False. That check is missing from polyval and needs to be added.
* ENH: Add `polyrootval` to numpy.polynomiale-q2016-06-121-0/+59
| | | | | | | | | | | As one can easily encounter when working with high-order signal processing filters, converting a high-order polynomial from its roots to its polynomial coefficients can be quite lossy, leading to inaccuracies in the filter's properties. This PR adds a new function, `polyrootval` - based on `polyval` - that evaluates a polynomial given a list of its roots. The benefit of calculating it this way can be seen at scipy/scipy:6059. Some tests are included, as well.
* MAINT: Fix typos in docs/comment of `ma` and `polynomial` modules.Dongjoon Hyun2016-02-191-1/+1
|
* TST: Add tests for polyfit with deg specified as listJonathan Underwood2016-01-181-0/+27
|
* STY: PEP8 fixes for numpy/polynomial/tests/*.py.Charles Harris2014-07-291-8/+8
| | | | Made conformant with the standards of scipy.
* STY: Make numpy/polynomial/tests/*.py PEP8 compliant.Charles Harris2013-09-031-75/+72
| | | | Run autopep8 on the tests and fixup the results.
* STY: Giant comma spacing fixup.Charles Harris2013-08-181-36/+36
| | | | | | | 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.
* BUG: Campanion Matrix was scalar, not matrix for degree 1.Charles Harris2013-06-201-0/+15
| | | | | | | | The companion matrices returned by the various polynomial types was a scalar in the degree one case instead of a 2-D array. Fix that and add a test to check for that result. Closes #3459.
* 2to3: Apply `print` fixer.Charles Harris2013-04-061-1/+1
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* 2to3: Use absolute imports.Charles Harris2013-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-271-3/+3
| | | | | | | | | | | | | | | 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
* TST: Add Test for column scaling in the polynomial package fits.Charles Harris2013-01-231-0/+5
| | | | | | The test uses the complex set of sample points [1, 1j, -1, -1j] whose squared sum is exactly zero. This would fail before the column scaling was fixed.
* Remove maskna API from ndarray, and all (and only) the code supporting itNathaniel J. Smith2012-06-161-30/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* TST: Add tests for NA support in the polynomial fitting functions.Charles Harris2012-01-091-0/+30
|
* TST: Finish moving class tests into test_classes.Charles Harris2012-01-091-63/+0
| | | | | | | There are currently errors that will be fixed if pull #178 goes in. The tests were also changed to use generators, which makes them run noticeably slower but give better error messages and makes the tests a bit cleaner.
* TST: Move more tests into numpy/polynomial/tests/test_classes.pyCharles Harris2012-01-091-63/+0
|
* TST: Add tests for basis and cast static class methods.Charles Harris2012-01-091-63/+5
| | | | | | | A new test file, test_classes, has been added so that conversions between all the class types can be tested. Several tests common to all the classes were also moved to this file. Ideally all the common tests will be moved, but that isn't done yet.
* TST: Add tests for multidimensional coefficient array functionality.Charles Harris2012-01-091-23/+159
| | | | | Test the multi-dimensional coefficient array functionality. Reorganize and cleanup some previous tests.
* BUG: The derivative tests were using incorrect test coefficients.Charles Harris2012-01-091-3/+3
| | | | The coefficients used were [1] + [0]*i instead of [0]*i + [1].
* ENH: Rename test_trimdeg to test_cutdeg to match method and add ability toCharles Harris2011-03-131-1/+5
| | | | run as script.
* ENH: Add {cheb,poly}mulx functions as use them to simplify some code.Charles Harris2010-08-151-0/+8
| | | | Fix some documentation.
* BUG: Fix integration of zero polynomials.Charles Harris2010-08-151-2/+6
| | | | | | Remove checks that prevent use of foreign scalar types for lower bounds and integration constants. Cleanup code a bit.
* Merge branch 'wgt'Charles Harris2010-07-181-9/+38
|
* CHG: Rename reduce method in polytemplate to cutdeg. Reduce is just tooCharles Harris2010-06-071-7/+7
| | | | much like a ufunc and a bit vague.
* CHG: Use [] instead of 'default' to specify the default domain inCharles Harris2010-05-231-2/+3
| | | | Chebyshev.fit and Polynomial.fit. Document the change from numpy 1.4.x.
* ENH: Add reduce method to polynomial.Chebyshev andCharles Harris2010-05-231-0/+8
| | | | | | polynomial.Polynomial. This method behaves like truncate except it takes the degree of the result instead of the number of coefficients.
* REV: Revert the changes to the truncate method of Polynomial and Chebyshev.Charles Harris2010-05-231-4/+4
| | | | | On second thought it was a bad idea to make such a radical change to existing behaviour. It was also hard to document the variations ;)
* CHG: Change the default domain for the fit class method of theCharles Harris2010-05-211-0/+6
| | | | | | | | | Chebyshev and Polynomial classes to None. Add 'default' as a possible value of the domain argument to specify the default domain. This change fits better with my experience with this method. I feel it is safe to make this change at this late date because the functions seem little used as yet and I would like to get them 'right' before folks catch on to their presence.
* CHG: Change the truncate method of the Chebyshev and Polynomial classesCharles Harris2010-05-211-4/+5
| | | | | | to take degree instead of length. This seems to fit better with normal usage. I feel this change is safe at this time because these new classes seem to be little used as yet.
* ENH: Add degree method to the Chebyshev and Polynomial classes.Charles Harris2010-05-211-0/+3
|
* ENH:Charles Harris2010-05-211-0/+7
| | | | | | | 1) Let {poly,cheb}int accept 0 for the number of integrations. 2) Let {poly,cheb}(int,der} accept floating integers for number of integrations or derivations, raise ValueError otherwise. 3) Add tests for same.
* BUG: Fix bug in lbnd implementation of the integ method of the Chebyshev andCharles Harris2010-02-271-0/+2
| | | | Polynomial classes.
* 3K: polynomial: make tests to importPauli Virtanen2010-02-211-1/+0
|
* Small cleanups in polynomial modules.Charles Harris2009-11-281-1/+1
|
* Add support for chebyshev series and polynomials.Charles Harris2009-11-141-0/+436
New modules chebyshev and polynomial are added. The new polynomial module is not compatible with the current polynomial support in numpy, but is much like the new chebyshev module. The most noticeable difference to most will be that coefficients are specified from low to high power, that the low level functions do *not* accept the Chebyshev and Polynomial classes as arguements, and that the Chebyshev and Polynomial classes include a domain. Mapping between domains is a linear substitution and the two classes can be converted one to the other, allowing, for instance, a Chebyshev series in one domain to be expanded as a polynomial in another domain. The new modules are not automatically imported into the numpy namespace, they must be explicitly brought in with a "import numpy.polynomial" statement.