summaryrefslogtreecommitdiff
path: root/numpy/polynomial
Commit message (Collapse)AuthorAgeFilesLines
* BUG: Fix failure to return monic polynomials from roots.Charles Harris2013-07-022-3/+15
| | | | | | | | | | | | | | | | 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.
* BUG: Campanion Matrix was scalar, not matrix for degree 1.Charles Harris2013-06-2012-6/+102
| | | | | | | | 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.
* MAINT: Remove unneeded version checks.Charles Harris2013-04-241-10/+0
| | | | | | Now that only Python versions 2.6-2.7 and 3.2-3.3 are supported some version checks are no longer needed. This patch removes them so as to clean up the code.
* 2to3: Apply `print` fixer.Charles Harris2013-04-0619-20/+20
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* Merge pull request #460 from endolith/regex_formattingCharles Harris2013-04-037-10/+10
|\ | | | | DOC: Formatting fixes using regex
| * DOC: regex-assisted fixes of definition list formattingendolith2013-03-191-1/+1
| |
| * DOC: Used regex to find colons missing spaces which render wrong online, ↵endolith2013-03-196-9/+9
| | | | | | | | also other spacing or formatting mistakes
* | 2to3: Use absolute imports.Charles Harris2013-03-2818-49/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-276-18/+18
|/ | | | | | | | | | | | | | | 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
* 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-014-1/+7
| | | | | | | | 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.
* 2to3: apply exec fixer results.Charles Harris2013-02-286-6/+6
| | | | This changes the `exec` command to the `exec` function.
* MAINT: Use a better method to detect complex arrays.Charles Harris2013-01-246-6/+6
| | | | | | | | | | Instead of if lhs.dtype.char in np.typecodes['Complex']: use if issubclass(lhs.dtype.type, np.complexfloating):
* TST: Add Test for column scaling in the polynomial package fits.Charles Harris2013-01-236-0/+25
| | | | | | 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.
* BUG: gh-2790, fix column scaling in polynomial package least squares.Charles Harris2013-01-236-12/+48
| | | | | | | The columns should be scaled using their 2-norm, but in the complex case that was being incorrectly computed as the square root of the sum of the squared elements rather than as the square root of the sum of their squared real and imaginary parts.
* Remove maskna API from ndarray, and all (and only) the code supporting itNathaniel J. Smith2012-06-1612-264/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* STY: Code cleanup in polynomial [*]fromroots functions.Charles Harris2012-02-056-18/+18
| | | | Use divmod instead of // and % separately.
* ENH: Improve the computation of polynomials from roots.Charles Harris2012-02-056-24/+66
| | | | | | | | | The original method was overly sensitive to roundoff. Of the two approaches considered, gauss integration or binary subdivision of the roots, the latter is more compatible with using other number representations such as mpmath. No method is going to be suitable for large numbers of arbitrary zeros but the current method is a significant improvement.
* TST: Remove docstring from test_class_methods.Charles Harris2012-01-091-17/+1
| | | | And don't use the 'exec' statement to write the tests.
* DOC: Fix bogus output in polyval example.Charles Harris2012-01-091-4/+4
|
* DOC: Clarify the column order of 2-D and 3-D Vandermonde matrices.Charles Harris2012-01-096-72/+120
|
* DOC: Fix cut and paste error, derivative <- integral.Charles Harris2012-01-095-6/+6
|
* SPELL: Spellcheck the modules. Clarify an example.Charles Harris2012-01-098-179/+179
|
* ENH: Modify test classes to produce more informative test messages.Charles Harris2012-01-091-1/+19
| | | | | | 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.
* WHT: Whitespace cleanup.Charles Harris2012-01-091-1/+0
|
* REM: Remove deprecated imports from polynomial package.Charles Harris2012-01-091-290/+0
|
* TST: Add tests for NA support in the polynomial fitting functions.Charles Harris2012-01-096-0/+175
|
* ENH: Add support for NA to the least squares fitting routines.Charles Harris2012-01-097-80/+184
|
* TST: Add tests for mismatched types, domains, and windows.Charles Harris2012-01-091-0/+39
| | | | | Test that those combinations raise ValueError for the arithmetic operations of the convenience classes.
* BUG: The polynomial convenience classes let different types interact.Charles Harris2012-01-091-39/+60
| | | | | | | | | In particular for arithmetic where one could end up with a Polynomial type with Chebyshev coefficients after an addition. It is unlikely that that would be done on purpose. The PolyDomain error message was also replaced by a TypeError with an appropriate message. That seems like a better choice.
* DOC: Finish documenting new functions in the polynomial package.Charles Harris2012-01-096-427/+838
| | | | The old functions could use a review, but that isn't pressing.
* DOC: Document xxxfit functions in the polynomial package modules.Charles Harris2012-01-096-110/+160
|
* DOC: Revise documentation for the basic functions.Charles Harris2012-01-096-1149/+1408
| | | | Step 1 in the polynomial package documentation revisions.
* DOC: Rearrange the polynomial documents.Charles Harris2012-01-091-33/+56
| | | | | This is the first step in cleaning up the polynomial documentation and writing an instructional section on the convenience classes.
* HACK: Make __array_priority__ = 1000.Charles Harris2012-01-091-2/+3
| | | | | | | | | | | This works around changes in the treatment of __array_priority__ that were part of commit 32b32c2. Previously the rop's of the right hand object were called whenever it had the __array_priority__ attribute and was not an ndarray or derived thereof. After the change the object needed to have greater priority, in this case > 0. It isn't clear that the new behavior is the correct one and if it is reverted then setting __array_priority__ back to 0 will provide a test for that decision.
* TST: Finish moving class tests into test_classes.Charles Harris2012-01-097-750/+448
| | | | | | | 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-097-429/+245
|
* TST: Add tests for basis and cast static class methods.Charles Harris2012-01-097-377/+202
| | | | | | | 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.
* ENH: Add static methods basis and cast to the polynomial classes.Charles Harris2012-01-091-9/+80
| | | | | | | | | The new basis method is a convenient way to return an instance of the basis function of given degree for the class. It is intended mostly for pedagogical purposes. The new cast method provides an alternate way to convert an instance of one polynomial class to another. It complements the convert instance method.
* TST: Add tests for Gauss quadrature and weight functions.Charles Harris2012-01-095-106/+254
|
* ENH: Add functions for Gauss quadrature and associated weight functions.Charles Harris2012-01-095-5/+433
| | | | | | | | | | | | The new functions for Gauss quadrature are of the form xxxgauss, where xxx is any of cheb, leg, lag, herm, herme. They return the Gauss points and weights for Gauss quadrature of the various orthogonal polynomial types given the degree. They are tested to work up to degree 100. The new functions for the weight are of the form xxxweight, where xxx is any of cheb, leg, lag, herm, herme. They return the value of the weight function for the various orthogonal polynomial types given and array of points.
* BUG: Fix test that was in wrong spot.Charles Harris2012-01-091-4/+4
|
* ENH: Add companion matrix functions.Charles Harris2012-01-097-107/+299
| | | | | | | | | The new companion matrices are related to the old by a similarity transformation that makes them better conditioned for root finding. In particular, the companion matrices for the orthogonal polynomials are symmetric when the zeros of a single polynomial term is wanted. This produces better zeros for use in Gauss quadrature.
* TST: Add tests for multidimensional coefficient array functionality.Charles Harris2012-01-096-395/+1163
| | | | | Test the multi-dimensional coefficient array functionality. Reorganize and cleanup some previous tests.
* BUG: Small fixes and additionsCharles Harris2012-01-096-66/+190
| | | | | | | | Where xxx is one of poly, cheb, leg, lag, herm, herme: Refactor xxxval2d, xxxval3d, xxxgrid2d, and xxxgrid3d for clarity. Check that coordinate arrays are compatible in xxxval2d, xxxval3d. Work around einsum bug that affected xxxvander3d.
* BUG: The derivative tests were using incorrect test coefficients.Charles Harris2012-01-096-18/+18
| | | | The coefficients used were [1] + [0]*i instead of [0]*i + [1].
* ENH: Make derivatives and integrals work on multidimensional array.Charles Harris2012-01-096-333/+556
| | | | | | | | | | An axis keyword was added to the function signatures of xxxder and xxxint, where xxx is any of poly, cheb, leg, lag, herm, herme. The evaluation method for the Chebeshev series was also changed to avoid using z_series and to more closely resemble the other implementations. At some point the z_series will be removed from the chebyshev module and only used for trigonometric series.
* ENH: Add functions for producing 2D and 3D pseudo Vandermonde matrices that ↵Charles Harris2012-01-096-18/+589
| | | | | | | | are useful for least squares fits to data depending on two or three variables using the various polynomial basis. The new functions have names polyvander2d, and polyvander3d, where 'poly' can be replaced by any of 'leg', 'cheb', 'lag', 'herm', or 'herme'.
* ENH: Modify the various polynomial series so that multidimensional ↵Charles Harris2012-01-096-222/+1361
| | | | | | | | | | coefficient arrays can be used. Add functions for evaluation of 2D and 3D polynomial series evaluated either on a specified set of points or on a cartesian product of 1D points. The new functions have names polyval2d, polygrid2d, polyval3d, and polygrid3d, where 'poly' can be replaced by any of 'leg', 'cheb', 'lag', 'herm', or 'herme'. These additional functions should cover the common multidimensional cases and provide examples for anyone who wants to go to higher dimensions.
* STY: Whitespace cleanup and double space between function definitions.Charles Harris2012-01-096-1/+24
|
* ENH: Add some tests for polynomial printing.Charles Harris2011-07-161-0/+81
|