NumPy masked comparison at 0.7: agree on dtype and a strict boundary first
Approve comparison precision for observations and thresholds before checking masked and ordinary paths.
The policy behind a Boolean result
Approve comparison precision for observations and thresholds before checking masked and ordinary paths. Use Truthound to compare that policy with actual per-row decisions. A Boolean output alone cannot establish that both paths used the same boundary. [1, 2, 3]
The scoped report at 0.7
NumPy #33219 reports different Boolean results for a float32 MaskedArray and ndarray compared with Python float 0.7, suspecting promotion differences. The report does not establish a confirmed cause for every threshold. Preserve the meaning of the actually stored float32 value rather than an ideal decimal. [1]
Preserve stored values and thresholds
Preserve raw float32 values, the Python threshold and approved comparison dtype. Reconcile per-row decisions from an explicitly typed independent comparison and isolate changed selections. Define mask, NaN and < versus <= semantics, retaining source row IDs as well as the decision. [1, 3]
A strict comparison of equal values
The illustrative policy compares an observation represented as float32 0.7 with the same threshold represented as float32 0.7. Strict < between equal values is false. Observed false meets the condition; true fails. This is a declared policy, not the only valid precision choice for every business. [1, 3]
Prepare independent decisions
Truthound Core Python SDK 3.3.2 can compare prepared reference_below_threshold and actual_below_threshold using ColumnPairValidator with relationship="==". The operator derives reference decisions under the approved dtype and handles missingness separately. The SDK does not change NumPy promotion or comparison, or choose the business policy. [1, 2, 3]
Declare a common calculation type
Explicitly convert observations and thresholds to the approved common calculation type and recheck boundary values and masks. Comparing text spellings of decimal 0.7 would not replace the stored-value comparison. Reuse an existing decision reconciliation for the same execution conditions. [1, 3]
Application conditions
Preserve stored value and threshold dtypes and define mask, NaN and < or <= behavior.
Alternatives
Explicitly use the approved common calculation type and recheck boundary values with masks.
Limitations
Core compares prepared decisions, does not change NumPy comparison and does not make one promotion policy universally correct.
Evidence
- Event checked
- Subject checked
- Modified
