Skip to content

Rounding error in spine resampling

Spine resampling and interpolation requires to identify the previous and next time steps for each time point on the interpolation grid.

A same rounding operation is used both in PlanarLarvae.jl (Julia side) and TaggingBackends (Python side) supposedly to control the numerical precision of grid time points. However, it is not effective at all in this respect.

julia> round((158.414 + 9 * 0.1) * 1e4) * 1e-4
159.31400000000002
>>> from numpy import trunc; trunc((158.414 + 9 * 0.1) * 1e4) * 1e-4
159.31400000000002

As a consequence, the previous or next identified step may occasionally be shifted by one step. This is unlikely to have any perceivable impact on the interpolated spines, especially for MWT data and their noisy timestamps. However this caused an error on "overflowing" the last time step of a track (while processing file t5/GMR_20D02_AE_01@UAS_GAL80ts_Kir21_23_0004/p_8_45s1x30s0s#p_8_105s10x2s10s#n#n@100/20101122_153313/trx.mat).

EDIT: the rounding operation in PlanarLarvae.jl is actually:

julia> round(158.414 + 9 * 0.1; digits=4)
159.314

The bug only affects the Python code, that was supposed to be a transposition of the original Julia code. The good news is: the sample datasets used for training are not affected either. The bug has been harmless until now.

Edited by François LAURENT