B
    d                 @   s   d dl Zd dlmZmZ d dlmZ d dlZd dlm	Z	 d dl
mZmZmZ dddd	d
ddgZG dd deZG dd deZG dd dedZG dd
 d
eZG dd dZG dd	 d	eeZG dd deeZdd ZG dd deeZdS )    N)ABCMetaabstractmethod)deepcopy)log)UnitQuantityUnitConversionErrorMissingDataAssociationException"IncompatibleUncertaintiesExceptionNDUncertaintyStdDevUncertaintyUnknownUncertaintyVarianceUncertaintyInverseVariancec               @   s   e Zd ZdZdS )r
   zThis exception should be used to indicate cases in which uncertainties
    with two different classes can not be propagated.
    N)__name__
__module____qualname____doc__ r   r   i/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/astropy/nddata/nduncertainty.pyr
      s   c               @   s   e Zd ZdZdS )r	   zThis exception should be used to indicate that an uncertainty instance
    has not been associated with a parent `~astropy.nddata.NDData` object.
    N)r   r   r   r   r   r   r   r   r	      s   c               @   s   e Zd ZdZd+ddZeedd Zedd	 Zed
d Z	e	j
dd Z	edd Zej
dd Zedd Zedd Zej
dd Zedd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zed#d$ Zed%d& Zed'd( Zed)d* ZdS ),r   a}  This is the metaclass for uncertainty classes used with `NDData`.

    Parameters
    ----------
    array : any type, optional
        The array or value (the parameter name is due to historical reasons) of
        the uncertainty. `numpy.ndarray`, `~astropy.units.Quantity` or
        `NDUncertainty` subclasses are recommended.
        If the `array` is `list`-like or `numpy.ndarray`-like it will be cast
        to a plain `numpy.ndarray`.
        Default is ``None``.

    unit : unit-like, optional
        Unit for the uncertainty ``array``. Strings that can be converted to a
        `~astropy.units.Unit` are allowed.
        Default is ``None``.

    copy : `bool`, optional
        Indicates whether to save the `array` as a copy. ``True`` copies it
        before saving, while ``False`` tries to save every parameter as
        reference. Note however that it is not always possible to save the
        input as reference.
        Default is ``True``.

    Raises
    ------
    IncompatibleUncertaintiesException
        If given another `NDUncertainty`-like class as ``array`` if their
        ``uncertainty_type`` is different.
    NTc             C   s   t |trP|j| jkrt|d k	r8||jkr8td n|jd k	rH|j}|j}nHt |t	r|d k	r|jd k	r||jkrtd n|jd k	r|j}|j
}|d krd | _n
t|| _|rt|}t|}|| _d | _d S )Nz;overwriting Uncertainty's current unit with specified unit.z8overwriting Quantity's current unit with specified unit.)
isinstancer   uncertainty_typer
   _unitr   infounitarrayr   valuer   r   parent_nddata)selfr   copyr   r   r   r   __init__?   s.    





