Skip to content

[Bug]: by default save_hdf5 and load_hdf5 set the dtype to float32 #2004

@Marc-Jindra

Description

@Marc-Jindra

What happened?

When saving a dndarray with dtype=ht.int32 using save_hdf5, the resulting h5 dataset has the type float32. This can be avoided by specifying dtype=int or dtype=np.int32 (not ht.int32 or torch.int32 as those throw errors) but it should use the dtype of the dndarray by default.

The same issue exists for load_hdf5, where it does not use the type of the h5 dataset but sets it to float32.

Code snippet triggering the error

import heat as ht
a = ht.arange(100, dtype=ht.int32)
ht.save_hdf5(a, 'test.h5', dataset='data')
b = ht.load_hdf5('test.h5', dataset='data')
print(b.dtype)

Error message or erroneous outcome

No error just the wrong type

Version

main (development branch)

Python version

3.12

PyTorch version

2.6

MPI version

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions