Floating point errors when defining an Index
Created by: dethodav
When creating a new Index
, rounding of float values can result in an extra x-index being created. For example, the following code should generate 1001 indices, but instead generates 1002 indices:
from gwpy.types.index import Index
x = Index.define(1262936373.4853957, 0.051, 1001)
print(x.shape)
This creates issues when creating spectrograms, as the number of points in the 2d array will not end up matching the number of points in the x-index: https://github.com/gwpy/gwpy/blob/de2299162736d745b7847b31cd1277805dcdb9a5/gwpy/signal/qtransform.py#L549-L553
In the above case, this bug leads to nx != len(out.xindex.value)
.This then leads to errors when plotting the created spectrogram.