U
    e»{j—  ã                   @   s°   d dl Z d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
mZ d dlmZ dd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze j deƒ ¡dd„ ƒZdS )é    N)Úunits)Úmodels)Ú
_ModelMeta)Ú
Gaussian1DÚMappingÚPix2Sky_TAN)Úassert_quantity_allclosec                  C   sV   t dtj dtj dtj d�} | j ¡ }t|d dtj ƒ t|d dtj ƒ d S )Né   ©ÚmeanÚstddevÚ	amplituder   g®Gáz®@é   gR¸…ëQ	@)r   ÚuÚmÚcmÚJyZbounding_boxr   )ÚgZbbox© r   úk/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/modeling/tests/test_quantities_model.pyÚtest_gaussian1d_bounding_box   s     
r   c                  C   s�   t dtj dtj gdtj dtj gdtj dtj gdd�} t| dtj ƒd	d
gtj ƒ t| t dtj dtj g¡ƒd	dgtj ƒ d S )Nr   g       @iˆ  gš™™™™™¹?éd   é   )r   r   r   Zn_modelsg)\�Âõ(ð?g‚Ç–i$×ï?g        i’  góŽSt$×ÿ?)r   r   ÚJr   ZAAr   ZQuantity©r   r   r   r   Útest_gaussian1d_n_models   s    ü ÿr   c               	   C   sZ   t dtj dtj dtj d�} | dtj ƒ d}tjtj|d�� | dƒ W 5 Q R X dS )zW
    Test that if constructed with Quanties models must be called with quantities.
    r	   r
   é
   zP.* Units of input 'x', .* could not be converted to required input units of m .*)ÚmatchN)r   r   r   r   r   ÚpytestÚraisesZ
UnitsError)r   ZMESSAGEr   r   r   Útest_quantity_call)   s     ÿr    c                  C   s(   t dddd�} t| t ƒst‚| dƒ dS )z\
    Test that if not constructed with Quantites they can be called without quantities.
    r	   r
   r   N)r   Ú
isinstanceÚAssertionErrorr   r   r   r   Útest_no_quantity_call9   s    r#   c                  C   s8   t dtj dtj d�} t| t ƒs&t‚| dtj ƒ d S )Nr	   )r   r   r   )r   r   r   r   r!   r"   r   r   r   r   Útest_default_parametersB   s    r$   c                  C   s\   t dtj dtj dtj d�} | js*t‚t dddd�} | jrBt‚dtj | _| jsXt‚dS )ú
    Test Quantity
    r	   r
   N)r   r   r   r   r   Úuses_quantityr"   r   r   r   r   r   Útest_uses_quantityJ   s     

r'   c                  C   s€   t dtj dtj dtj d�} t dtj dtj dtj d�}| |B jsNt‚t dddd�} t dddd�}| |B }|jr|t‚dS )r%   r	   r
   é   N)r   r   r   r   r   r&   r"   )r   Úg2Úcompr   r   r   Útest_uses_quantity_compound[   s      r+   c                  C   s   t dƒtƒ B } | jst‚d S )N)r   r   )r   r   r&   r"   )r*   r   r   r   Útest_uses_quantity_no_paraml   s    r,   c               	   C   sV   g } t tƒD ]D}tt|ƒ}t|ƒtkrz
|ƒ }W n tk
rD   Y nX |  |¡ q| S )N)Údirr   ÚgetattrÚtyper   Ú	ExceptionÚappend)Z	allmodelsÚnameÚmodelr   r   r   r   Ú
_allmodelsr   s    

r4   r   c              	   C   st   t  t¡� i | _W 5 Q R X t  t¡� i | _W 5 Q R X t  t¡� i | _W 5 Q R X t  t¡� i | _W 5 Q R X dS )za
    input_units
    return_units
    input_units_allow_dimensionless
    input_units_strict
    N)r   r   ÚAttributeErrorZinput_unitsZreturn_unitsZinput_units_allow_dimensionlessZinput_units_strict)r   r   r   r   Útest_read_only   s    r6   )r   Zastropyr   r   Zastropy.modelingr   Zastropy.modeling.corer   Zastropy.modeling.modelsr   r   r   Zastropy.tests.helperr   r   r   r    r#   r$   r'   r+   r,   r4   ÚmarkZparametrizer6   r   r   r   r   Ú<module>   s    	