Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to interpret raw 4-byte ieee754 floating point TRE values #565

Open
bndkr opened this issue Oct 24, 2024 · 0 comments
Open

Unable to interpret raw 4-byte ieee754 floating point TRE values #565

bndkr opened this issue Oct 24, 2024 · 0 comments
Labels
bug Something isn't working in integration merged into integration branch

Comments

@bndkr
Copy link

bndkr commented Oct 24, 2024

The BANDSB TRE includes 4-byte fields that use the ieee754 floating-point format:

self.add_field('SCALE_FACTOR', 'ieee754_binary32', 4, value)

When interpreted, these values are converted to floating-point numbers. However, when we want to convert a TRE to a dict, there is no support to place floating-point numbers in the dict:
def to_dict(self):
"""
Create a dictionary representation of the object.
Returns
-------
dict
"""
out = OrderedDict()
for fld in self._field_ordering:
val = getattr(self, fld)
if val is None or isinstance(val, (bytes, str, int)):
out[fld] = val
elif isinstance(val, TREElement):
out[fld] = val.to_dict()
else:
raise TypeError('Unhandled type {}'.format(type(val)))
return out

The error check should be updated:

-        if val is None or isinstance(val, (bytes, str, int)):
+        if val is None or isinstance(val, (bytes, str, int, float)):
@pressler-vsc pressler-vsc added bug Something isn't working in integration merged into integration branch labels Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in integration merged into integration branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants