conftest.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. from datetime import (
  2. datetime,
  3. timedelta,
  4. )
  5. import numpy as np
  6. import pytest
  7. import pandas.util._test_decorators as td
  8. from pandas import (
  9. DataFrame,
  10. Series,
  11. bdate_range,
  12. )
  13. @pytest.fixture(params=[True, False])
  14. def raw(request):
  15. """raw keyword argument for rolling.apply"""
  16. return request.param
  17. @pytest.fixture(
  18. params=[
  19. "sum",
  20. "mean",
  21. "median",
  22. "max",
  23. "min",
  24. "var",
  25. "std",
  26. "kurt",
  27. "skew",
  28. "count",
  29. "sem",
  30. ]
  31. )
  32. def arithmetic_win_operators(request):
  33. return request.param
  34. @pytest.fixture(params=[True, False])
  35. def center(request):
  36. return request.param
  37. @pytest.fixture(params=[None, 1])
  38. def min_periods(request):
  39. return request.param
  40. @pytest.fixture(params=[True, False])
  41. def parallel(request):
  42. """parallel keyword argument for numba.jit"""
  43. return request.param
  44. # Can parameterize nogil & nopython over True | False, but limiting per
  45. # https://github.com/pandas-dev/pandas/pull/41971#issuecomment-860607472
  46. @pytest.fixture(params=[False])
  47. def nogil(request):
  48. """nogil keyword argument for numba.jit"""
  49. return request.param
  50. @pytest.fixture(params=[True])
  51. def nopython(request):
  52. """nopython keyword argument for numba.jit"""
  53. return request.param
  54. @pytest.fixture(params=[True, False])
  55. def adjust(request):
  56. """adjust keyword argument for ewm"""
  57. return request.param
  58. @pytest.fixture(params=[True, False])
  59. def ignore_na(request):
  60. """ignore_na keyword argument for ewm"""
  61. return request.param
  62. @pytest.fixture(params=[True, False])
  63. def numeric_only(request):
  64. """numeric_only keyword argument"""
  65. return request.param
  66. @pytest.fixture(
  67. params=[
  68. pytest.param("numba", marks=[td.skip_if_no("numba"), pytest.mark.single_cpu]),
  69. "cython",
  70. ]
  71. )
  72. def engine(request):
  73. """engine keyword argument for rolling.apply"""
  74. return request.param
  75. @pytest.fixture(
  76. params=[
  77. pytest.param(
  78. ("numba", True), marks=[td.skip_if_no("numba"), pytest.mark.single_cpu]
  79. ),
  80. ("cython", True),
  81. ("cython", False),
  82. ]
  83. )
  84. def engine_and_raw(request):
  85. """engine and raw keyword arguments for rolling.apply"""
  86. return request.param
  87. @pytest.fixture(params=["1 day", timedelta(days=1), np.timedelta64(1, "D")])
  88. def halflife_with_times(request):
  89. """Halflife argument for EWM when times is specified."""
  90. return request.param
  91. @pytest.fixture
  92. def series():
  93. """Make mocked series as fixture."""
  94. arr = np.random.default_rng(2).standard_normal(100)
  95. locs = np.arange(20, 40)
  96. arr[locs] = np.nan
  97. series = Series(arr, index=bdate_range(datetime(2009, 1, 1), periods=100))
  98. return series
  99. @pytest.fixture
  100. def frame():
  101. """Make mocked frame as fixture."""
  102. return DataFrame(
  103. np.random.default_rng(2).standard_normal((100, 10)),
  104. index=bdate_range(datetime(2009, 1, 1), periods=100),
  105. )
  106. @pytest.fixture(params=[None, 1, 2, 5, 10])
  107. def step(request):
  108. """step keyword argument for rolling window operations."""
  109. return request.param