| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
| |
Run autopep8 on the tests and fixup the results.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This bug affected the various polynomial class methods fromroots due to
the ability to specify both window and domain. In that circumstance the
roots are mapped from the domain to the window by the substitution
`x = off + scl*x`. The polynomial that was being generated was monic in
the window before substitution, but if scl was not one it was not monic
considered as a function of the variable x in the domain. The fix is to
divide the generated coefficients by `scl ** deg` so that the scaling of
the highest degree term after substitution is canceled.
It might be better to make the scaling optional in the future, but this
fix makes the result match the documentation.
Closes #3467.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
Add `print_function` to all `from __future__ import ...` statements
and use the python3 print function syntax everywhere.
Closes #3078.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
And don't use the 'exec' statement to write the tests.
|
|
|
|
|
|
| |
The tests were all generator based and that produced the same message
for all the tests when they were run in verbose mode. The quick fix
was to use the generator to write named test functions for all the tests.
|