MCPcopy
hub / github.com/microsoft/qlib / test_ops

Method test_ops

tests/misc/test_index_data.py:115–127  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

113 sd = idd.SingleData([1, 2, 3], index=timeindex)
114
115 def test_ops(self):
116 sd1 = idd.SingleData([1, 2, 3, 4], index=["foo", "bar", "f", "g"])
117 sd2 = idd.SingleData([1, 2, 3, 4], index=["foo", "bar", "f", "g"])
118 print(sd1 + sd2)
119 new_sd = sd2 * 2
120 self.assertTrue(new_sd.index == sd2.index)
121
122 sd1 = idd.SingleData([1, 2, None, 4], index=["foo", "bar", "f", "g"])
123 sd2 = idd.SingleData([1, 2, 3, None], index=["foo", "bar", "f", "g"])
124 self.assertTrue(np.isnan((sd1 + sd2).iloc[3]))
125 self.assertTrue(sd1.add(sd2).sum() == 13)
126
127 self.assertTrue(idd.sum_by_index([sd1, sd2], sd1.index, fill_value=0.0).sum() == 13)
128
129 def test_todo(self):
130 pass

Callers

nothing calls this directly

Calls 2

addMethod · 0.95
sumMethod · 0.45

Tested by

no test coverage detected