I am trying to encode an array which contains floats and
json.dumps has an
allow_nan parameter, which defaults to True.
allow_nan=False. But then you'll get ValueError when you try to serialise NaN.