Skip to content

coreforecast/indptr-missing-zero

Rule indptr-missing-zero
Pack CoreForecast
Severity warning
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

A GroupedArray starts its first series at indptr[0]. An offset above zero leaves the preceding values outside any series.

groups = GroupedArray(values, np.array([3, 10]))
groups = GroupedArray(values, np.array([0, 3, 10]))

The rule reports a CoreForecast GroupedArray call whose second argument or indptr= is an inline np.array or numpy.array with a literal list or tuple starting with a positive decimal integer. It checks the constructor's import. Offsets computed elsewhere need a runtime check.

With CoreForecast 0.0.20 and ten values, [3, 10] defined one series with seven values. [0, 3, 10] defined the two intended series, with three and seven values. See the grouped array contract.

xpd check --fix --unsafe-fixes prepends 0 to literal list or tuple offsets inside np.array(...) or numpy.array(...). It is unsafe because you should also confirm that the last offset matches the length of the values array.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

GroupedArray offsets must start at zero. A first offset above zero leaves those observations outside any series. Prepend 0 if these offsets are cumulative series lengths.

Browse the other rules of the CoreForecast pack.