[Bug]: jsanitize does not play nicely with `np.array(float)` types
Closed this issue · 0 comments
Andrew-S-Rosen commented
Email (Optional)
No response
Version
2024.4.17
Which OS(es) are you using?
- MacOS
- Windows
- Linux
What happened?
Running jsanitize
on a np.array(float)
or np.array(int)
yields a TypeError
.
Code snippet
import numpy as np
from monty.json import jsanitize
jsanitize(np.array(-1))
# or..
jsanitize(np.array(-1.0))
# or...
jsanitize({"test": np.array(-1.0})
Log output
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\asros\miniconda\envs\quacc\Lib\site-packages\monty\json.py", line 703, in jsanitize
return {
^
File "C:\Users\asros\miniconda\envs\quacc\Lib\site-packages\monty\json.py", line 704, in <dictcomp>
str(k): jsanitize(
^^^^^^^^^^
File "C:\Users\asros\miniconda\envs\quacc\Lib\site-packages\monty\json.py", line 687, in jsanitize
return [
^
TypeError: 'float' object is not iterable
Code of Conduct
- I agree to follow this project's Code of Conduct