OwlCyberSecurity - MANAGER
Edit File: _polybase.cpython-38.pyc
U �p�]E� � @ sX d Z ddlmZmZmZ ddlZddlZddlZddl m Z dgZG dd� dej �ZdS )a Abstract base class for the various polynomial Classes. The ABCPolyBase class provides the methods needed to implement the common API for the various polynomial classes. It operates as a mixin, but uses the abc module from the stdlib, hence it is only available for Python >= 2.6. � )�division�absolute_import�print_functionN� )� polyutils�ABCPolyBasec @ s" e Zd ZdZdZdZdZeej dd� ��Z eej dd� ��Zeej dd � ��Zeej d d� ��Z eej dd � ��Zeej dd� ��Zeej dd� ��Zeej dd� ��Zeej d�dd���Zeej dd� ��Zeej dd� ��Zeej dd� ��Zeej dd� ��Zeej dd� ��Zeej d d!� ��Zeej d"d#� ��Zd$d%� Zd&d'� Zd(d)� Zd*d+� Zd,d-� Zd�d.d/�Z d0d1� Z!d2d3� Z"e#d4d5� �Z$ed6d7� �Z%d8d9� Z&d:d;� Z'd<d=� Z(d>d?� Z)d@dA� Z*dBdC� Z+dDdE� Z,dFdG� Z-dHdI� Z.dJdK� Z/dLdM� Z0dNdO� Z1dPdQ� Z2dRdS� Z3dTdU� Z4dVdW� Z5dXdY� Z6dZd[� Z7d\d]� Z8d^d_� Z9d`da� Z:dbdc� Z;ddde� Z<dfdg� Z=dhdi� Z>djdk� Z?dldm� Z@dndo� ZAdpdq� ZBdrds� ZCd�dudv�ZDdwdx� ZEd�dydz�ZFd{d|� ZGd}g dfd~d�ZHd�d�d��ZId�d�� ZJd�d�d��ZKe#d�d�d���ZLe#g dfd�d���ZMe#d�d�d���ZNe#d�d�d���ZOe#d�d�d���ZPdS )�r a� An abstract base class for immutable series classes. ABCPolyBase provides the standard Python numerical methods '+', '-', '*', '//', '%', 'divmod', '**', and '()' along with the methods listed below. .. versionadded:: 1.9.0 Parameters ---------- coef : array_like Series coefficients in order of increasing degree, i.e., ``(1, 2, 3)`` gives ``1*P_0(x) + 2*P_1(x) + 3*P_2(x)``, where ``P_i`` is the basis polynomials of degree ``i``. domain : (2,) array_like, optional Domain to use. The interval ``[domain[0], domain[1]]`` is mapped to the interval ``[window[0], window[1]]`` by shifting and scaling. The default value is the derived class domain. window : (2,) array_like, optional Window, see domain for its use. The default value is the derived class window. Attributes ---------- coef : (N,) ndarray Series coefficients in order of increasing degree. domain : (2,) ndarray Domain that is mapped to window. window : (2,) ndarray Window that domain is mapped to. Class Attributes ---------------- maxpower : int Maximum power allowed, i.e., the largest number ``n`` such that ``p(x)**n`` is allowed. This is to limit runaway polynomial size. domain : (2,) ndarray Default domain of the class. window : (2,) ndarray Default window of the class. N�d c C s d S �N� ��selfr r �</usr/lib/python3/dist-packages/numpy/polynomial/_polybase.py�domainH s zABCPolyBase.domainc C s d S r r r r r r �windowM s zABCPolyBase.windowc C s d S r r r r r r �nicknameR s zABCPolyBase.nicknamec C s d S r r r r r r � basis_nameW s zABCPolyBase.basis_namec C s d S r r �Zc1Zc2r r r �_add\ s zABCPolyBase._addc C s d S r r r r r r �_suba s zABCPolyBase._subc C s d S r r r r r r �_mulf s zABCPolyBase._mulc C s d S r r r r r r �_divk s zABCPolyBase._divc C s d S r r )�c�pow�maxpowerr r r �_powp s zABCPolyBase._powc C s d S r r )�xr r r r �_valu s zABCPolyBase._valc C s d S r r )r �m�k�lbnd�sclr r r �_intz s zABCPolyBase._intc C s d S r r )r r r r r r �_der s zABCPolyBase._derc C s d S r r )r �y�deg�rcond�fullr r r �_fit� s zABCPolyBase._fitc C s d S r r )�offr r r r �_line� s zABCPolyBase._linec C s d S r r )r r r r �_roots� s zABCPolyBase._rootsc C s d S r r )�rr r r � _fromroots� s zABCPolyBase._fromrootsc C s6 t | j�t |j�krdS t�| j|jk�s.dS dS dS )aG Check if coefficients match. .. versionadded:: 1.6.0 Parameters ---------- other : class instance The other class must have the ``coef`` attribute. Returns ------- bool : boolean True if the coefficients are the same, False otherwise. FTN)�len�coef�np�all�r �otherr r r �has_samecoef� s zABCPolyBase.has_samecoefc C s t �| j|jk�S )a? Check if domains match. .. versionadded:: 1.6.0 Parameters ---------- other : class instance The other class must have the ``domain`` attribute. Returns ------- bool : boolean True if the domains are the same, False otherwise. )r/ r0 r r1 r r r �has_samedomain� s zABCPolyBase.has_samedomainc C s t �| j|jk�S )a? Check if windows match. .. versionadded:: 1.6.0 Parameters ---------- other : class instance The other class must have the ``window`` attribute. Returns ------- bool : boolean True if the windows are the same, False otherwise. )r/ r0 r r1 r r r �has_samewindow� s zABCPolyBase.has_samewindowc C s t || j�S )a Check if types match. .. versionadded:: 1.7.0 Parameters ---------- other : object Class instance. Returns ------- bool : boolean True if other is same class as self )� isinstance� __class__r1 r r r �has_sametype� s zABCPolyBase.has_sametypec C s` t |t�r\t || j�s td��n6t�| j|jk�s<td��nt�| j|jk�sVtd��|jS |S )a� Interpret other as polynomial coefficients. The `other` argument is checked to see if it is of the same class as self with identical domain and window. If so, return its coefficients, otherwise return `other`. .. versionadded:: 1.9.0 Parameters ---------- other : anything Object to be checked. Returns ------- coef The coefficients of`other` if it is a compatible instance, of ABCPolyBase, otherwise `other`. Raises ------ TypeError When `other` is an incompatible instance of ABCPolyBase. zPolynomial types differzDomains differzWindows differ) r6 r r7 � TypeErrorr/ r0 r r r. r1 r r r �_get_coefficients� s zABCPolyBase._get_coefficientsc C s� t j|gdd�\}|| _|d k rLt j|gdd�\}t|�dkrFtd��|| _|d k r�t j|gdd�\}t|�dkrztd��|| _d S )NF��trim� z$Domain has wrong number of elements.z$Window has wrong number of elements.)�pu� as_seriesr. r- � ValueErrorr r )r r. r r r r r �__init__ s zABCPolyBase.__init__c C sR d}t | j�dd� }t | j�dd� }t | j�dd� }| jj}|||||f S )Nz%s(%s, domain=%s, window=%s)� ���)�reprr. r r r7 �__name__)r �formatr. r r �namer r r �__repr__ s zABCPolyBase.__repr__c C s d}t | j�}| j}|||f S )Nz%s(%s))�strr. r )r rF r. rG r r r �__str__! s zABCPolyBase.__str__c C s$ | j d krtd��dj| j ||d�S )NzbSubclasses must define either a basis name, or override _repr_latex_term(i, arg_str, needs_parens)z{{{basis}}}_{{{i}}}({arg_str}))�basis�i�arg_str)r �NotImplementedErrorrF )�clsrL rM �needs_parensr r r �_repr_latex_term' s � �zABCPolyBase._repr_latex_termc C s d� | �S )Nz\text{{{}}})rF )r r r r �_repr_latex_scalar2 s zABCPolyBase._repr_latex_scalarc C sh | � � \}}|dkr&|dkr&d}d}nX|dkrDd�| �|��}d}n:|dkrbd�| �|��}d}nd�| �|�| �|��}d}d j}g }t| j�D ]�\}}|dkr�d �| �|��} nLt|tj�s�d�| �|��} n.t� |�s�d�| �|��} nd �| �| ��} | � |||�} | dk�r| }nd�| | �}|dk�r<||�}|�|� q�|�rZd�|�}nd}d�|�S )Nr r r Fz{} + xTz{}xz{} + {}xz\color{{LightGray}}{{{}}}z{}z + ({})z + {}z - {}�1z{}\,{}� �0z$x \mapsto {}$) �mapparmsrF rR � enumerater. r6 �numbersZRealr/ ZsignbitrQ �append�join) r r( ZscaleZtermrP Zmute�partsrL r Zcoef_strZterm_str�partZbodyr r r �_repr_latex_8 sP ��� zABCPolyBase._repr_latex_c C s8 | j �� }| j�� |d<