hdf5storage icon indicating copy to clipboard operation
hdf5storage copied to clipboard

Strings not loaded properly when using oned_as='column' in savemat()

Open jeremypriest opened this issue 3 years ago • 0 comments

Hello Freja! First, thank you for hdf5storage - we use it extensively at my place of work.

I'm seeing a bug in v0.1.18 when I use oned_as='column' in savemat(). Here is a snippet:

import hdf5storage as hs

a = {'metadata':
         {'paths':
              {'0': 'string0',
               '1': 'string1',
               '2': 'string2'}}}

# Save the dictionary
file = 'test.mat'
hs.savemat(file, mdict=a, oned_as='column')

# Load the dictionary
b = hs.loadmat(file)

print(a)
print(b)

# Assert the original and loaded dicts match
assert a == b

I see the following printed, and the assert fails.

{'metadata': {'paths': {'0': 'string0', '1': 'string1', '2': 'string2'}}}
{'metadata': {'paths': {}}}

I notice when I swap oned_as to 'rows' from 'columns', this behavior goes away. Let me know if there is any more information I can provide!

Python version: 3.8.12 hdf5storage version: 0.1.18

jeremypriest avatar Nov 15 '21 17:11 jeremypriest