
    HR-e                         d dl Z d dlmZ d dlmZ d dlZd dlmZ d dl	m
Z
 d dlmZ ddlmZ g Zd	d
gZddZ eddd          d             Z eddd          d             Zd ZdS )    N)inf)Number)Quantity)
isiterable)
deprecated   )unitsinf_likevectorize_if_neededc                       t          j        t                    S t          j                    fd            t	          j                   _        S )a  Vectorize a method of redshift(s).

    Parameters
    ----------
    func : callable or None
        method to wrap. If `None` returns a :func:`functools.partial`
        with ``nin`` loaded.
    nin : int
        Number of positional redshift arguments.

    Returns
    -------
    wrapper : callable
        :func:`functools.wraps` of ``func`` where the first ``nin``
        arguments are converted from |Quantity| to :class:`numpy.ndarray`.
    N)ninc                     d |d         D             }t          d |D                       r | g||d         R i |S  j        | g||d         R i |S )z
        :func:`functools.wraps` of ``func`` where the first ``nin``
        arguments are converted from |Quantity| to `numpy.ndarray` or scalar.
        c                 z    g | ]8}t          |t                    s|n|                    t          j                  9S  )
isinstancer   to_valuecuredshift.0zs     7lib/python3.11/site-packages/astropy/cosmology/utils.py
<listcomp>z>vectorize_redshift_method.<locals>.wrapper.<locals>.<listcomp>1   sI     
 
 
  8,,IAA!**R[2I2I
 
 
    Nc              3   X   K   | ]%}t          |t          t          j        f          V  &d S )N)r   r   npgenericr   s     r   	<genexpr>z=vectorize_redshift_method.<locals>.wrapper.<locals>.<genexpr>6   s3      ??qz!fbj122??????r   )all__vectorized__)selfargskwargszsfuncr   wrappers       r   r&   z*vectorize_redshift_method.<locals>.wrapper)   s    
 
$3$Z
 
 

 ??B????? 	:49r9DJ999&999%w%dGRG$stt*GGGGGGr   )	functoolspartialvectorize_redshift_methodwrapsr   	vectorizer    )r%   r   r&   s   ``@r   r)   r)      s}    $ | !:DDDD_TH H H H H H H"  \$//G Nr   z5.0zSvectorize_if_needed has been removed because it constructs a new ufunc on each callz<use a pre-vectorized function instead for a target array 'z')sincemessagealternativec                 z    t          t          t          |                    r t          j        | fi || n | | S )a  Helper function to vectorize scalar functions on array inputs.

    Parameters
    ----------
    f : callable
        'f' must accept positional arguments and no mandatory keyword
        arguments.
    *x
        Arguments into ``f``.
    **vkw
        Keyword arguments into :class:`numpy.vectorize`.

    Examples
    --------
    >>> func = lambda x: x ** 2
    >>> vectorize_if_needed(func, 2)
    4
    >>> vectorize_if_needed(func, [2, 3])
    array([4, 9])
    )anymapr   r   r+   )fxvkws      r   r   r   A   sF    : *-SQ-?-?)@)@K!2<!!S!!1%%aaeKr   z[inf_like has been removed because it duplicates functionality provided by numpy.full_like()z@Use numpy.full_like(z, numpy.inf) instead for a target array 'z'c                 z    t          j        |           rt          n t          j        | t          t                    S )aL  Return the shape of x with value infinity and dtype='float'.

    Preserves 'shape' for both array and scalar inputs.
    But always returns a float array, even if x is of integer type.

    Parameters
    ----------
    x : scalar or array-like
        Must work with functions `numpy.isscalar` and `numpy.full_like` (if `x`
        is not a scalar`

    Returns
    -------
    `math.inf` or ndarray[float] thereof
        Returns a scalar `~math.inf` if `x` is a scalar, an array of floats
        otherwise.

    Examples
    --------
    >>> inf_like(0.)  # float scalar
    inf
    >>> inf_like(1)  # integer scalar should give float output
    inf
    >>> inf_like([0., 1., 2., 3.])  # float list
    array([inf, inf, inf, inf])
    >>> inf_like([0, 1, 2, 3])  # integer list should give float output
    array([inf, inf, inf, inf])
    )dtype)r   isscalarr   	full_likefloat)r3   s    r   r
   r
   a   s-    J +a..G33bl1c&G&G&GGr   c                     t          | t          t          j        f          r| S t	          | d          r&t	          | d          r| t
          j        z  j        S | S t          | t
          j                  j        S )z
    Redshift as a `~numbers.Number` or `~numpy.ndarray` / |Quantity| / |Column|.
    Allows for any ndarray ducktype by checking for attribute "shape".
    shapeunit)	r   r   r   r   hasattrr   r   valuer   )r   s    r   aszarrr?      sp    
 !fbj)** 	G		 1f 	,$++Ar{##))r   )Nr   )r'   mathr   numbersr   numpyr   astropy.unitsr   astropy.utilsr   astropy.utils.decoratorsr    r	   r   __all____doctest_skip__r)   r   r
   r?   r   r   r   <module>rI      sK                       " " " " " " $ $ $ $ $ $ / / / / / /      
 56 * * * *Z 
	 O  L L L0 
	6 S  H H H@* * * * *r   