zNDUncertainty.__init__c             C   s   dS )z`str` : Short description of the type of uncertainty.

        Defined as abstract property so subclasses *have* to override this.
        Nr   )r   r   r   r   r   d   s    zNDUncertainty.uncertainty_typec             C   s   dS )z`bool` : Supports uncertainty propagation with correlated                  uncertainties?

        .. versionadded:: 1.2
        Fr   )r   r   r   r   supports_correlatedm   s    z!NDUncertainty.supports_correlatedc             C   s   | j S )z3`numpy.ndarray` : the uncertainty's value.
        )_array)r   r   r   r   r   v   s    zNDUncertainty.arrayc             C   s*   t |ttjfr tj|ddd}|| _d S )NF)Zsubokr   )r   listnpndarrayr   r"   )r   r   r   r   r   r   |   s    c             C   s   | j S )zE`~astropy.units.Unit` : The unit of the uncertainty, if any.
        )r   )r   r   r   r   r      s    zNDUncertainty.unitc             C   sj   |dk	r`| j dk	rT| jj}y| || W n$ tk
rR   td||Y nX t|| _n|| _dS )z|
        The unit should be set to a value consistent with the parent NDData
        unit and the uncertainty type.
        Nz5Unit {} is incompatible with unit {} of parent nddata)	_parent_nddatar   r   _data_unit_to_uncertainty_unittor   formatr   r   )r   r   parent_unitr   r   r   r      s    
c             C   s   t | j| jd| jjdS )zJ
        This uncertainty as an `~astropy.units.Quantity` object.
        F)r   dtype)r   r   r   r+   )r   r   r   r   quantity   s    zNDUncertainty.quantityc             C   s   d}d}y
| j }W n tk
r.   t|Y nPX |dkrBt|n<t| j tjrn|   }|dkrjt| |S td | j S dS )z`NDData` : reference to `NDData` instance with this uncertainty.

        In case the reference is not set uncertainty propagation will not be
        possible since propagation might need the uncertain data besides the
        uncertainty.
        z3uncertainty is not associated with an NDData objectzthe associated NDData object was deleted and cannot be accessed anymore. You can prevent the NDData object from being deleted by assigning it to a variable. If this happened after unpickling make sure you pickle the parent not the uncertainty directly.Nz6parent_nddata should be a weakref to an NDData object.)r&   AttributeErrorr	   r   weakrefrefr   r   )r   Zno_parent_messageZparent_lost_messageparentZresolved_parentr   r   r   r      s    



zNDUncertainty.parent_nddatac             C   s   |d k	rt |tjst|}|| _|d k	r| jj}| jd kr\|d krNd | _q| || _nB| |}y|| j W n& tk
r   td	| j|Y nX d S )Nz8Unit {} of uncertainty incompatible with unit {} of data)
r   r.   r/   r&   r   r   r'   r(   r   r)   )r   r   r*   Zunit_from_datar   r   r   r      s     


c             C   s   dS )z
        Subclasses must override this property. It should take in a data unit
        and return the correct unit for the uncertainty given the uncertainty
        type.
        Nr   )r   r   r   r   r   r'      s    z,NDUncertainty._data_unit_to_uncertainty_unitc             C   sR   | j jd }ytj| jd|d}W n tk
r@   t| j}Y nX d||dgS )N(z, )	separatorprefix ))	__class__r   r$   Zarray2stringr   r-   strjoin)r   r3   bodyr   r   r   __repr__   s    zNDUncertainty.__repr__c             C   s4   y| j | j| jfS  tk
r.   | j | jd fS X d S )N)r"   r   r   r	   )r   r   r   r   __getstate__   s    zNDUncertainty.__getstate__c             C   sL   t |dkrtd|d | _|d | _|d }|d k	rBt|}|| _d S )N   z!The state should contain 3 items.r         )len	TypeErrorr"   r   r.   r/   r&   )r   stater0   r   r   r   __setstate__  s    


zNDUncertainty.__setstate__c             C   s   | j | j| | jddS )zKNormal slicing on the array, keep the unit and return a reference.
        F)r   r   )r6   r   r   )r   itemr   r   r   __getitem__  s    zNDUncertainty.__getitem__c             C   s   | j s,t|tjs|dkr,td| jj| |j	}|jdkrR| 
|||}nV|jdkrl| |||}n<|jdkr| |||}n"|jdkr| |||}ntd| j|dd	S )
a`  Calculate the resulting uncertainty given an operation on the data.

        .. versionadded:: 1.2

        Parameters
        ----------
        operation : callable
            The operation that is performed on the `NDData`. Supported are
            `numpy.add`, `numpy.subtract`, `numpy.multiply` and
            `numpy.true_divide` (or `numpy.divide`).

        other_nddata : `NDData` instance
            The second operand in the arithmetic operation.

        result_data : `~astropy.units.Quantity` or ndarray
            The result of the arithmetic operations on the data.

        correlation : `numpy.ndarray` or number
            The correlation (rho) is defined between the uncertainties in
            sigma_AB = sigma_A * sigma_B * rho. A value of ``0`` means
            uncorrelated operands.

        Returns
        -------
        resulting_uncertainty : `NDUncertainty` instance
            Another instance of the same `NDUncertainty` subclass containing
            the uncertainty of the result.

        Raises
        ------
        ValueError
            If the ``operation`` is not supported or if correlation is not zero
            but the subclass does not support correlated uncertainties.

        Notes
        -----
        First this method checks if a correlation is given and the subclass
        implements propagation with correlated uncertainties.
        Then the second uncertainty is converted (or an Exception is raised)
        to the same class in order to do the propagation.
        Then the appropriate propagation method is invoked and the result is
        returned.
        r   z={} does not support uncertainty propagation with correlation.addsubtractmultiply)Ztrue_dividedividezunsupported operationF)r   )r!   r   r$   r%   
ValueErrorr)   r6   r   _convert_uncertaintyZuncertainty_propagate_add_propagate_subtract_propagate_multiply_propagate_divide)r   Z	operationZother_nddataresult_datacorrelationother_uncertresultr   r   r   	propagate  s&    -



