def indexes(*, elements: st.SearchStrategy[Ex] = None, dtype: Any = None, min_size: int = 0, max_size: int = None, unique: bool = True) -> st.SearchStrategy[pandas.Index]: """Provides a strategy for producing a :class:`pandas.Index`. Arguments: * elements is a strategy which will be used to generate the individual values of the index. If None, it will be inferred from the dtype. Note: even if the elements strategy produces tuples, the generated value will not be a MultiIndex, but instead be a normal index whose elements are tuples. * dtype is the dtype of the resulting index. If None, it will be inferred from the elements strategy. At least one of dtype or elements must be provided. * min_size is the minimum number of elements in the index. * max_size is the maximum number of elements in the index. If None then it will default to a suitable small size. If you want larger indexes you should pass a max_size explicitly. * unique specifies whether all of the elements in the resulting index should be distinct. """ check_valid_size(min_size, "min_size") check_valid_size(max_size, "max_size") check_valid_interval(min_size, max_size, "min_size", "max_size") check_type(bool, unique, "unique") elements, dtype = elements_and_dtype(elements, dtype) if max_size is None: max_size = min_size + DEFAULT_MAX_SIZE return ValueIndexStrategy(elements, dtype, min_size, max_size, unique)
def range_indexes(min_size=0, max_size=None): """Provides a strategy which generates an :class:`~pandas.Index` whose values are 0, 1, ..., n for some n. Arguments: * min_size is the smallest number of elements the index can have. * max_size is the largest number of elements the index can have. If None it will default to some suitable value based on min_size. """ check_valid_size(min_size, 'min_size') check_valid_size(max_size, 'max_size') if max_size is None: max_size = min([min_size + DEFAULT_MAX_SIZE, 2**63 - 1]) check_valid_interval(min_size, max_size, 'min_size', 'max_size') return st.integers(min_size, max_size).map(pandas.RangeIndex)
def range_indexes(min_size=0, max_size=None): # type: (int, int) -> st.SearchStrategy[pandas.RangeIndex] """Provides a strategy which generates an :class:`~pandas.Index` whose values are 0, 1, ..., n for some n. Arguments: * min_size is the smallest number of elements the index can have. * max_size is the largest number of elements the index can have. If None it will default to some suitable value based on min_size. """ check_valid_size(min_size, "min_size") check_valid_size(max_size, "max_size") if max_size is None: max_size = min([min_size + DEFAULT_MAX_SIZE, 2 ** 63 - 1]) check_valid_interval(min_size, max_size, "min_size", "max_size") return st.integers(min_size, max_size).map(pandas.RangeIndex)
def indexes( elements=None, # type: st.SearchStrategy[Ex] dtype=None, # type: Any min_size=0, # type: int max_size=None, # type: int unique=True, # type: bool ): """Provides a strategy for producing a :class:`pandas.Index`. Arguments: * elements is a strategy which will be used to generate the individual values of the index. If None, it will be inferred from the dtype. Note: even if the elements strategy produces tuples, the generated value will not be a MultiIndex, but instead be a normal index whose elements are tuples. * dtype is the dtype of the resulting index. If None, it will be inferred from the elements strategy. At least one of dtype or elements must be provided. * min_size is the minimum number of elements in the index. * max_size is the maximum number of elements in the index. If None then it will default to a suitable small size. If you want larger indexes you should pass a max_size explicitly. * unique specifies whether all of the elements in the resulting index should be distinct. """ check_valid_size(min_size, "min_size") check_valid_size(max_size, "max_size") check_valid_interval(min_size, max_size, "min_size", "max_size") check_type(bool, unique, "unique") elements, dtype = elements_and_dtype(elements, dtype) if max_size is None: max_size = min_size + DEFAULT_MAX_SIZE return ValueIndexStrategy(elements, dtype, min_size, max_size, unique)
# I really never thought I'd be testing variable function inputs at any point in my life... @hs.composite def functions(draw, name=None min_argc=None, # int max_argc=None, # int manual_argument_bindings=None, # {} dict manual_keyword_bindings=None, # {} dict body=_phony_callable, decorators=None, # [] list kwarginit=hs.nothing(), ): """DOCUMENT ME!!!""" # Replicates check_valid_sizes logic but with correct variable names check_valid_size(min_argc, "min_argc") check_valid_size(max_argc, "max_argc") check_valid_interval(min_argc, max_argc, "min_argc", "max_argc") min_argc = None if min_argc is None else ceil(min_argc) max_argc = None if max_argc is None else floor(max_argc) check_strategy(kwarginit, name="kwarginit") if decorators is not None: check_type(list, decorators, "decorators") for index, d in enumerate(decorators): _check_callable(d, name="iteration %r in 'decorators'" % (index)) _check_callable(body, name="body")