summaryrefslogtreecommitdiff
path: root/numpy/polynomial/tests
Commit message (Collapse)AuthorAgeFilesLines
* TST: Add fixture to avoid issue with randomizing test order.Ross Barnowski2023-01-041-0/+4
|
* 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.
* MAINT: limit the number of decimals in Polynomial representation (#21654)Lev Maximov2022-06-141-39/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * limit the number of decimals in Polynomial representation * tests pass * parenthesize exponential notation in polynomials * fixed a long line warning * added polynomial printoptions tests * polynomial printoptions typo fixed * made switch to exp notation in polynomial display more natural * added a test on switching polynomials to exp notation * fixed linter errors/warnings * support for nanstr and infstr printoptions in polynomials * 10^8 threshold for switching to exp notation when displaying polynomials * merged in PR #21696 fixing issue #21695 * made linter happy * made some docstring tests pass * fixed the docs Co-authored-by: Lev Maximov <lev.maximov@gmail.com>
* ENH: Add support for symbol to polynomial package (#16154)Ross Barnowski2022-06-012-6/+289
| | | | | | | Adds a symbol attribute to the polynomials from the np.polynomial package to allow the user to control/modify the symbol used to represent the independent variable for a polynomial expression. This attribute corresponds to the variable attribute of the poly1d class from the old np.lib.polynomial module. Marked as draft for now as it depends on #15666 - all _str* and _repr* methods of ABCPolyBase and derived classes would need to be modified (and tested) to support this change. Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com>
* TST: increase error tol from 12 to 11 decimal places for test_approximationRaghuveer Devulapalli2021-08-241-1/+1
| | | | | SVML library is accurate upto 4ULP and hence reduces the accuracy slightly
* TST: Branch coverage improvement for `np.polynomial` (#18499)jbCodeHub2021-02-283-0/+34
| | | | | | | * 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
* TST: Fix crosstalk issues with polynomial str tests.Ross Barnowski2020-12-071-5/+8
| | | | | | | | | | | Polynomial printing tests implicitly depended on calling order, causing the test suite to fail when the test ordering was randomized with the pytest-random plugin (gh-17954). Two factors contributed to this: * Improper setting of class-level test config and * Poorly designed test that overrode an inherited class variable.
* Merge pull request #15666 from rossbar/enh/poly_strMatti Picus2020-06-041-20/+292
|\ | | | | ENH: Improved `__str__` for polynomials
| * Handle TypeError in _generate_str for coefs.Ross Barnowski2020-05-131-4/+45
| | | | | | | | | | | | Add a fallback for TypeErrors that are raised when attempting to compare arbitrary elements (e.g. strings or Python complex) to 0 in _generate_str.
| * ENH: Improved __str__, __format__ for polynomialsRoss Barnowski2020-05-071-20/+251
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes the printing style of instances of the convenience classes in the polynomial package to a more "human-readable" format. __str__ has been modified and __format__ added to ABCPolyBase, modifying the string representation of polynomial instances, e.g. when printed. __repr__ and the _repr_latex method (which is used in the Jupyter environment are unchanged. Two print formats have been added: 'unicode' and 'ascii'. 'unicode' is the default mode on *nix systems, and uses unicode values for numeric subscripts and superscripts in the polynomial expression. The 'ascii' format is the default on Windows (due to font considerations) and uses Python-style syntax to represent powers, e.g. x**2. The default printing style can be controlled at the package-level with the set_default_printstyle function. The ABCPolyBase.__str__ has also been made to respect the linewidth printoption. Other parameters from the printoptions dictionary are not used. Co-Authored-By: Warren Weckesser <warren.weckesser@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* | MAINT,TST: Move _repr_latex tests to test_printing.Ross Barnowski2020-04-212-50/+49
| | | | | | | | | | | | | | | | | | | | Organizational refactoring - the tests for the polynomial _repr_latex method were originally defined in test_classes.py. Based on the descriptions of the various test files, it is a better fit in test_printing.py. Updated docstring to reflect that _repr_latex is used in Jupyter environments, not IPython terminals (by default).
* | MAINT: simplify code that assumes str/unicode and int/long are different ↵Eric Wieser2020-03-261-2/+1
|/ | | | | types (#15816) Cleanup from the dropping of python 2
* Updated files in polynomial/ to use fstringsAnton Ritter-Gogerly2020-01-277-36/+36
|
* 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-059-66/+66
| | | | | | | 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-039-18/+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
|
* check also warning messagepatto902019-07-141-2/+3
|
* add test to hit RankWarning in polyutils._fitpatto902019-07-131-2/+12
|
* DEP: polynomial: Be stricter about integral argumentsEric Wieser2019-03-166-18/+18
| | | | | | | | | | | | | | | | | | | 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-266-6/+6
|
* TST: add missing tests for all polynomial subclass pow fns.Jeffrey Yancey2018-08-266-0/+66
|
* ENH: Add support for ipython latex printing to polynomialEric Wieser2018-08-121-0/+50
| | | | | | | | | | | | | | | Choices made, and the alternatives rejected (for no particularly strong reason): 1. Show terms in ascending order, to match their internal representation * alternative: descending, to match convention 2. Shows 0 terms in gray * alternative: omit entirely * alternative: show normally to aid comparison 3. Write each term as `basis(ax + b) * alternative: write as `basis(u) ... where u = ax + b` * alternative: show the normalized polynomial In future it would perhaps make sense to expose these options to the end user
* MAINT: move matrix tests in core, polynomial to matrixlib.Marten van Kerkwijk2018-04-291-3/+6
|
* TST: Replace yield tests in polynomial/tests/test_classes.Charles Harris2018-04-081-65/+49
|
* MAINT: Remove all uses of run_module_suite.Charles Harris2018-04-069-46/+2
| | | | | That function is nose specific and has not worked since `__init__` files were added to the tests directories.
* MAINT: Do not use random when testing roots.Charles Harris2018-02-161-3/+3
| | | | | | | | | | | The `check_roots` function in numpy/polynomial/tests/test_classes.py was using random numbers without a seed to generate the random roots to be checked. This made the test sensitive to the random state, with the result that currently two of the roots are close together and fail the test to the default seven digit precision when running on the Mac. The failure is probably due to a combination of library and compiler differences between the Mac and the other platforms tested.. The fix here is to hardwire the test values rather than use random numbers.
* TST: Add tests for `lbnd` and `scl` in polynomial integration.Charles Harris2017-10-266-0/+18
| | | | | | 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: update tests to remove unneeded whitespaceAllan Haldane2017-09-251-12/+12
|
* Merge pull request #9524 from charris/add_init_to_test_directoriesCharles Harris2017-08-121-0/+0
|\ | | | | TST, MAINT: Add `__init__.py` files to tests directories.
| * TST, MAINT: Add `__init__.py` files to tests directories.Charles Harris2017-08-061-0/+0
| | | | | | | | | | | | | | | | This allows pytest to run with duplicate test file names. Note that `python <path-to-test-file>` no longer works with this change, nor will a simple `pytest numpy`, because numpy is imported from the numpy repository. However, `python runtests.py` and `>>> numpy.test()` are still available.
* | BUG/TST: Fix the polynomial.test_printing tests, which never tested anything ↵Eric Wieser2017-08-101-25/+25
|/ | | | | | useful assert_ is not a substitute for assert_equal
* MAINT: Rename chebinterp to chebinterpolation and add test.Charles Harris2017-07-292-11/+41
| | | | | | | * Rename chebinterp to chebinterpolation as suggested. * Make some fixes to the Chebyshev class function. * Refactor TestInterpolation. * Add test for the Chebyshev.interpolation class function.
* ENH: Add np.polynomial.chebyshev.chebinterp functionLukas Mericle2017-07-241-0/+20
| | | | | | | | | The chebinterp function interpolates a function at the Chebyshev points of the first kind using a Chebyshev series. The resulting interpolation approximates a polynomial fit minimizing the L_inf norm. This function is useful e.g. for estimating roots before running a root-finding function.
* TST: Remove unittest dependencies in numpy/polynomial/tests.Charles Harris2017-07-248-78/+85
|
* ENH: Use `__array_ufunc__ = None` in polynomial convenience classes.Charles Harris2017-04-271-0/+8
| | | | | | | | Add `__array_ufunc__ = None` to ABCPolyBase. This ensures that polynomial convenience classes will not participate in ufuncs and will have priority when combined with an ndarray in a Python binary operator. `__array_priority__` is removed, as it is no longer needed.
* 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-196-6/+6
|
* TST: Add tests for check_fit with deg specified as listJonathan Underwood2016-01-181-0/+9
|
* TST: Add tests for hermefit with deg specified as listJonathan Underwood2016-01-181-0/+31
|
* TST: Add tests for polyfit with deg specified as listJonathan Underwood2016-01-181-0/+27
|
* TST: Add tests for lagfit with deg specified as listJonathan Underwood2016-01-181-0/+16
|
* TST: Add tests for hermfit with deg specified as listJonathan Underwood2016-01-181-0/+31
|
* TST: Add tests for chebfit with deg specified as listJonathan Underwood2016-01-181-0/+31
|
* TST: Add tests for legfit with deg specified as listJonathan Underwood2016-01-181-0/+31
|
* MAINT: Fix blemishes in numpy/polynomial/tests revealed by pyflakes.Charles Harris2014-07-296-13/+31
|
* STY: PEP8 fixes for numpy/polynomial/tests/*.py.Charles Harris2014-07-296-49/+49
| | | | Made conformant with the standards of scipy.