mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-07 13:00:58 +08:00
[840] - Test case for operators. (#841)
* [840] - Test case for operators. * Move import to the head of file and add test_setting.
This commit is contained in:
33
tests/ops/test_elem_operator.py
Normal file
33
tests/ops/test_elem_operator.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import unittest
|
||||
|
||||
from qlib.data import DatasetProvider
|
||||
from qlib.tests import TestOperatorData
|
||||
from qlib.config import C
|
||||
|
||||
|
||||
class TestOperatorDataSetting(TestOperatorData):
|
||||
def test_setting(self):
|
||||
self.assertEqual(len(self.instruments_d), 1)
|
||||
self.assertGreater(len(self.cal), 0)
|
||||
|
||||
|
||||
class TestElementOperator(TestOperatorData):
|
||||
def setUp(self) -> None:
|
||||
freq = "day"
|
||||
expressions = [
|
||||
"$change",
|
||||
"Abs($change)",
|
||||
]
|
||||
columns = ["change", "abs"]
|
||||
self.data = DatasetProvider.expression_calculator(
|
||||
self.inst, self.start_time, self.end_time, freq, expressions, self.spans, C, []
|
||||
)
|
||||
self.data.columns = columns
|
||||
|
||||
def test_abs(self):
|
||||
abs_values = self.data["abs"]
|
||||
self.assertGreater(abs_values[2], 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user