Skip to content

Commit

Permalink
Fix shape encoded wrong for 1d arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnor committed Aug 18, 2024
1 parent cb8f58e commit d3cba85
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion npyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ def _write_header(self):
dtype_matches = [ key for key, (tc, size) in format_mapping.items() if tc == self.typecode ]
assert len(dtype_matches) == 1, dtype_matches
dtype = '<'+dtype_matches[0].decode('ascii')
shape_str = ','.join((str(d) for d in shape))
if len(shape) == 1:
shape_str = f'{shape[0]},' # 1-length tuple must have trailing ,
else:
shape_str = ','.join((str(d) for d in shape))

header = f"{{'descr': '{dtype}', 'fortran_order': False, 'shape': ({shape_str}), }}"
#print('wh', header)
Expand Down

0 comments on commit d3cba85

Please sign in to comment.