a
    w=ic                     @   sN   d dl mZ d dlZd dlZd dlZdgZG dd deZdd Zdd Z	dS )	    )NumberNVectorc                       s  e Zd ZdZdZd4 fdd	Z fddZdd	 Zd
d Zdd Z	dd Z
e
Zdd Zdd Zdd ZeZdd Zdd Zdd Zdd Zeddd Z fd!d"Zd#d$ Zd%d& ZeZd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zed1d2 Z e j!d3d2 Z   Z"S )5r   zA math-like vector.

    Represents an n-dimensional numeric vector. ``Vector`` objects support
    vector addition and subtraction, scalar multiplication and division,
    negation, rounding, and comparison tests.
     Fc                    s2   |durt dt t|tkr$|S t | |S )NFz'the 'keep' argument has been deprecated)warningswarnDeprecationWarningtyper   super__new__)clsvaluesZkeep	__class__r   f/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/misc/vector.pyr
      s    zVector.__new__c                    s   | j j dt   dS )N())r   __name__r	   __repr__selfr   r   r   r       s    zVector.__repr__c                    sj   t tr<t| tksJ |  fddt| D S t tr`|  fdd| D S t d S )Nc                 3   s   | ]\}} ||V  qd S Nr   .0abopr   r   	<genexpr>&       z#Vector._vectorOp.<locals>.<genexpr>c                 3   s   | ]} |V  qd S r   r   r   vr   otherr   r   r   (   r   )
isinstancer   lenr   zipr   NotImplementedErrorr   r"   r   r   r!   r   	_vectorOp#   s    

zVector._vectorOpc                    s.   t tr$|  fdd| D S t d S )Nc                 3   s   | ]} |V  qd S r   r   r   r!   r   r   r   -   r   z#Vector._scalarOp.<locals>.<genexpr>)r#   r   r   r&   r'   r   r!   r   	_scalarOp+   s    
zVector._scalarOpc                    s   |   fdd| D S )Nc                 3   s   | ]} |V  qd S r   r   r   r   r   r   r   1   r   z"Vector._unaryOp.<locals>.<genexpr>r   )r   r   r   r   r   _unaryOp0   s    zVector._unaryOpc                 C   s   |  |tjS r   )r(   operatoraddr   r"   r   r   r   __add__3   s    zVector.__add__c                 C   s   |  |tjS r   )r(   r+   subr-   r   r   r   __sub__8   s    zVector.__sub__c                 C   s   |  |tS r   )r(   _operator_rsubr-   r   r   r   __rsub__;   s    zVector.__rsub__c                 C   s   |  |tjS r   )r)   r+   mulr-   r   r   r   __mul__>   s    zVector.__mul__c                 C   s   |  |tjS r   )r)   r+   truedivr-   r   r   r   __truediv__C   s    zVector.__truediv__c                 C   s   |  |tS r   )r)   _operator_rtruedivr-   r   r   r   __rtruediv__F   s    zVector.__rtruediv__c                 C   s   |  tjS r   )r*   r+   posr   r   r   r   __pos__I   s    zVector.__pos__c                 C   s   |  tjS r   )r*   r+   negr   r   r   r   __neg__L   s    zVector.__neg__)roundc                C   s
   |  |S r   )r*   )r   r=   r   r   r   	__round__O   s    zVector.__round__c                    s   t |trt|}t |S r   )r#   listtupler	   __eq__r-   r   r   r   rA   R   s    
zVector.__eq__c                 C   s   |  | S r   )rA   r-   r   r   r   __ne__X   s    zVector.__ne__c                 C   s   t | S r   )anyr   r   r   r   __bool__[   s    zVector.__bool__c                 C   s   t tdd | D S )Nc                 s   s   | ]}|| V  qd S r   r   )r   xr   r   r   r   a   r   z!Vector.__abs__.<locals>.<genexpr>)mathsqrtsumr   r   r   r   __abs__`   s    zVector.__abs__c                 C   s   t | S )z;Return the length of the vector. Equivalent to abs(vector).absr   r   r   r   lengthc   s    zVector.lengthc                 C   s   | t |  S )z+Return the normalized vector of the vector.rJ   r   r   r   r   
normalizedg   s    zVector.normalizedc                 C   s,   t | t |ksJ tdd t| |D S )z[Performs vector dot product, returning the sum of
        ``a[0] * b[0], a[1] * b[1], ...``c                 s   s   | ]\}}|| V  qd S r   r   r   r   r   r   r   o   r   zVector.dot.<locals>.<genexpr>)r$   rH   r%   r-   r   r   r   dotk   s    z
Vector.dotc                 C   s   t dt |  S )NzAthe 'toInt' method has been deprecated, use round(vector) instead)r   r   r   r>   r   r   r   r   toInts   s
    zVector.toIntc                 C   s   t dt t| S )NzPthe 'values' attribute has been deprecated, use the vector object itself instead)r   r   r   r?   r   r   r   r   r   z   s
    zVector.valuesc                 C   s   t dd S )Nz?can't set attribute, the 'values' attribute has been deprecated)AttributeError)r   r   r   r   r   r      s    )F)#r   
__module____qualname____doc__	__slots__r
   r   r(   r)   r*   r.   __radd__r0   r2   r4   __rmul__r6   r8   r:   r<   r=   r>   rA   rB   rD   __nonzero__rI   rL   rM   rN   rO   propertyr   setter__classcell__r   r   r   r   r   
   s>   
c                 C   s   t || S r   )r+   r/   r   r   r   r   r   r1      s    r1   c                 C   s   t || S r   )r+   r5   r[   r   r   r   r7      s    r7   )
numbersr   rF   r+   r   __all__r@   r   r1   r7   r   r   r   r   <module>   s    