
    wdX                     8    d dl mZ d dlZd dlZddgZddZd ZdS )	    )absolute_importNpromote	optionifyTc                 ~   | |k    r| S t          | d|           t          |d|          }}||cxk    rt          j        k    rn nt          j        }nXt          j        t          j        |          t          j        |                    }t          j                            |          }|rt          | ||          }|S )a  Promote two scalar dshapes to a possibly larger, but compatible type.

    Examples
    --------
    >>> from datashape import int32, int64, Option, string
    >>> x = Option(int32)
    >>> y = int64
    >>> promote(x, y)
    Option(ty=ctype("int64"))
    >>> promote(int64, int64)
    ctype("int64")

    Don't promote to option types.
    >>> promote(x, y, promote_option=False)
    ctype("int64")

    Strings are handled differently than NumPy, which promotes to ctype("object")
    >>> x = string
    >>> y = Option(string)
    >>> promote(x, y) == promote(y, x) == Option(string)
    True
    >>> promote(x, y, promote_option=False)
    ctype("string")

    Notes
    ----
    Except for ``datashape.string`` types, this uses ``numpy.result_type`` for
    type promotion logic.  See the numpy documentation at:

    http://docs.scipy.org/doc/numpy/reference/generated/numpy.result_type.html
    ty)	getattr	datashapestringnpresult_typeto_numpy_dtypeCTypefrom_numpy_dtyper   )lhsrhspromote_optionleftrightdtypenp_res_types          1lib/python3.11/site-packages/datashape/promote.pyr   r   
   s    @ cz 
#tS))73c+B+B%Du > > > >	( > > > > > nY%=d%C%C%.%=e%D%DF F00== +#sE**L    c                     t          |j        d          r|S t          | d          st          |d          rt          j        |          S |S )a  Check whether a binary operation's dshape came from
    :class:`~datashape.coretypes.Option` typed operands and construct an
    :class:`~datashape.coretypes.Option` type accordingly.

    Examples
    --------
    >>> from datashape import int32, int64, Option
    >>> x = Option(int32)
    >>> x
    Option(ty=ctype("int32"))
    >>> y = int64
    >>> y
    ctype("int64")
    >>> optionify(x, y, int64)
    Option(ty=ctype("int64"))
    r   )hasattrmeasurer	   Option)r   r   dshapes      r   r   r   9   sV    " v~t$$ sD (WS$// ('''Mr   )T)
__future__r   numpyr   r	   __all__r   r    r   r   <module>r"      si    & & & & & &         k
", , , ,^    r   