Skip to content

Commit 426419c

Browse files
author
r730
committed
check pre commit
1 parent 1950bcf commit 426419c

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

src/dataset.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use polars::frame::DataFrame;
22

33
///
44
/// 数据集
5-
///
5+
///
66
trait Dataset{
77
///
88
/// Config被设计用来配置无法从数据中学习到的参数
9-
///
9+
///
1010
fn config(self, config: serde_json::Value);
1111

1212
///
@@ -16,8 +16,8 @@ trait Dataset{
1616
// - User load the Dataset object from the disk. 用户从磁盘加载Dataset对象。
1717
// - User call `setup_data` to load new data. 用户调用' setup_data '来加载新数据。
1818
// - User prepare data for model based on previous status. 用户根据以前的状态为模型准备数据。
19-
///
20-
///
19+
///
20+
///
2121
fn setup_date(self);
2222

2323
///
@@ -26,28 +26,28 @@ trait Dataset{
2626
// The method should:
2727
// - process the data
2828
// - return the processed data
29-
///
29+
///
3030
fn prepare(self);
3131
}
3232

3333
///
3434
/// 序列化
35-
///
35+
///
3636
trait Serializable{
3737
///
3838
/// 持久化
39-
///
39+
///
4040
fn to_pickle(self, path: String)->anyhow::Result<bool>;
4141

4242
///
4343
/// 加载持久化数据
44-
///
44+
///
4545
fn load(self, path: String) -> anyhow::Result<DataFrame>;
4646
}
4747

4848
///
4949
/// 数据加载
50-
///
50+
///
5151
trait DataLoader{
5252
fn load(self, instruments: String, start_end: StratEndRange) -> anyhow::Result<DataFrame>;
5353
}
@@ -58,8 +58,8 @@ trait DataLoader{
5858
// Only following data processing functions should be placed in Dataset: 数据集中只应放置以下数据处理函数:
5959
// - The processing is related to specific model. 处理与具体的模型有关。
6060
// - The processing is related to data split. 处理与数据分割有关。
61-
///
62-
///
61+
///
62+
///
6363
struct DatasetH{
6464
pub segments: Segments,
6565
pub handler: DataHandler
@@ -68,7 +68,7 @@ struct DatasetH{
6868
impl Dataset for DatasetH{
6969
///
7070
/// 解析配置
71-
///
71+
///
7272
fn config(self, config: serde_json::Value) {
7373
todo!()
7474
}
@@ -85,38 +85,38 @@ impl Dataset for DatasetH{
8585

8686
///
8787
/// 数据处理
88-
///
88+
///
8989
struct DataHandler{
9090
///
9191
/// The stock list to retrieve. 基线股票集合
92-
///
92+
///
9393
pub instruments: String,
9494

9595
///
9696
/// start_time of the original data. 原始数据的开始时间
97-
///
97+
///
9898
pub start_time: String,
9999

100100
///
101101
/// end_time of the original data. 原始数据的结束时间
102-
///
102+
///
103103
pub end_time :String,
104104

105105
///
106106
/// data loader to load the data.
107-
///
107+
///
108108
pub data_loader : Box<dyn DataLoader>,
109-
109+
110110
///
111111
/// initialize the original data in the constructor.
112-
///
112+
///
113113
pub init_data: String,
114-
114+
115115
///
116116
/// Return the original data instead of copy if possible.
117-
///
117+
///
118118
pub fetch_orig:bool,
119-
119+
120120
}
121121

122122
impl Serializable for DataHandler{
@@ -133,30 +133,30 @@ impl Serializable for DataHandler{
133133

134134
///
135135
/// 片段
136-
/// 1)
136+
/// 1)
137137
/// ```json
138138
/// 'segments': {
139139
/// 'train': ("2008-01-01", "2014-12-31"),
140140
/// 'valid': ("2017-01-01", "2020-08-01",),
141141
/// 'test': ("2015-01-01", "2016-12-31",),
142142
/// }
143143
/// ```
144-
/// 2)
144+
/// 2)
145145
/// ```json
146146
/// 'segments': {
147147
/// 'insample': ("2008-01-01", "2014-12-31"),
148148
/// 'outsample': ("2017-01-01", "2020-08-01",),
149149
/// }
150150
/// ```
151-
///
151+
///
152152
enum Segments{
153153
TVT(SegmentTVT),
154154
SIMPLE(SegmentsSimple)
155155
}
156156

157157
///
158158
/// 机器学习常用切片分组
159-
///
159+
///
160160
struct SegmentTVT{
161161
pub train: StratEndRange,
162162
pub valid: StratEndRange,
@@ -165,15 +165,15 @@ struct SegmentTVT{
165165

166166
///
167167
/// 简单切片,包含输入输出范围
168-
///
168+
///
169169
struct SegmentsSimple{
170170
pub insample: StratEndRange,
171171
pub outsample: StratEndRange
172172
}
173173

174174
///
175175
/// 开始结束范围
176-
///
176+
///
177177
struct StratEndRange{
178178
pub start: String,
179179
pub end: String,
@@ -187,19 +187,19 @@ mod dataset_works{
187187

188188
#[test]
189189
fn dataset_h_works(){
190-
let segments = Segments::TVT(super::SegmentTVT {
191-
train: super::StratEndRange {
190+
let segments = Segments::TVT(super::SegmentTVT {
191+
train: super::StratEndRange {
192192
start: String::from("2008-01-01"),
193-
end: String::from("2017-12-31")
194-
},
195-
valid: super::StratEndRange {
193+
end: String::from("2017-12-31")
194+
},
195+
valid: super::StratEndRange {
196196
start: String::from("2008-01-01"),
197-
end: String::from("2017-12-31")
198-
},
199-
test: super::StratEndRange {
197+
end: String::from("2017-12-31")
198+
},
199+
test: super::StratEndRange {
200200
start: String::from("2008-01-01"),
201-
end: String::from("2017-12-31")
202-
}
201+
end: String::from("2017-12-31")
202+
}
203203
});
204204

205205
let handler: DataHandler = DataHandler{ instruments: todo!(), start_time: todo!(), end_time: todo!(), data_loader: todo!(), init_data: todo!(), fetch_orig: todo!() };
@@ -209,8 +209,8 @@ mod dataset_works{
209209
handler: handler,
210210
};
211211

212-
212+
213213

214214

215215
}
216-
}
216+
}

0 commit comments

Comments
 (0)