o
    a                     @   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   7/usr/lib/python3/dist-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                    sf   t trt| tksJ |  fddt| D S t tr0|  fdd| D S t )Nc                 3   s    | ]
\}} ||V  qd S Nr   .0abopr   r   	<genexpr>&   s    z#Vector._vectorOp.<locals>.<genexpr>c                 3       | ]} |V  qd S r   r   r   vr   otherr   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 )Nc                 3   r   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       z"Vector._unaryOp.<locals>.<genexpr>r   )r   r   r   r   r   _unaryOp0      zVector._unaryOpc                 C      |  |tjS r   )r)   operatoraddr   r"   r   r   r   __add__3      zVector.__add__c                 C   r.   r   )r)   r/   subr1   r   r   r   __sub__8   r3   zVector.__sub__c                 C      |  |tS r   )r)   _operator_rsubr1   r   r   r   __rsub__;      zVector.__rsub__c                 C   r.   r   )r*   r/   mulr1   r   r   r   __mul__>   r3   zVector.__mul__c                 C   r.   r   )r*   r/   truedivr1   r   r   r   __truediv__C   r3   zVector.__truediv__c                 C   r6   r   )r*   _operator_rtruedivr1   r   r   r   __rtruediv__F   r9   zVector.__rtruediv__c                 C      |  tjS r   )r,   r/   posr   r   r   r   __pos__I   r9   zVector.__pos__c                 C   r@   r   )r,   r/   negr   r   r   r   __neg__L   r9   zVector.__neg__)roundc                C   s
   |  |S r   )r,   )r   rE   r   r   r   	__round__O   s   
zVector.__round__c                    s   t |tr	t|}t |S r   )r$   listtupler	   __eq__r1   r   r   r   rI   R   s   
zVector.__eq__c                 C   s   |  | S r   )rI   r1   r   r   r   __ne__X   r9   zVector.__ne__c                 C      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>)mathZsqrtsumr   r   r   r   __abs__`   r-   zVector.__abs__c                 C   rK   )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.rR   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   s    zVector.dot.<locals>.<genexpr>)r%   rP   r&   r1   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   rF   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   rG   r   r   r   r   r   z   s
   zVector.valuesc                 C   s   t d)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,   r2   __radd__r5   r8   r;   __rmul__r=   r?   rB   rD   rE   rF   rI   rJ   rM   Z__nonzero__rQ   rT   rU   rV   rW   propertyr   setter__classcell__r   r   r   r   r   
   s@    
c                 C      t || S r   )r/   r4   r   r   r   r   r   r7      r9   r7   c                 C   rb   r   )r/   r<   rc   r   r   r   r>      r9   r>   )
Znumbersr   rO   r/   r   __all__rH   r   r7   r>   r   r   r   r   <module>   s     