Skip to content
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

Cannot convert numpy types to json (numpy 2.0) #433

Open
hyanwong opened this issue Dec 4, 2024 · 0 comments
Open

Cannot convert numpy types to json (numpy 2.0) #433

hyanwong opened this issue Dec 4, 2024 · 0 comments

Comments

@hyanwong
Copy link
Contributor

hyanwong commented Dec 4, 2024

When printing the output of the HmmRun class, using asjson(), here:

return d

I'm getting "TypeError: Object of type int64 is not JSON serializable". I think this is because numpy 2 saves e.g. integers and float as special types that are not directly convertible to JSON. To get it to work, I had to adjust the asdict() method to use .item() to convert two of the values:

        d["match"]["cost"] = d["match"]["cost"].item()
        d["match"]["likelihood"] = d["match"]["likelihood"].item()
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant