conftest.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import numpy as np
  2. import pytest
  3. from pandas import (
  4. DataFrame,
  5. Index,
  6. MultiIndex,
  7. Series,
  8. date_range,
  9. )
  10. @pytest.fixture
  11. def series_ints():
  12. return Series(np.random.default_rng(2).random(4), index=np.arange(0, 8, 2))
  13. @pytest.fixture
  14. def frame_ints():
  15. return DataFrame(
  16. np.random.default_rng(2).standard_normal((4, 4)),
  17. index=np.arange(0, 8, 2),
  18. columns=np.arange(0, 12, 3),
  19. )
  20. @pytest.fixture
  21. def series_uints():
  22. return Series(
  23. np.random.default_rng(2).random(4),
  24. index=Index(np.arange(0, 8, 2, dtype=np.uint64)),
  25. )
  26. @pytest.fixture
  27. def frame_uints():
  28. return DataFrame(
  29. np.random.default_rng(2).standard_normal((4, 4)),
  30. index=Index(range(0, 8, 2), dtype=np.uint64),
  31. columns=Index(range(0, 12, 3), dtype=np.uint64),
  32. )
  33. @pytest.fixture
  34. def series_labels():
  35. return Series(np.random.default_rng(2).standard_normal(4), index=list("abcd"))
  36. @pytest.fixture
  37. def frame_labels():
  38. return DataFrame(
  39. np.random.default_rng(2).standard_normal((4, 4)),
  40. index=list("abcd"),
  41. columns=list("ABCD"),
  42. )
  43. @pytest.fixture
  44. def series_ts():
  45. return Series(
  46. np.random.default_rng(2).standard_normal(4),
  47. index=date_range("20130101", periods=4),
  48. )
  49. @pytest.fixture
  50. def frame_ts():
  51. return DataFrame(
  52. np.random.default_rng(2).standard_normal((4, 4)),
  53. index=date_range("20130101", periods=4),
  54. )
  55. @pytest.fixture
  56. def series_floats():
  57. return Series(
  58. np.random.default_rng(2).random(4),
  59. index=Index(range(0, 8, 2), dtype=np.float64),
  60. )
  61. @pytest.fixture
  62. def frame_floats():
  63. return DataFrame(
  64. np.random.default_rng(2).standard_normal((4, 4)),
  65. index=Index(range(0, 8, 2), dtype=np.float64),
  66. columns=Index(range(0, 12, 3), dtype=np.float64),
  67. )
  68. @pytest.fixture
  69. def series_mixed():
  70. return Series(np.random.default_rng(2).standard_normal(4), index=[2, 4, "null", 8])
  71. @pytest.fixture
  72. def frame_mixed():
  73. return DataFrame(
  74. np.random.default_rng(2).standard_normal((4, 4)), index=[2, 4, "null", 8]
  75. )
  76. @pytest.fixture
  77. def frame_empty():
  78. return DataFrame()
  79. @pytest.fixture
  80. def series_empty():
  81. return Series(dtype=object)
  82. @pytest.fixture
  83. def frame_multi():
  84. return DataFrame(
  85. np.random.default_rng(2).standard_normal((4, 4)),
  86. index=MultiIndex.from_product([[1, 2], [3, 4]]),
  87. columns=MultiIndex.from_product([[5, 6], [7, 8]]),
  88. )
  89. @pytest.fixture
  90. def series_multi():
  91. return Series(
  92. np.random.default_rng(2).random(4),
  93. index=MultiIndex.from_product([[1, 2], [3, 4]]),
  94. )