B
    Jd                 @   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k	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   G/var/www/html/venv/lib/python3.7/site-packages/fontTools/misc/vector.pyr
      s    zVector.__new__c                s   | j j dt   dS )N())r   __name__r	   __repr__)self)r   r   r   r       s    zVector.__repr__c                sj   t tr<t| tkst|  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>&   s    z#Vector._vectorOp.<locals>.<genexpr>c             3   s   | ]} |V  qd S )Nr   )r   v)r   otherr   r   r   (   s    )
isinstancer   lenAssertionErrorr   zipr   NotImplementedError)r   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 )Nr   )r   r   )r   r   r   r   r   -   s    z#Vector._scalarOp.<locals>.<genexpr>)r   r   r   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 )Nr   )r   r   )r   r   r   r   1   s    z"Vector._unaryOp.<locals>.<genexpr>)r   )r   r   r   )r   r   _unaryOp0   s    zVector._unaryOpc             C   s   |  |tjS )N)r    operatoradd)r   r   r   r   r   __add__3   s    zVector.__add__c             C   s   |  |tjS )N)r    r#   sub)r   r   r   r   r   __sub__8   s    zVector.__sub__c             C   s   |  |tS )N)r    _operator_rsub)r   r   r   r   r   __rsub__;   s    zVector.__rsub__c             C   s   |  |tjS )N)r!   r#   mul)r   r   r   r   r   __mul__>   s    zVector.__mul__c             C   s   |  |tjS )N)r!   r#   truediv)r   r   r   r   r   __truediv__C   s    zVector.__truediv__c             C   s   |  |tS )N)r!   _operator_rtruediv)r   r   r   r   r   __rtruediv__F   s    zVector.__rtruediv__c             C   s   |  tjS )N)r"   r#   pos)r   r   r   r   __pos__I   s    zVector.__pos__c             C   s   |  tjS )N)r"   r#   neg)r   r   r   r   __neg__L   s    zVector.__neg__)roundc            C   s
   |  |S )N)r"   )r   r4   r   r   r   	__round__O   s    zVector.__round__c                s   t |trt|}t |S )N)r   listtupler	   __eq__)r   r   )r   r   r   r8   R   s    
zVector.__eq__c             C   s   |  | S )N)r8   )r   r   r   r   r   __ne__X   s    zVector.__ne__c             C   s   t | S )N)any)r   r   r   r   __bool__[   s    zVector.__bool__c             C   s   t tdd | D S )Nc             s   s   | ]}|| V  qd S )Nr   )r   xr   r   r   r   a   s    z!Vector.__abs__.<locals>.<genexpr>)mathsqrtsum)r   r   r   r   __abs__`   s    zVector.__abs__c             C   s   t | S )z;Return the length of the vector. Equivalent to abs(vector).)abs)r   r   r   r   lengthc   s    zVector.lengthc             C   s   | t |  S )z+Return the normalized vector of the vector.)rA   )r   r   r   r   
normalizedg   s    zVector.normalizedc             C   s,   t | t |kst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 )Nr   )r   r   r   r   r   r   r   o   s    zVector.dot.<locals>.<genexpr>)r   r   r?   r   )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   r5   )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   r6   )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__r'   r)   r+   __rmul__r-   r/   r1   r3   r4   r5   r8   r9   r;   __nonzero__r@   rB   rC   rD   rE   propertyr   setter__classcell__r   r   )r   r   r   
   s:   	c             C   s   t || S )N)r#   r&   )r   r   r   r   r   r(      s    r(   c             C   s   t || S )N)r#   r,   )r   r   r   r   r   r.      s    r.   )
numbersr   r=   r#   r   __all__r7   r   r(   r.   r   r   r   r   <module>   s    