zNDUncertainty.propagatec             C   s.   t |tr&| j|jkr|S | |S ntdS )a  Checks if the uncertainties are compatible for propagation.

        Checks if the other uncertainty is `NDUncertainty`-like and if so
        verify that the uncertainty_type is equal. If the latter is not the
        case try returning ``self.__class__(other_uncert)``.

        Parameters
        ----------
        other_uncert : `NDUncertainty` subclass
            The other uncertainty.

        Returns
        -------
        other_uncert : `NDUncertainty` subclass
            but converted to a compatible `NDUncertainty` subclass if
            possible and necessary.

        Raises
        ------
        IncompatibleUncertaintiesException:
            If the other uncertainty cannot be converted to a compatible
            `NDUncertainty` subclass.
        N)r   r   r   r6   r
   )r   rQ   r   r   r   rJ   ^  s
    
z"NDUncertainty._convert_uncertaintyc             C   s   d S )Nr   )r   rQ   rO   rP   r   r   r   rK   ~  s    zNDUncertainty._propagate_addc             C   s   d S )Nr   )r   rQ   rO   rP   r   r   r   rL     s    z!NDUncertainty._propagate_subtractc             C   s   d S )Nr   )r   rQ   rO   rP   r   r   r   rM     s    z!NDUncertainty._propagate_multiplyc             C   s   d S )Nr   )r   rQ   rO   rP   r   r   r   rN     s    zNDUncertainty._propagate_divide)NTN)r   r   r   r   r    propertyr   r   r!   r   setterr   r,   r   r'   r:   r;   rB   rD   rS   rJ   rK   rL   rM   rN   r   r   r   r   r      s.   
%	%!		G )	metaclassc               @   sX   e Zd ZdZedd Zedd Zdd Zdd	 Zd
d Z	dd Z
dd Zdd ZdS )r   zThis class implements any unknown uncertainty type.

    The main purpose of having an unknown uncertainty class is to prevent
    uncertainty propagation.

    Parameters
    ----------
    args, kwargs :
        see `NDUncertainty`
    c             C   s   dS )zL`False` : Uncertainty propagation is *not* possible for this class.
        Fr   )r   r   r   r   r!     s    z&UnknownUncertainty.supports_correlatedc             C   s   dS )zq``"unknown"`` : `UnknownUncertainty` implements any unknown                            uncertainty type.
        unknownr   )r   r   r   r   r     s    z#UnknownUncertainty.uncertainty_typec             C   s   dS )z>
        No way to convert if uncertainty is unknown.
        Nr   )r   r   r   r   r   r'     s    z1UnknownUncertainty._data_unit_to_uncertainty_unitc             C   s   d}t |dS )zcRaise an Exception because unknown uncertainty types cannot
        implement propagation.
        z3Uncertainties of unknown type cannot be propagated.N)r
   )r   rQ   msgr   r   r   rJ     s    z'UnknownUncertainty._convert_uncertaintyc             C   s   dS )z4Not possible for unknown uncertainty types.
        Nr   )r   rQ   rO   rP   r   r   r   rK     s    z!UnknownUncertainty._propagate_addc             C   s   d S )Nr   )r   rQ   rO   rP   r   r   r   rL     s    z&UnknownUncertainty._propagate_subtractc             C   s   d S )Nr   )r   rQ   rO   rP   r   r   r   rM     s    z&UnknownUncertainty._propagate_multiplyc             C   s   d S )Nr   )r   rQ   rO   rP   r   r   r   rN     s    z$UnknownUncertainty._propagate_divideN)r   r   r   r   rT   r!   r   r'   rJ   rK   rL   rM   rN   r   r   r   r   r     s   
c               @   s@   e Zd ZdZddd dd fddZddd dd fd	d
ZdS )_VariancePropagationMixinz
    Propagation of uncertainties for variances, also used to perform error
    propagation for variance-like uncertainties (standard deviation and inverse
    variance).
    Fc             C   s   | S )Nr   )xr   r   r   <lambda>      z"_VariancePropagationMixin.<lambda>c             C   s$  |r
