A report that assigns one label to each robot inspection record can hide the fact that several rules matched. A record might contain a technician's note and a residual above the threshold at the same time. If the report uses NumPy's select function, the position of those rules in the condition list determines the displayed label. Rearranging the list can change the report even when the measured values, rule definitions and counts of raw rule matches stay the same.

A report label is an editorial choice for routing review work. This example uses one small offline dataset to demonstrate the choice. It does not represent a robot interlock, a process limit or a rule for accepting parts.

Check the intersections before assigning a single label

The fixture has five rows. A synthetic residual is expressed in pixels, a technician note is represented by a Boolean and a separate flag says whether the sensor record was valid. The 2.0-pixel threshold is only a fixture input. The report orders the labels so that an invalid record appears as missing, then a note takes priority over a high residual. When all conditions are false the row receives a normal label.

import numpy as np

residual_px = np.array([0.4, 2.2, 3.8, 0.7, 2.8])

manual_note = np.array([False, False, True, True, True])

sensor_valid = np.array([True, True, True, True, False])

rules = [~sensor_valid, manual_note, residual_px > 2.0]

labels = ["missing", "manual", "inspect"]

assigned = np.select(rules, labels, default="normal")

assert assigned.tolist() == [

"normal", "inspect", "manual", "manual", "missing"

]

hits = np.count_nonzero(np.stack(rules), axis=0)

assert hits.tolist() == [0, 1, 2, 1, 3]

reordered = np.select([rules[0], rules[2], rules[1]],

["missing", "inspect", "manual"],

default="normal")

assert np.flatnonzero(assigned != reordered).tolist() == [2]

The third row has a valid record, a manual note and a high residual. The original order assigns manual. Moving the residual rule earlier assigns inspect. Both labels come from the same input. The fifth row has all three flags set, and its displayed label stays missing because that rule remains first in both versions. Here the residual value on the invalid row is a synthetic carried value, so a raw numeric comparison can still succeed. A production report can include validity in the residual condition if only valid measurements should count toward residual statistics.

The overlap count works along the rule axis. Each Boolean mask has the same length as the input. Stacking those masks makes each output column correspond to one record, and counting true entries along axis zero reports how many rules matched that record. Keeping the original masks or recording the names of the matching rules explains which rules contributed. The count alone gives the extent of the overlap.

Record the reason alongside the display label

Decide whether consumers need a single display label, a list of all matching rules, or both. The review queue can use a primary label while an export carries the underlying evidence. A dashboard can report both the number of rows labeled inspect and the number of valid measurements above the threshold. Those numbers may differ because a more prominent manual label can take priority on the same row.

Check the default value as part of the data contract. In this fixture every row enters the classification step and normal means no defined condition matched. If some records are skipped earlier, keep that state separate. Otherwise an absent measurement or an unhandled data status can look like an ordinary result. Test the exact threshold as well. The greater-than comparison in this example excludes a valid residual of exactly 2.0 pixels.

Make rule priority an explicit part of review

Keep the condition order with the recipe or report version and pair each mask with its own label when changing the configuration. Put overlap cases in the regression test, since tests with one matching mask per row cannot detect a swap. Compare which records changed labels and which raw flags stayed the same. This gives reviewers evidence that a change comes from priority and lets them check whether a downstream report consumer expects the old order.

Sources

NumPy API reference, select

https://numpy.org/doc/stable/reference/generated/numpy.select.html

NumPy API reference, count_nonzero

https://numpy.org/doc/stable/reference/generated/numpy.count_nonzero.html