microsoft/qlib · error · NotImplementedError
Please implement the `replace` method
Error message
Please implement the `replace` method
What it means
Error "Please implement the `replace` method" thrown in microsoft/qlib.
Source
Thrown at qlib/backtest/high_performance_ds.py:288
def abs(self) -> BaseSingleMetric:
raise NotImplementedError(f"Please implement the `abs` method")
@property
def empty(self) -> bool:
"""If metric is empty, return True."""
raise NotImplementedError(f"Please implement the `empty` method")
def add(self, other: BaseSingleMetric, fill_value: float = None) -> BaseSingleMetric:
"""Replace np.nan with fill_value in two metrics and add them."""
raise NotImplementedError(f"Please implement the `add` method")
def replace(self, replace_dict: dict) -> BaseSingleMetric:
"""Replace the value of metric according to replace_dict."""
raise NotImplementedError(f"Please implement the `replace` method")
def apply(self, func: Callable) -> BaseSingleMetric:
"""Replace the value of metric with func (metric).
Currently, the func is only qlib/backtest/order/Order.parse_dir.
"""
raise NotImplementedError(f"Please implement the 'apply' method")
class BaseOrderIndicator:
"""
The data structure of order indicator.
!!!NOTE: There are two ways to organize the data structure. Please choose a better way.
1. One way is using BaseSingleMetric to represent each metric. For example, the data
structure of PandasOrderIndicator is Dict[str, PandasSingleMetric]. It uses
PandasSingleMetric based on pd.Series to represent each metric.
2. The another way doesn't use BaseSingleMetric to represent each metric. The data
structure of PandasOrderIndicator is a whole matrix. It means you are not necessaryView on GitHub (pinned to 79633dd950)
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`.
When it happens
Trigger: 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.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/31eeaa7f7a6cc464.
Report an issue: GitHub.