1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-07 21:11:50 +08:00

add custom_ops docstring

This commit is contained in:
bxdd
2021-06-24 15:00:45 +08:00
parent 0eee4a0f2e
commit 8d0b673341
2 changed files with 19 additions and 2 deletions

View File

@@ -195,7 +195,10 @@ MODE_CONF = {
"timeout": 100,
"logging_level": logging.INFO,
"region": REG_CN,
## Custom Operator
# custom operator
# each element of custom_ops should be Type[ExpressionOps] or dict
# if element of custom_ops is Type[ExpressionOps], it represents the custom operator class
# if element of custom_ops is dict, it represents the config of custom operator and should include `class` and `module_path` keys.
"custom_ops": [],
},
}

View File

@@ -10,6 +10,7 @@ import abc
import numpy as np
import pandas as pd
from typing import Union, List, Type
from scipy.stats import percentileofscore
from .base import Expression, ExpressionOps
@@ -1496,7 +1497,20 @@ class OpsWrapper:
def reset(self):
self._ops = {}
def register(self, ops_list):
def register(self, ops_list: List[Union[Type[ExpressionOps], dict]]):
"""register operator
Parameters
----------
ops_list : List[Union[Type[ExpressionOps], dict]]
- if type(ops_list) is List[Type[ExpressionOps]], each element of ops_list represents the operator class, which should be the subclass of `ExpressionOps`.
- if type(ops_list) is List[dict], each element of ops_list represents the config of operator, which has the following format:
{
"class": class_name,
"module_path": path,
}
Note: `class` should be the class name of operator, `module_path` should be a python module or path of file.
"""
for _operator in ops_list:
if isinstance(_operator, dict):
_ops_class, _ = get_cls_kwargs(_operator)