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

Method register

qlib/data/ops.py:1628–1659  ·  view source on GitHub ↗

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 t

(self, ops_list: List[Union[Type[ExpressionOps], dict]])

Source from the content-addressed store, hash-verified

1626 self._ops = {}
1627
1628 def register(self, ops_list: List[Union[Type[ExpressionOps], dict]]):
1629 """register operator
1630
1631 Parameters
1632 ----------
1633 ops_list : List[Union[Type[ExpressionOps], dict]]
1634 - if type(ops_list) is List[Type[ExpressionOps]], each element of ops_list represents the operator class, which should be the subclass of `ExpressionOps`.
1635 - if type(ops_list) is List[dict], each element of ops_list represents the config of operator, which has the following format:
1636
1637 .. code-block:: text
1638
1639 {
1640 "class": class_name,
1641 "module_path": path,
1642 }
1643
1644 Note: `class` should be the class name of operator, `module_path` should be a python module or path of file.
1645 """
1646 for _operator in ops_list:
1647 if isinstance(_operator, dict):
1648 _ops_class, _ = get_callable_kwargs(_operator)
1649 else:
1650 _ops_class = _operator
1651
1652 if not issubclass(_ops_class, (Expression,)):
1653 raise TypeError("operator must be subclass of ExpressionOps, not {}".format(_ops_class))
1654
1655 if _ops_class.__name__ in self._ops:
1656 get_module_logger(self.__class__.__name__).warning(
1657 "The custom operator [{}] will override the qlib default definition".format(_ops_class.__name__)
1658 )
1659 self._ops[_ops_class.__name__] = _ops_class
1660
1661 def __getattr__(self, key):
1662 if key not in self._ops:

Callers 1

register_all_opsFunction · 0.45

Calls 1

get_callable_kwargsFunction · 0.85

Tested by

no test coverage detected