Skip to content

v0.4.6: UniSaver: Adding graceful handling for NaN when saving to json or jsonl

Compare
Choose a tag to compare
@trojblue trojblue released this 28 Jun 14:19
· 14 commits to main since this release

^title

this should not produce a file containing NaN anymore:

import numpy as np

test_dict = [{
    "id": 1,
    "name": "Alice",
    "age": None,  # Contains a None value
    "height": float('nan'), 
    "weight": np.nan, 
}]

ub.saves(test_dict, "test_invalid_values2.jsonl") # shouldn't contain "NaN" in the output file