ezmsg.dashboard.backend.json_encoding#
Wire encoding for values JSON cannot represent natively.
JSON has no literal for inf, -inf or nan, and the two transports the
dashboard uses disagree about what to do with them: JSONResponse renders
with allow_nan=False and raises, while pydantic’s model_dump(mode="json")
silently rewrites them to null. Settings classes are free to hold such
values (clip_max: float = np.inf is perfectly reasonable), so the dashboard
encodes them as the string tokens below on the way out and decodes them again on
the way in.
The tokens are spelled the way JavaScript spells them, so the frontend can
recover the value with Number(token).
Functions
- decode_float_token(value)[source]#
Return the float a token stands for, or
Noneif it is not a token.