d}nd}y|j d }W n tk
r4   d}Y nX |jdk	r~|j dk	rr|||j krr||j|j > |j}	q||j}	nd}	| jdk	r| j dk	r|| j | jj d kr|| j| j > |j}
q|| j}
nd}
t|tjs|dkrd| t	|
|	  }|
|	 ||  }n|
|	 }||S )a`  
        Error propagation for addition or subtraction of variance or
        variance-like uncertainties. Uncertainties are calculated using the
        formulae for variance but can be used for uncertainty convertible to
        a variance.

        Parameters
        ----------

        other_uncert : `~astropy.nddata.NDUncertainty` instance
            The uncertainty, if any, of the other operand.

        result_data : `~astropy.nddata.NDData` instance
            The results of the operation on the data.

        correlation : float or array-like
            Correlation of the uncertainties.

        subtract : bool, optional
            If ``True``, propagate for subtraction, otherwise propagate for
            addition.

        to_variance : function, optional
            Function that will transform the input uncertainties to variance.
            The default assumes the uncertainty is the variance.

        from_variance : function, optional
            Function that will convert from variance to the input uncertainty.
            The default assumes the uncertainty is the variance.
        r=   r>   Nr   )
r   r-   r   r(   r   r   r   r$   r%   sqrt)r   rQ   rO   rP   rF   to_variancefrom_variancecorrelation_signZresult_unit_sqotherthiscorrrR   r   r   r   _propagate_add_sub  s0    !



 z,_VariancePropagationMixin._propagate_add_subc             C   s   | S )Nr   )rZ   r   r   r   r[     r\   c             C   s   | S )Nr   )rZ   r   r   r   r[      r\   c             C   s  t |tr|j}|rd}nd}|jdk	r|jrt|d|j d|jj d jkrt||j|j> d|jj d j}n
||j}t| jj	d | }	nd}	| jdk	r| jr|d| j d| jj d jkr|| j| j> d| jj d j}
n
|| j}
t|jj	d |
 }nd}t |tj
s0|dkrXd| t|
|  | jj	 |jj	 }nd}|r|||	 ||  |jj	d  S |||	 ||  S dS )ad  
        Error propagation for multiplication or division of variance or
        variance-like uncertainties. Uncertainties are calculated using the
        formulae for variance but can be used for uncertainty convertible to
        a variance.

        Parameters
        ----------

        other_uncert : `~astropy.nddata.NDUncertainty` instance
            The uncertainty, if any, of the other operand.

        result_data : `~astropy.nddata.NDData` instance
            The results of the operation on the data.

        correlation : float or array-like
            Correlation of the uncertainties.

        divide : bool, optional
            If ``True``, propagate for division, otherwise propagate for
            multiplication.

        to_variance : function, optional
            Function that will transform the input uncertainties to variance.
            The default assumes the uncertainty is the variance.

        from_variance : function, optional
            Function that will convert from variance to the input uncertainty.
            The default assumes the uncertainty is the variance.
        r]   r=   Nr>   r      )r   r   r   r   r   r   r(   r$   absdatar%   r^   )r   rQ   rO   rP   rH   r_   r`   ra   Zd_brightZd_aleftrd   r   r   r   _propagate_multiply_divide  s>    $



z4_VariancePropagationMixin._propagate_multiply_divideN)r   r   r   r   re   rk   r   r   r   r   rY     s   QrY   c                   sl   e Zd ZdZedd Zedd Zdd Z fdd	Z fd
dZ	 fddZ
 fddZdd Z  ZS )r   a  Standard deviation uncertainty assuming first order gaussian error
    propagation.

    This class implements uncertainty propagation for ``addition``,
    ``subtraction``, ``multiplication`` and ``division`` with other instances
    of `StdDevUncertainty`. The class can handle if the uncertainty has a
    unit that differs from (but is convertible to) the parents `NDData` unit.
    The unit of the resulting uncertainty will have the same unit as the
    resulting data. Also support for correlation is possible but requires the
    correlation as input. It cannot handle correlation determination itself.

    Parameters
    ----------
    args, kwargs :
        see `NDUncertainty`

    Examples
    --------
    `StdDevUncertainty` should always be associated with an `NDData`-like
    instance, either by creating it during initialization::

        >>> from astropy.nddata import NDData, StdDevUncertainty
        >>> ndd = NDData([1,2,3], unit='m',
        ...              uncertainty=StdDevUncertainty([0.1, 0.1, 0.1]))
        >>> ndd.uncertainty  # doctest: +FLOAT_CMP
        StdDevUncertainty([0.1, 0.1, 0.1])

    or by setting it manually on the `NDData` instance::

        >>> ndd.uncertainty = StdDevUncertainty([0.2], unit='m', copy=True)
        >>> ndd.uncertainty  # doctest: +FLOAT_CMP
        StdDevUncertainty([0.2])

    the uncertainty ``array`` can also be set directly::

        >>> ndd.uncertainty.array = 2
        >>> ndd.uncertainty
        StdDevUncertainty(2)

    .. note::
        The unit will not be displayed.
    c             C   s   dS )z`True` : `StdDevUncertainty` allows to propagate correlated                     uncertainties.

        ``correlation`` must be given, this class does not implement computing
        it by itself.
        Tr   )r   r   r   r   r!     s    z%StdDevUncertainty.supports_correlatedc             C   s   dS )zG``"std"`` : `StdDevUncertainty` implements standard deviation.
        Zstdr   )r   r   r   r   r     s    z"StdDevUncertainty.uncertainty_typec             C   s   t |tr|S td S )N)r   r   r
   )r   rQ   r   r   r   rJ     s    
z&StdDevUncertainty._convert_uncertaintyc                s   t  j|||dtjtjdS )NF)rF   r_   r`   )superre   r$   squarer^   )r   rQ   rO   rP   )r6   r   r   rK     s    
z StdDevUncertainty._propagate_addc                s   t  j|||dtjtjdS )NT)rF   r_   r`   )rl   re   r$   rm   r^   )r   rQ   rO   rP   )r6   r   r   rL     s    
z%StdDevUncertainty._propagate_subtractc                s   t  j|||dtjtjdS )NF)rH   r_   r`   )rl   rk   r$   rm   r^   )r   rQ   rO   rP   )r6   r   r   rM     s
    z%StdDevUncertainty._propagate_multiplyc                s   t  j|||dtjtjdS )NT)rH   r_   r`   )rl   rk   r$   rm   r^   )r   rQ   rO   rP   )r6   r   r   rN     s
    z#StdDevUncertainty._propagate_dividec             C   s   |S )Nr   )r   r   r   r   r   r'     s    z0StdDevUncertainty._data_unit_to_uncertainty_unit)r   r   r   r   rT   r!   r   rJ   rK   rL   rM   rN   r'   __classcell__r   r   )r6   r   r     s   *
c                   sd   e Zd ZdZedd Zedd Z fddZ fdd	Z fd
dZ	 fddZ
dd Z  ZS )r   a  
    Variance uncertainty assuming first order Gaussian error
    propagation.

    This class implements uncertainty propagation for ``addition``,
    ``subtraction``, ``multiplication`` and ``division`` with other instances
    of `VarianceUncertainty`. The class can handle if the uncertainty has a
    unit that differs from (but is convertible to) the parents `NDData` unit.
    The unit of the resulting uncertainty will be the square of the unit of the
    resulting data. Also support for correlation is possible but requires the
    correlation as input. It cannot handle correlation determination itself.

    Parameters
    ----------
    args, kwargs :
        see `NDUncertainty`

    Examples
    --------
    Compare this example to that in `StdDevUncertainty`; the uncertainties
    in the examples below are equivalent to the uncertainties in
    `StdDevUncertainty`.

    `VarianceUncertainty` should always be associated with an `NDData`-like
    instance, either by creating it during initialization::

        >>> from astropy.nddata import NDData, VarianceUncertainty
        >>> ndd = NDData([1,2,3], unit='m',
        ...              uncertainty=VarianceUncertainty([0.01, 0.01, 0.01]))
        >>> ndd.uncertainty  # doctest: +FLOAT_CMP
        VarianceUncertainty([0.01, 0.01, 0.01])

    or by setting it manually on the `NDData` instance::

        >>> ndd.uncertainty = VarianceUncertainty([0.04], unit='m^2', copy=True)
        >>> ndd.uncertainty  # doctest: +FLOAT_CMP
        VarianceUncertainty([0.04])

    the uncertainty ``array`` can also be set directly::

        >>> ndd.uncertainty.array = 4
        >>> ndd.uncertainty
        VarianceUncertainty(4)

    .. note::
        The unit will not be displayed.
    c             C   s   dS )z?``"var"`` : `VarianceUncertainty` implements variance.
        varr   )r   r   r   r   r      s    z$VarianceUncertainty.uncertainty_typec             C   s   dS )z`True` : `VarianceUncertainty` allows to propagate correlated                     uncertainties.

        ``correlation`` must be given, this class does not implement computing
        it by itself.
        Tr   )r   r   r   r   r!   &  s    z'VarianceUncertainty.supports_correlatedc                s   t  j|||ddS )NF)rF   )rl   re   )r   rQ   rO   rP   )r6   r   r   rK   0  s    
