skfolio/skfolio-panel-inactive-policy
| Rule | skfolio-panel-inactive-policy |
|---|---|
| Pack | skfolio |
| Severity | error |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | skfolio 1.14.4 and later |
skfolio AssetPanel distinguishes inactive pairs from missing values for active assets. Its field policy controls what values are valid outside active_mask.
FieldCategorical(values=codes, levels=labels, inactive_policy=InactivePolicy.ZERO)FieldCategorical(values=codes, levels=labels, inactive_policy=InactivePolicy.MISSING)What the rule reports
Section titled “What the rule reports”Reserve -1 for missing categorical codes. For numeric fields, use NaN under MISSING, explicitly construct a field with ZERO when zero is meaningful, or use IGNORE when intentionally retaining inactive values. CharacteristicsFactorModel expects the panel as its characteristics input.
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to switch InactivePolicy.ZERO on FieldCategorical to InactivePolicy.MISSING and to convert string inactive_policy values to InactivePolicy enum members.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
skfolio FieldCategorical raises ValueError for InactivePolicy.ZERO because code 0 is a category. Use MISSING and encode inactive entries as -1.Browse the other rules of the skfolio pack.