mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-01 10:01:19 +08:00
broadcast_to and get single data
This commit is contained in:
committed by
you-n-g
parent
9446116642
commit
4da3f3b104
@@ -150,7 +150,7 @@ class CN1minNumpyQuote(BaseQuote):
|
||||
|
||||
# single data
|
||||
# If it don't consider the classification of single data, it will consume a lot of time.
|
||||
if is_single_value(start_time, end_time, self.freq) and method is not None:
|
||||
if is_single_value(start_time, end_time, self.freq):
|
||||
# this is a very special case.
|
||||
# skip aggregating function to speed-up the query calculation
|
||||
try:
|
||||
|
||||
@@ -335,7 +335,8 @@ class IndexData(metaclass=index_data_ops_creator):
|
||||
data_shape = tuple(data_shape)
|
||||
|
||||
# broadcast the data to expected shape
|
||||
self.data = np.broadcast_to(self.data, data_shape)
|
||||
if self.data.shape != data_shape:
|
||||
self.data = np.broadcast_to(self.data, data_shape)
|
||||
|
||||
self.data = self.data.astype(np.float64)
|
||||
# Please notice following cases when converting the type
|
||||
@@ -492,6 +493,8 @@ class SingleData(IndexData):
|
||||
elif isinstance(data, pd.Series):
|
||||
assert len(index) == 0
|
||||
index, data = data.index, data.values
|
||||
elif isinstance(data, (int, float, np.number)):
|
||||
data = [data]
|
||||
super().__init__(data, index)
|
||||
assert self.ndim == 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user