o
    i                     @  s  d dl mZ d dlm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 d dlmZmZ d d	lmZ d d
lmZmZ erhd dlZd dlmZ d dlmZmZ ejdkrbd dlmZ nd dlmZ ed	d+dd eddd,ddZ ed	d+ddd dddd-d)d*Z!dS ).    )annotations)Sequence)TYPE_CHECKINGAnyN)InvalidArgument)
deprecated)is_polars_dtype)
_COL_LIMITcolumn)lists)_instantiate_dtypedtypes)SearchStrategy)OneOrMoreDataTypesPolarsDataType)      zX`columns` is deprecated; use `column` instead, in conjunction with a list comprehension.F)dtypemin_colsmax_colsuniquecolsint | Sequence[str] | Noner   OneOrMoreDataTypes | Noner   intr   r   boolreturnlist[column]c          
        s   | du rt j||d } t| trdd t| D }n| }t|}|du r,dg| }n0t|r6|g| }n&t|trSt| }|krPd| d| d}	t	|	|}n	|d}	t	|	 fd	dt
||d
dD S )aG  
    Define multiple columns for use with the @dataframes strategy.

    .. deprecated:: 0.20.26
        Use :class:`column` instead, in conjunction with a list comprehension.

    .. warning::
        This functionality is currently considered **unstable**. It may be
        changed at any point without it being considered a breaking change.

    Generate a fixed sequence of `column` objects suitable for passing to the
    @dataframes strategy, or using standalone (note that this function is not itself
    a strategy).

    Notes
    -----
    Additional control is available by creating a sequence of columns explicitly,
    using the `column` class (an especially useful option is to override the default
    data-generating strategy for a given col/dtype).

    Parameters
    ----------
    cols : {int, [str]}, optional
        integer number of cols to create, or explicit list of column names. if
        omitted a random number of columns (between mincol and max_cols) are
        created.
    dtype : PolarsDataType, optional
        a single dtype for all cols, or list of dtypes (the same length as `cols`).
        if omitted, each generated column is assigned a random dtype.
    min_cols : int, optional
        if not passing an exact size, can set a minimum here (defaults to 0).
    max_cols : int, optional
        if not passing an exact size, can set a maximum value here (defaults to
        MAX_COLS).
    unique : bool, optional
        indicate if the values generated for these columns should be unique
        (per-column).

    Examples
    --------
    >>> from polars.testing.parametric import columns, dataframes
    >>> from hypothesis import given
    >>> @given(dataframes(columns(["x", "y", "z"], unique=True)))  # doctest: +SKIP
    ... def test_unique_xyz(df: pl.DataFrame) -> None:
    ...     assert_something(df)
    N)Z	min_valueZ	max_valuec                 S  s   g | ]}d | qS )col ).0nr   r   b/home/app/Keep/.python/lib/python3.10/site-packages/polars/testing/parametric/strategies/legacy.py
<listcomp>Z   s    zcolumns.<locals>.<listcomp>zgiven z dtypes for z namesz is not a valid polars datatypec                   s   g | ]\}}t || d qS ))namer   r   )r
   )r    nmtpr   r   r"   r#   m   s    T)strict)stZintegersexample
isinstancer   rangelenr   r   r   zip)
r   r   r   r   r   namesZn_colsr   Zn_dtypesmsgr   r'   r"   columns   s(   ;



r1   z:`create_list_strategy` is deprecated; use `lists` instead.)select_fromsizemin_sizemax_sizer   inner_dtypePolarsDataType | Noner2   Sequence[Any] | Noner3   
int | Noner4   r5   SearchStrategy[list[Any]]c                C  sB   |dur| }}| du rt   } nt|  } t| ||||dS )a  
    Create a strategy for generating Polars :class:`List` data.

    .. deprecated:: 0.20.26
        Use :func:`lists` instead.

    Parameters
    ----------
    inner_dtype : PolarsDataType
        type of the inner list elements (can also be another List).
    select_from : list, optional
        randomly select the innermost values from this list (otherwise
        the default strategy associated with the innermost dtype is used).
    size : int, optional
        if set, generated lists will be of exactly this size (and
        ignore the min_size/max_size params).
    min_size : int, optional
        set the minimum size of the generated lists (default: 0 if unset).
    max_size : int, optional
        set the maximum size of the generated lists (default: 3 if
        min_size is unset or zero, otherwise 2x min_size).
    unique : bool, optional
        ensure that the generated lists contain unique values.

    Examples
    --------
    Create a strategy that generates a list of i32 values:

    >>> from polars.testing.parametric import create_list_strategy
    >>> lst = create_list_strategy(inner_dtype=pl.Int32)  # doctest: +SKIP
    >>> lst.example()  # doctest: +SKIP
    [-11330, 24030, 116]
    N)r2   r4   r5   r   )r   r*   r   r   )r6   r2   r3   r4   r5   r   r   r   r"   create_list_strategys   s   +r;   )N)r   r   r   r   r   r   r   r   r   r   r   r   )r6   r7   r2   r8   r3   r9   r4   r   r5   r9   r   r   r   r:   )"
__future__r   collections.abcr   typingr   r   Zhypothesis.strategies
strategiesr)   Zhypothesis.errorsr   Zpolars._utils.deprecationr   Zpolars.datatypesr   Z)polars.testing.parametric.strategies.corer	   r
   Z)polars.testing.parametric.strategies.datar   Z*polars.testing.parametric.strategies.dtyper   r   sysr   Zpolars._typingr   r   version_infowarningsZtyping_extensionsr1   r;   r   r   r   r"   <module>   sH    
S