conftest.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import numpy as np
  2. import pytest
  3. from pandas import (
  4. Series,
  5. array,
  6. )
  7. import pandas._testing as tm
  8. @pytest.fixture(params=[None, False])
  9. def sort(request):
  10. """
  11. Valid values for the 'sort' parameter used in the Index
  12. setops methods (intersection, union, etc.)
  13. Caution:
  14. Don't confuse this one with the "sort" fixture used
  15. for DataFrame.append or concat. That one has
  16. parameters [True, False].
  17. We can't combine them as sort=True is not permitted
  18. in the Index setops methods.
  19. """
  20. return request.param
  21. @pytest.fixture(params=["D", "3D", "-3D", "H", "2H", "-2H", "T", "2T", "S", "-3S"])
  22. def freq_sample(request):
  23. """
  24. Valid values for 'freq' parameter used to create date_range and
  25. timedelta_range..
  26. """
  27. return request.param
  28. @pytest.fixture(params=[list, tuple, np.array, array, Series])
  29. def listlike_box(request):
  30. """
  31. Types that may be passed as the indexer to searchsorted.
  32. """
  33. return request.param
  34. @pytest.fixture(
  35. params=tm.ALL_REAL_NUMPY_DTYPES
  36. + [
  37. "object",
  38. "category",
  39. "datetime64[ns]",
  40. "timedelta64[ns]",
  41. ]
  42. )
  43. def any_dtype_for_small_pos_integer_indexes(request):
  44. """
  45. Dtypes that can be given to an Index with small positive integers.
  46. This means that for any dtype `x` in the params list, `Index([1, 2, 3], dtype=x)` is
  47. valid and gives the correct Index (sub-)class.
  48. """
  49. return request.param