Styxis
Company
Knowledge

NumPy gradient on integer nanoseconds: preserve the origin and intervals before float conversion

Preserve integer differences before converting large absolute times to float, then approve gradients against the original intervals.

Large absolute values and small intervals

Preserve integer differences before converting large absolute times to float, then approve gradients against the original intervals. Do not build the Truthound reference from the same rounded absolute timestamps. A finite output can still have lost the small intervals required for accurate change detection. [1, 2, 3]

The workaround and its remaining scope

NumPy #33173 reports float64 conversion of integer nanosecond timestamps changing intervals and producing gradients different from 1 even for linear data. Production impact was not confirmed. A follow-up tests integer-origin subtraction and discusses difference overflow; those proposals do not establish a released correction for every range. [1]

Preserve the origin first

Preserve raw integer times and the reference origin, deriving a gradient reference from lossless relative time. Withhold out-of-policy gradients from change detection and test origin subtraction. Check integer subtraction range and time units, retaining the absolute epoch separately. Real-data tolerance and boundary stencils require their own policy. [1, 3]

Gradient 1 for linear data

Illustrative elapsed times are [0,1000,3000,6000]ns and values are the same numbers. Every value difference divided by time difference is 1, unchanged by adding an absolute epoch. Observed gradient 1 meets this condition; 0.9765625 fails. Compare translated-origin inputs to distinguish absolute magnitude from intervals. [1, 3]

Check a prepared gradient reference

Truthound Core Python SDK 3.3.2 can compare prepared independently_derived_gradient and observed_gradient with ColumnPairValidator using relationship="==". This fixture has an exact linear reference; operational floating-point tolerances are separate. The operator computes differences and references. The SDK does not execute np.gradient or recover lost intervals. [1, 2, 3]

Connect to actual change detection

Choose integer-origin-relative time or a verified precise-difference path, checking safety over the full time span. Changed units or sample correspondence would still change the gradient after origin subtraction. Evaluate the actual anomaly consumer’s false alarms and missed changes separately after choosing the validated path. [1, 3]

Application conditions

Check integer-origin subtraction safety and units, preserving absolute timestamps separately.

Alternatives

Use verified integer-origin-relative coordinates or precise differences and check the full-range safety.

Limitations

  • Core compares prepared gradients, does not execute np.gradient or subtraction, and does not define operational tolerance or stencils.

Evidence

Event checked
Subject checked
Modified