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

silx.io.fioh5: Improved handling of missing data entries #4156

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tifuchs
Copy link
Contributor

@tifuchs tifuchs commented Aug 6, 2024

Enables the loading of fio files with missing data entries, that can not be converted into the target data type.
Mostly uses the default behaviour of numpy.genfromtxt.

For example: Entries like <no data> or nan in a FLOAT data column are automatically converted to numpy.nan by numpy.genfromtxt.

Not all missing values can be handled:
Missing boolean or integer values cannot be flagged as missing (i.e. nan) in a bool or integer array and thus result in a ValueError.

Closes #4155

@woutdenolf
Copy link
Contributor

woutdenolf commented Aug 12, 2024

Fix CI failures

 >       val = val.decode().lower()
E       AttributeError: 'str' object has no attribute 'decode'

Could you also add a unit test with FIO data that has missingvalues?

@t20100 t20100 added this to the Next release milestone Aug 27, 2024
Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

As already mentioned, the continuous integration fails highlighting an bytes/str issue and it would also be great to have a test with nan and no data

Comment on lines +170 to +174
"""Convert a byte of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a complete description in the docstring IMO, the code is self-explanatory

Suggested change
"""Convert a byte of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
"""Convert bytes of a truth value to bool.
Raises ValueError if 'val' is not supported.
"""

elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return False
else:
raise ValueError("invalid truth value %r" % (val,))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError("invalid truth value %r" % (val,))
raise ValueError("Invalid truth value %r" % val)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IO] FIO files: handle missing data
3 participants