z"VarianceUncertainty._propagate_addc                s   t  j|||ddS )NT)rF   )rl   re   )r   rQ   rO   rP   )r6   r   r   rL   4  s    
z'VarianceUncertainty._propagate_subtractc                s   t  j|||ddS )NF)rH   )rl   rk   )r   rQ   rO   rP   )r6   r   r   rM   8  s    z'VarianceUncertainty._propagate_multiplyc                s   t  j|||ddS )NT)rH   )rl   rk   )r   rQ   rO   rP   )r6   r   r   rN   =  s    z%VarianceUncertainty._propagate_dividec             C   s   |d S )Nr>   r   )r   r   r   r   r   r'   B  s    z2VarianceUncertainty._data_unit_to_uncertainty_unit)r   r   r   r   rT   r   r!   rK   rL   rM   rN   r'   rn   r   r   )r6   r   r     s   /
c             C   s   d|  S )z4Just a simple inverse for use in the InverseVariancer=   r   )rZ   r   r   r   _inverseF  s    rp   c                   sd   e Zd ZdZedd Zedd Z fddZ fdd	Z fd
dZ	 fddZ
dd Z  ZS )r   a  
    Inverse variance uncertainty assuming first order Gaussian error
    propagation.

    This class implements uncertainty propagation for ``addition``,
    ``subtraction``, ``multiplication`` and ``division`` with other instances
    of `InverseVariance`. The class can handle if the uncertainty has a unit
    that differs from (but is convertible to) the parents `NDData` unit. The
    unit of the resulting uncertainty will the inverse square of the unit of
    the resulting data. Also support for correlation is possible but requires
    the correlation as input. It cannot handle correlation determination
    itself.

    Parameters
    ----------
    args, kwargs :
        see `NDUncertainty`

    Examples
    --------
    Compare this example to that in `StdDevUncertainty`; the uncertainties
    in the examples below are equivalent to the uncertainties in
    `StdDevUncertainty`.

    `InverseVariance` should always be associated with an `NDData`-like
    instance, either by creating it during initialization::

        >>> from astropy.nddata import NDData, InverseVariance
        >>> ndd = NDData([1,2,3], unit='m',
        ...              uncertainty=InverseVariance([100, 100, 100]))
        >>> ndd.uncertainty  # doctest: +FLOAT_CMP
        InverseVariance([100, 100, 100])

    or by setting it manually on the `NDData` instance::

        >>> ndd.uncertainty = InverseVariance([25], unit='1/m^2', copy=True)
        >>> ndd.uncertainty  # doctest: +FLOAT_CMP
        InverseVariance([25])

    the uncertainty ``array`` can also be set directly::

        >>> ndd.uncertainty.array = 0.25
        >>> ndd.uncertainty
        InverseVariance(0.25)

    .. note::
        The unit will not be displayed.
    c             C   s   dS )zD``"ivar"`` : `InverseVariance` implements inverse variance.
        Zivarr   )r   r   r   r   r   |  s    z InverseVariance.uncertainty_typec             C   s   dS )z`True` : `InverseVariance` allows to propagate correlated                     uncertainties.

        ``correlation`` must be given, this class does not implement computing
        it by itself.
        Tr   )r   r   r   r   r!     s    z#InverseVariance.supports_correlatedc                s   t  j|||dttdS )NF)rF   r_   r`   )rl   re   rp   )r   rQ   rO   rP   )r6   r   r   rK     s    
zInverseVariance._propagate_addc                s   t  j|||dttdS )NT)rF   r_   r`   )rl   re   rp   )r   rQ   rO   rP   )r6   r   r   rL     s    
z#InverseVariance._propagate_subtractc                s   t  j|||dttdS )NF)rH   r_   r`   )rl   rk   rp   )r   rQ   rO   rP   )r6   r   r   rM     s
    z#InverseVariance._propagate_multiplyc                s   t  j|||dttdS )NT)rH   r_   r`   )rl   rk   rp   )r   rQ   rO   rP   )r6   r   r   rN     s
    z!InverseVariance._propagate_dividec             C   s   d|d  S )Nr=   r>   r   )r   r   r   r   r   r'     s    z.InverseVariance._data_unit_to_uncertainty_unit)r   r   r   r   rT   r   r!   rK   rL   rM   rN   r'   rn   r   r   )r6   r   r   K  s   0
)numpyr$   abcr   r   r   r   r.   Zastropyr   Zastropy.unitsr   r   r   __all__	Exceptionr
   r	   r   r   rY   r   r   rp   r   r   r   r   r   <module>   s*     r5 M`V