Skip to content

Commit

Permalink
close h5py#1244
Browse files Browse the repository at this point in the history
Issue: ">f8" was written as ">f16" on ppc64le
Actually the dict doing the mapping between numpy and hdf5 was wrong.
Stop iterating when first matching is found, avoiding "f16" to replace "f8"
  • Loading branch information
Jerome Kieffer committed Sep 19, 2019
1 parent 355300d commit 79104b3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions h5py/h5t.pyx
Expand Up @@ -1369,11 +1369,9 @@ cdef class TypeEnumID(TypeCompositeID):
def _get_float_dtype_to_hdf5():
float_le = {}
float_be = {}
h5_be_list = [IEEE_F16BE, IEEE_F32BE, IEEE_F64BE, IEEE_F128BE,
LDOUBLE_BE]
h5_le_list = [IEEE_F16LE, IEEE_F32LE, IEEE_F64LE, IEEE_F128LE]
if MACHINE != 'ppc64le':
h5_le_list.append(LDOUBLE_LE)
h5_be_list = [IEEE_F16BE, IEEE_F32BE, IEEE_F64BE, IEEE_F128BE, LDOUBLE_BE]
h5_le_list = [IEEE_F16LE, IEEE_F32LE, IEEE_F64LE, IEEE_F128LE, LDOUBLE_LE]

for ftype_, finfo, size in _available_ftypes:
nmant, maxexp, minexp = _correct_float_info(ftype_, finfo)
for h5type in h5_be_list:
Expand All @@ -1383,13 +1381,15 @@ def _get_float_dtype_to_hdf5():
(maxexp - 1) == ebias
):
float_be[ftype_] = h5type
break # first found matches, related to #1244
for h5type in h5_le_list:
spos, epos, esize, mpos, msize = h5type.get_fields()
ebias = h5type.get_ebias()
if (finfo.iexp == esize and nmant == msize and
(maxexp - 1) == ebias
):
float_le[ftype_] = h5type
break # first found matches, related to #1244
if ORDER_NATIVE == H5T_ORDER_LE:
float_nt = dict(float_le)
else:
Expand Down

0 comments on commit 79104b3

Please sign in to comment.