Current File : //usr/lib64/python2.7/site-packages/numpy/polynomial/polyutils.pyo |
�
E�`Qc
@ s d Z d d l m Z d d d d d d d d
d d g
Z d d
l Z d d
l Z d d
l Z d e f d � � YZ d e
f d � � YZ d e f d � � YZ d e
f d � � YZ e j d d k r� d � Z n d � Z e d � Z d d � Z d � Z d � Z d � Z d
S( s
Utililty objects for the polynomial modules.
This module provides: error and warning objects; a polynomial base class;
and some routines used in both the `polynomial` and `chebyshev` modules.
Error objects
-------------
- `PolyError` -- base class for this sub-package's errors.
- `PolyDomainError` -- raised when domains are "mismatched."
Warning objects
---------------
- `RankWarning` -- raised by a least-squares fit when a rank-deficient
matrix is encountered.
Base class
----------
- `PolyBase` -- The base class for the `Polynomial` and `Chebyshev`
classes.
Functions
---------
- `as_series` -- turns a list of array_likes into 1-D arrays of common
type.
- `trimseq` -- removes trailing zeros.
- `trimcoef` -- removes trailing coefficients that are less than a given
magnitude (thereby removing the corresponding terms).
- `getdomain` -- returns a domain appropriate for a given set of abscissae.
- `mapdomain` -- maps points between domains.
- `mapparms` -- parameters of the linear map between domains.
i����( t divisiont RankWarningt PolyErrort PolyDomainErrort PolyBaset as_seriest trimseqt trimcoeft getdomaint mapdomaint mapparmsNc B s e Z d Z RS( s; Issued by chebfit when the design matrix is rank deficient.( t __name__t
__module__t __doc__( ( ( s@ /usr/lib64/python2.7/site-packages/numpy/polynomial/polyutils.pyR 0 s c B s e Z d Z RS( s% Base class for errors in this module.( R R R
( ( ( s@ /usr/lib64/python2.7/site-packages/numpy/polynomial/polyutils.pyR 4 s c B s e Z d Z RS( s� Issued by the generic Poly class when two domains don't match.
This is raised when an binary operation is passed Poly objects with
different domains.
( R R R
( ( ( s@ /usr/lib64/python2.7/site-packages/numpy/polynomial/polyutils.pyR 8 s c B s e Z RS( ( R R ( ( ( s@ /usr/lib64/python2.7/site-packages/numpy/polynomial/polyutils.pyR E s i i c C s x | D] } | r t Sq Wt S( N( t Truet False( t iterablet element( ( s@ /usr/lib64/python2.7/site-packages/numpy/polynomial/polyutils.pyt anyL s
c C sa t | � d k r | Sx8 t t | � d d d � D] } | | d k r3 Pq3 q3 W| | d Sd S( s� Remove small Poly series coefficients.
Parameters
----------
seq : sequence
Sequence of Poly series coefficients. This routine fails for
empty sequences.
Returns
-------
series : sequence
Subsequence with trailing zeros removed. If the resulting sequence
would be empty, return the first element. The returned sequence may
or may not be a view.
Notes
-----
Do not lose the type info if the sequence contains unknown objects.
i i i����N( t lent range( t seqt i( ( s@ /usr/lib64/python2.7/site-packages/numpy/polynomial/polyutils.pyR U s #c C s� g | D]! } t j | d d d d �^ q } t g | D] } | j ^ q8 � d k re t d � � n t g | D] } | j d k ^ qo � r� t d � � n | r� g | D] } t | � ^ q� } n t g | D] } | j t j t � k ^ q� � rvg } x� | D]m } | j t j t � k r\t j
t | � d t j t � �} | | (| j | � q| j | j
� � qWnW y t j | � } Wn t d � � n Xg | D]! } t j | d d d | �^ q�} | S( s�
Return argument as a list of 1-d arrays.
The returned list contains array(s) of dtype double, complex double, or
object. A 1-d argument of shape ``(N,)`` is parsed into ``N`` arrays of
size one; a 2-d argument of shape ``(M,N)`` is parsed into ``M`` arrays
of size ``N`` (i.e., is "parsed by row"); and a higher dimensional array
raises a Value Error if it is not first reshaped into either a 1-d or 2-d
array.
Parameters
----------
a : array_like
A 1- or 2-d array_like
trim : boolean, optional
When True, trailing zeros are removed from the inputs.
When False, the inputs are passed through intact.
Returns
-------
[a1, a2,...] : list of 1-D arrays
A copy of the input data as a list of 1-d arrays.
Raises
------
ValueError :
Raised when `as_series` cannot convert its input to 1-d arrays, or at
least one of the resulting arrays is empty.
Examples
--------
>>> from numpy import polynomial as P
>>> a = np.arange(4)
>>> P.as_series(a)
[array([ 0.]), array([ 1.]), array([ 2.]), array([ 3.])]
>>> b = np.arange(6).reshape((2,3))
>>> P.as_series(b)
[array([ 0., 1., 2.]), array([ 3., 4., 5.])]
t ndmini t copyi s Coefficient array is emptys Coefficient array is not 1-dt dtypes&