{"record":{"id":"69134afb318aef33","repo":"microsoft/qlib","slug":"please-implement-the-apply-method","errorCode":null,"errorMessage":"Please implement the 'apply' method","messagePattern":"Please implement the 'apply' method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/backtest/high_performance_ds.py","lineNumber":295,"sourceCode":"\n        raise NotImplementedError(f\"Please implement the `empty` method\")\n\n    def add(self, other: BaseSingleMetric, fill_value: float = None) -> BaseSingleMetric:\n        \"\"\"Replace np.nan with fill_value in two metrics and add them.\"\"\"\n\n        raise NotImplementedError(f\"Please implement the `add` method\")\n\n    def replace(self, replace_dict: dict) -> BaseSingleMetric:\n        \"\"\"Replace the value of metric according to replace_dict.\"\"\"\n\n        raise NotImplementedError(f\"Please implement the `replace` method\")\n\n    def apply(self, func: Callable) -> BaseSingleMetric:\n        \"\"\"Replace the value of metric with func (metric).\n        Currently, the func is only qlib/backtest/order/Order.parse_dir.\n        \"\"\"\n\n        raise NotImplementedError(f\"Please implement the 'apply' method\")\n\n\nclass BaseOrderIndicator:\n    \"\"\"\n    The data structure of order indicator.\n    !!!NOTE: There are two ways to organize the data structure. Please choose a better way.\n        1. One way is using BaseSingleMetric to represent each metric. For example, the data\n        structure of PandasOrderIndicator is Dict[str, PandasSingleMetric]. It uses\n        PandasSingleMetric based on pd.Series to represent each metric.\n        2. The another way doesn't use BaseSingleMetric to represent each metric. The data\n        structure of PandasOrderIndicator is a whole matrix. It means you are not necessary\n        to inherit the BaseSingleMetric.\n    \"\"\"\n\n    def __init__(self):\n        self.data = {}  # will be created in the subclass\n        self.logger = get_module_logger(\"online operator\")\n","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/high_performance_ds.py#L277-L313","documentation":"Error \"Please implement the 'apply' method\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/backtest/high_performance_ds.py:295 when the guard condition fails: \"Please implement the 'apply' method\". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.","commonSituations":"See trigger scenarios.","solutions":["Implement the `apply` method in your subclass before calling it.","Use a concrete class that provides `apply` instead of the abstract base."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}