Phrogz opened a new pull request, #1322:
URL: https://github.com/apache/hamilton/pull/1322

   Fix it so that NaN and Infinity floats do not throw an error when being 
passed to Hamilton UI.
   
   ## Changes
   
   This commit uses `json.dumps(…, allow_nan=False)`, which raises a 
`ValueError` for such values, and in that case converts them to strings.
   
   The result is that Hamliton UI will show such values as **strings** `"nan"`, 
`"inf"`, and `"-inf"`.
   This could be confusing only to users who are also using such string values.
   
   ## How I tested this
   
   Created failing unit tests, patched the code, ensured the failing tests now 
pass.
   
   Ran all unit tests; while some fail, they also failed before this fix.
   
   ## Notes
   
   Float values that are "out of range" were previously serialized—to send to 
the tracker/Hamilton UI—in a way that produced invalid JSON (but value JS), 
which caused a runtime error trying to send values to the tracker.
   
   `math.nan`, `math.inf`, and `-math.inf` are serialized by `json.dumps()` to 
`NaN`, `Infinity`, and `-Infinity` values by default(NOT as strings).
   
   Fixes #1310
   
   
   ## Checklist
   
   - [x] PR has an informative and human-readable title (this will be pulled 
into the release notes)
   - [x] Changes are limited to a single goal (no scope creep)
   - [x] Code passed the pre-commit check & code is left cleaner/nicer than 
when first encountered.
   - [x] Any _change_ in functionality is tested
   - [x] New functions are documented (with a description, list of inputs, and 
expected output)
   - [x] Placeholder code is flagged / future TODOs are captured in comments
   - [x] Project documentation has been updated if adding/changing 
functionality.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to