You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/home/lhe97136/CIL/Wrappers/Python/test/test_io.py", line 283, in test_TIFF_compression3D_1
self.TIFF_compression_test('uint8')
File "/home/lhe97136/CIL/Wrappers/Python/test/test_io.py", line 324, in TIFF_compression_test
writer.write()
File "/home/lhe97136/miniconda3/envs/cil_mat/lib/python3.12/site-packages/cil/io/TIFF.py", line 179, in write
save_scale_offset(fname, self.scale, self.offset)
File "/home/lhe97136/miniconda3/envs/cil_mat/lib/python3.12/site-packages/cil/io/TIFF.py", line 51, in save_scale_offset
utilities.save_dict_to_file(txt, d)
File "/home/lhe97136/miniconda3/envs/cil_mat/lib/python3.12/site-packages/cil/io/utilities.py", line 134, in save_dict_to_file
json.dump(dictionary, configfile)
File "/home/lhe97136/miniconda3/envs/cil_mat/lib/python3.12/json/init.py", line 179, in dump
for chunk in iterable:
^^^^^^^^
File "/home/lhe97136/miniconda3/envs/cil_mat/lib/python3.12/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/home/lhe97136/miniconda3/envs/cil_mat/lib/python3.12/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/home/lhe97136/miniconda3/envs/cil_mat/lib/python3.12/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/home/lhe97136/miniconda3/envs/cil_mat/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type float32 is not JSON serializable
Description
This is because we try to write a dictionary to a json file and the dictionary contains something of type numpy.float32. This is because here:
CIL/Wrappers/Python/cil/io/utilities.py
Line 116 in f0f97a4
scale becomes the same type as the data because data_range is the same type as the data
CIL/Wrappers/Python/cil/io/utilities.py
Line 113 in f0f97a4
We need to convert the scale to a normal float type and then it can be 'dumped' to json
Environment
python 3.12, numpy 2
The text was updated successfully, but these errors were encountered: