Hi, I just came across the following issue:
If you have numpy strings as keys of a dictionary and you save this dictionary, the h5py_wrapper raises the error
ValueError: malformed node or string:
<ast.Name object at 0x7fcfa1870970>
when trying to load the file. This can be reproduced using the following test (using pytest):
import pytest
import numpy as np
import h5py_wrapper as h5
from unittest import TestCase
def test_saving_and_consecutive_loading_of_numpy_string_keys(tmpdir):
file = 'test.h5'
keys = ['a', 'b', 'c']
# this makes the keys numpy strings
keys = np.atleast_1d(keys)
output = {key: i for i, key in enumerate(keys)}
# create temporary directory to save test file into
tmp_test = tmpdir.mkdir('tmp_test')
with tmp_test.as_cwd():
h5.save(file, output)
input = h5.load(file)
TestCase().assertDictEqual(output, input)
The problem seems to be line 296 in wrapper.py where key_type is compared to ['str', 'unicode', 'string_'], but a numpy string leads to key_type = 'str_'.
Hi, I just came across the following issue:
If you have numpy strings as keys of a dictionary and you save this dictionary, the
h5py_wrapperraises the errorwhen trying to load the file. This can be reproduced using the following test (using
pytest):The problem seems to be line 296 in
wrapper.pywherekey_typeis compared to['str', 'unicode', 'string_'], but a numpy string leads tokey_type = 'str_'.