Skip to content

Commit

Permalink
unicode/ascii/bytes/str hdf5 grr
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Bailey authored and Stephen Bailey committed Apr 19, 2024
1 parent c6f61ed commit c006d4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions py/redrock/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def write_zscan(filename, zscan, zfit, clobber=False):
zfit = zfit.copy()

#- convert unicode to byte strings
zfit.replace_column('spectype', np.char.encode(zfit['spectype'], 'ascii'))
zfit.replace_column('subtype', np.char.encode(zfit['subtype'], 'ascii'))
for colname in ('spectype', 'subtype', 'fitmethod'):
if colname in zfit.columns:
zfit.replace_column(colname, np.char.encode(zfit[colname], 'ascii'))

zbest = zfit[zfit['znum'] == 0]
zbest.remove_column('znum')
Expand Down
2 changes: 2 additions & 0 deletions py/redrock/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def test_zscan_io(self):

zscan1, zfit1 = zfind(dtarg, [ dtemp ])

zfit1.remove_column('fitmethod')

write_zscan(self.testfile, zscan1, zfit1)
write_zscan(self.testfile, zscan1, zfit1, clobber=True)
zscan2, zfit2 = read_zscan(self.testfile)
Expand Down

0 comments on commit c006d4f

Please sign in to comment.