| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
SVML library is accurate upto 4ULP and hence reduces the accuracy
slightly
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
ENH: Improved `__str__` for polynomials
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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).
|
|/
|
|
|
| |
types (#15816)
Cleanup from the dropping of python 2
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
As numpy is Python 3 only, these import statements are now unnecessary
and don't alter runtime behavior.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
|
|
|
|
| |
That function is nose specific and has not worked since `__init__` files
were added to the tests directories.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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, MAINT: Add `__init__.py` files to tests directories.
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
| |
useful
assert_ is not a substitute for assert_equal
|
|
|
|
|
|
|
| |
* Rename chebinterp to chebinterpolation as suggested.
* Make some fixes to the Chebyshev class function.
* Refactor TestInterpolation.
* Add test for the Chebyshev.interpolation class function.
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Made conformant with the standards of scipy.
|