Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

conftest.py 1.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  1. # MIT License
  2. #
  3. # Copyright (c) 2018 Dafiti OpenSource
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in all
  13. # copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22. """
  23. General fixtures for tests.
  24. """
  25. import os
  26. import numpy as np
  27. import pandas as pd
  28. import pytest
  29. @pytest.fixture
  30. def fix_path():
  31. p = os.path.dirname(os.path.abspath(__file__))
  32. p = os.path.join(p, 'fixtures')
  33. return p
  34. @pytest.fixture
  35. def rand_data():
  36. return pd.DataFrame(np.random.randn(200, 3), columns=["y", "x1", "x2"])
  37. @pytest.fixture
  38. def date_rand_data(rand_data):
  39. date_rand_data = rand_data.set_index(pd.date_range(
  40. start='20180101',
  41. periods=len(rand_data))
  42. )
  43. return date_rand_data
  44. @pytest.fixture
  45. def pre_int_period():
  46. return [0, 99]
  47. @pytest.fixture
  48. def post_int_period():
  49. return [100, 199]
  50. @pytest.fixture
  51. def pre_str_period():
  52. return ['20180101', '20180410']
  53. @pytest.fixture
  54. def post_str_period():
  55. return ['20180411', '20180719']
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...