U
    d»{jä  ã                   @   s¾   d dl Z d dlZd dlmZmZ d dlmZ d dlmZ d dl	m
Z
 ddlmZ e  edd	d
d�¡Zeedd„ e d¡D ƒƒƒZddgeeƒ ZddgiZdd„ Zdd„ ZG dd„ de
ƒZdS )é    N)ÚOptionalÚUnion)Úget_pkg_data_path)Ú
deprecated)ÚScienceStateé   )Ú	CosmologyZ	cosmologyÚdataZastropy)Úpackagec                 c   s   | ]}|j V  qd S )N)Ústem)Ú.0Úp© r   ú]/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/cosmology/realizations.pyÚ	<genexpr>   s     r   z*.ecsvÚ	availableÚdefault_cosmologyÚ*Zscipyc                 C   sp   | t krtdt›d| ›d�ƒ‚tjtt|  ƒd dd�}| › d|jj› d|j	d	 › d
�|_
ttjt | |ƒ |S )zíMake specific realizations from data files with lazy import from
    `PEP 562 <https://www.python.org/dev/peps/pep-0562/>`_.

    Raises
    ------
    AttributeError
        If "name" is not in :mod:`astropy.cosmology.realizations`
    zmodule z has no attribute Ú.z.ecsvz
ascii.ecsv)Úformatz instance of z cosmology
(from Ú	referenceú))r   ÚAttributeErrorÚ__name__r   ÚreadÚstrÚ_COSMOLOGY_DATA_DIRÚ	__class__Ú__qualname__ÚmetaÚ__doc__ÚsetattrÚsysÚmodules)ÚnameZcosmor   r   r   Ú__getattr__   s    	 ÿÿr%   c                   C   s   t S )z-Directory, including lazily-imported objects.)Ú__all__r   r   r   r   Ú__dir__4   s    r'   c                   @   sf   e Zd ZdZdZdZeddd�edd„ ƒƒZee	e
edf ee
 d	œd
d„ƒZeee
dœdd„ƒZdS )r   a  The default cosmology to use.

    To change it::

        >>> from astropy.cosmology import default_cosmology, WMAP7
        >>> with default_cosmology.set(WMAP7):
        ...     # WMAP7 cosmology in effect
        ...     pass

    Or, you may use a string::

        >>> with default_cosmology.set('WMAP7'):
        ...     # WMAP7 cosmology in effect
        ...     pass

    To get the default cosmology:

        >>> default_cosmology.get()
        FlatLambdaCDM(name="Planck18", H0=67.66 km / (Mpc s), Om0=0.30966, ...
    ZPlanck18z5.0Úget)Úalternativec                 C   s   |dkrd}n
|   |¡}|S )z*Return a cosmology instance from a string.Ú
no_defaultN)Ú_get_from_registry)ÚclsÚargÚvaluer   r   r   Úget_cosmology_from_stringW   s    
z+default_cosmology.get_cosmology_from_stringN)r.   Úreturnc                 C   sP   |dkr| j }t|tƒr2|dkr&d}qL|  |¡}nt|tƒsLtd|› d�ƒ‚|S )aI  Return a Cosmology given a value.

        Parameters
        ----------
        value : None, str, or `~astropy.cosmology.Cosmology`

        Returns
        -------
        `~astropy.cosmology.Cosmology` instance

        Raises
        ------
        TypeError
            If ``value`` is not a string or |Cosmology|.
        Nr*   z>default_cosmology must be a string or Cosmology instance, not r   )Ú_default_valueÚ
isinstancer   r+   r   Ú	TypeError)r,   r.   r   r   r   Úvalidatea   s    


ÿzdefault_cosmology.validate)r$   r0   c                 C   s\   zt tjt |ƒ}W n( tk
r<   td|›dt› �ƒ‚Y nX t|tƒsXt	d|› d�ƒ‚|S )aß  Get a registered Cosmology realization.

        Parameters
        ----------
        name : str
            The built-in |Cosmology| realization to retrieve.

        Returns
        -------
        `astropy.cosmology.Cosmology`
            The cosmology realization of `name`.

        Raises
        ------
        ValueError
            If ``name`` is a str, but not for a built-in Cosmology.
        TypeError
            If ``name`` is for a non-Cosmology object.
        zUnknown cosmology z. Valid cosmologies:
z+cannot find a Cosmology realization called r   )
Úgetattrr"   r#   r   r   Ú
ValueErrorr   r2   r   r3   )r,   r$   r.   r   r   r   r+   …   s    ÿ

z$default_cosmology._get_from_registry)r   Ú
__module__r   r    r1   Ú_valuer   Úclassmethodr/   r   r   r   r   r4   r+   r   r   r   r   r   >   s   
 #)Úpathlibr"   Útypingr   r   Zastropy.utils.datar   Zastropy.utils.decoratorsr   Zastropy.utils.stater   Úcorer   ÚPathr   ÚtupleÚsortedÚglobr   Úlistr&   Z__doctest_requires__r%   r'   r   r   r   r   r   Ú<module>   s   ÿ

