mirror of
https://github.com/microsoft/qlib.git
synced 2026-06-30 01:21:18 +08:00
* [840] - Test case for operators. * Move import to the head of file and add test_setting.
34 lines
870 B
Python
34 lines
870 B
Python
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()
|