'/' is separator in h5py even on windows.

os.path assumes OS-dependent path separators
This commit is contained in:
Martin Diehl 2022-03-26 22:09:45 +01:00
parent c11d38b2ec
commit ff3d3afe9e
1 changed files with 6 additions and 6 deletions

View File

@ -125,9 +125,9 @@ class TestUtil:
def test_D3D_base_group(self,tmp_path,complete):
base_group = ''.join(random.choices('DAMASK', k=10))
with h5py.File(tmp_path/'base_group.dream3d','w') as f:
f.create_group(os.path.join(base_group,'_SIMPL_GEOMETRY'))
f.create_group('/'.join((base_group,'_SIMPL_GEOMETRY')))
if complete:
f[os.path.join(base_group,'_SIMPL_GEOMETRY')].create_dataset('SPACING',data=np.ones(3))
f['/'.join((base_group,'_SIMPL_GEOMETRY'))].create_dataset('SPACING',data=np.ones(3))
if complete:
assert base_group == util.DREAM3D_base_group(tmp_path/'base_group.dream3d')
@ -141,12 +141,12 @@ class TestUtil:
cell_data_group = ''.join(random.choices('KULeuven', k=10))
cells = np.random.randint(1,50,3)
with h5py.File(tmp_path/'cell_data_group.dream3d','w') as f:
f.create_group(os.path.join(base_group,'_SIMPL_GEOMETRY'))
f[os.path.join(base_group,'_SIMPL_GEOMETRY')].create_dataset('SPACING',data=np.ones(3))
f[os.path.join(base_group,'_SIMPL_GEOMETRY')].create_dataset('DIMENSIONS',data=cells[::-1])
f.create_group('/'.join((base_group,'_SIMPL_GEOMETRY')))
f['/'.join((base_group,'_SIMPL_GEOMETRY'))].create_dataset('SPACING',data=np.ones(3))
f['/'.join((base_group,'_SIMPL_GEOMETRY'))].create_dataset('DIMENSIONS',data=cells[::-1])
f[base_group].create_group(cell_data_group)
if complete:
f[os.path.join(base_group,cell_data_group)].create_dataset('data',shape=np.append(cells,1))
f['/'.join((base_group,cell_data_group))].create_dataset('data',shape=np.append(cells,1))
if complete:
assert cell_data_group == util.DREAM3D_cell_data_group(tmp_path/'cell_data_group.dream3d')