-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing Nan/Infinity breaks most standard JSON parsers #208
Comments
It originally came up as a way to handle #83, and yes a large number would work similarly in practice. We could alter the schema and replace basically every |
@IzaakWN given you originally requested the asymmetric flow, do you have any opinions on using a "large number" instead of infinity? |
No, not really strong opinion either way. As long as it's large enough to cover all realistic physics use cases (like eta, pT, mass, ...), as well as technical limitations by different data types (mainly in python and C++ I guess) . :) |
I think using a large number sounds good. We could recommend something that hopefully will never be reached such as 999999? |
I was leaning towards implementing |
For my understanding, what would this look like for: "edges": [
15.0,
20.0,
25.0,
30.0,
40.0,
50.0,
60.0,
120.0,
Infinity
], |
"edges": [
15.0,
20.0,
25.0,
30.0,
40.0,
50.0,
60.0,
120.0,
"inf"
], |
OK, fine for me. Renders OK in browsers. |
This has gotten more urgent since something changed in pydantic between 2.6.4 and 2.7 that makes the serialization of |
I found that allowing
NaN
andInfinity
breaks standard JSON parsers, e.g. web browsers, probably because it violates https://datatracker.ietf.org/doc/html/rfc8259#section-6An example file is https://gitlab.cern.ch/cms-nanoAOD/jsonpog-integration/-/blob/master/POG/MUO/2018_UL/muon_Z.json.gz
This was introduced in #85 and is actually a feature of rapidjson. It converts the value to
std::numeric_limits<double>::infinity()
. This is a nice feature, but I'm not sure it's worth the caveat of breaking JSON parsing...Two questions come to my mind:
I would propose to use infinity, but as a quoted, case-insensitive string instead and leave the parsing/value assignment to correctionlib. In this way, the JSON standard would be preserved and one could still open the file in RFC8259-compliant applications. What do you think?
The text was updated successfully, but these errors were encountered: