{"record":{"id":"3ff4a6c3d23ea74e","repo":"microsoft/qlib","slug":"str-e-n-t-warning-info","errorCode":null,"errorMessage":"{str(e)}. \\n\\t{warning_info}","messagePattern":"(.+?)\\. \\\\n\\\\t(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/data/ops.py","lineNumber":331,"sourceCode":"        check_length = isinstance(series_left, (np.ndarray, pd.Series)) and isinstance(\n            series_right, (np.ndarray, pd.Series)\n        )\n        if check_length:\n            warning_info = (\n                f\"Loading {instrument}: {str(self)}; np.{self.func}(series_left, series_right), \"\n                f\"The length of series_left and series_right is different: ({len(series_left)}, {len(series_right)}), \"\n                f\"series_left is {str(self.feature_left)}, series_right is {str(self.feature_right)}. Please check the data\"\n            )\n        else:\n            warning_info = (\n                f\"Loading {instrument}: {str(self)}; np.{self.func}(series_left, series_right), \"\n                f\"series_left is {str(self.feature_left)}, series_right is {str(self.feature_right)}. Please check the data\"\n            )\n        try:\n            res = getattr(np, self.func)(series_left, series_right)\n        except ValueError as e:\n            get_module_logger(\"ops\").debug(warning_info)\n            raise ValueError(f\"{str(e)}. \\n\\t{warning_info}\") from e\n        else:\n            if check_length and len(series_left) != len(series_right):\n                get_module_logger(\"ops\").debug(warning_info)\n        return res\n\n\nclass Power(NpPairOperator):\n    \"\"\"Power Operator\n\n    Parameters\n    ----------\n    feature_left : Expression\n        feature instance\n    feature_right : Expression\n        feature instance\n\n    Returns\n    ----------","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/ops.py#L313-L349","documentation":"Raised by NpPairOperator._load_internal (qlib/data/ops.py) when numpy rejects the element-wise operation between the left and right feature series (e.g. np.divmod, np.arctan2 on incompatible data). The original numpy ValueError is caught, a detailed warning_info string (operator, both feature expressions, instrument, and length mismatch note) is logged at debug level, and a new ValueError chaining the original is re-raised. It almost always means the two operand features produced series that cannot be paired — most commonly different lengths.","triggerScenarios":"Using binary element-wise expression operators such as Div(feature_left, feature_right), Sub(...), Gt(...) where one operand is NaN-only, empty, or the two series have different lengths (check_length=True path warns; the np call itself can still fail on shape mismatch). Typical with mismatched data availability between two features for one instrument.","commonSituations":"Expressions mixing features with different calendars or missing data coverage (e.g. a feature only defined for part of the instruments); data holes in a local bin store for one operand; stale or partially dumped qlib data where one field exists and another does not.","solutions":["Re-dump or repair the qlib bin data so both operand features have data for the requested instrument and range (qlib's dump_bin.py).","Simplify the expression: load each operand separately for the failing instrument (enable the ops debug logger: logging.getLogger('ops').setLevel(logging.DEBUG)) to see which side is empty.","Wrap operands or the whole pair operator in operators that tolerate NaN (e.g. If/IsNa) or use qlib's Fillna processor afterwards instead of relying on broken inputs.","If series lengths differ due to a custom data handler, fix the handler so both features are aligned on the same datetime index."],"exampleFix":"# before (expression that can fail when one side has no data)\nfields = [\"Div($close, $volume)\"]\n\n# after (guard against missing operand data; fill after computing)\nfields = [\"If(IsNa($volume), NaN, Div($close, $volume))\"]\n# and/or in the processor list:\n# {\"class\": \"Fillna\", \"kwargs\": {\"fields_group\": \"feature\"}}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"import logging\nlogging.getLogger(\"ops\").setLevel(logging.DEBUG)\ntry:\n    df = D.features(insts, [expr], start, end)\nexcept ValueError as e:\n    if \"Please check the data\" in str(e):\n        logger.error(\"feature data incomplete for %s; re-dump bins\", expr)\n        raise","preventionTips":["Validate data completeness per instrument/field after every dump (count non-NaN rows).","Wrap risky pair operations in If/IsNa guards and add a Fillna processor.","Keep the ops logger at DEBUG during development to get the diagnostic context."],"tags":["qlib","expression","numpy","data-quality"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}