{"record":{"id":"31eeaa7f7a6cc464","repo":"microsoft/qlib","slug":"please-implement-the-replace-method","errorCode":null,"errorMessage":"Please implement the `replace` method","messagePattern":"Please implement the `replace` method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/backtest/high_performance_ds.py","lineNumber":288,"sourceCode":"\n    def abs(self) -> BaseSingleMetric:\n        raise NotImplementedError(f\"Please implement the `abs` method\")\n\n    @property\n    def empty(self) -> bool:\n        \"\"\"If metric is empty, return True.\"\"\"\n\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","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/high_performance_ds.py#L270-L306","documentation":"Error \"Please implement the `replace` method\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/backtest/high_performance_ds.py:288 when the guard condition fails: \"Please implement the `replace` 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 `replace` method in your subclass of the indicator/data class before calling it.","If you intended to use the pandas-like replace behavior, use the concrete implementation class that already defines `replace`."],"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-15T17:31:12.345Z"}