-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ENH: Add support for float hex format to loadtxt. #5504
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
Conversation
Needed python > 2.5, so open for discussion. |
return float(x) | ||
except ValueError: | ||
pass | ||
return float.fromhex(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pass should not be needed, you can return from the except clause
2.5 should not be a concern anymore, we (or probably you ;) ) removed 2.5 compat code a while ago and we say since 1.8 >= 2.6 |
5731814
to
6dae34f
Compare
Yeah, also needs a test. |
6dae34f
to
6ef4e1d
Compare
If I understand correctly, that means that "A0" will be treated as hex while "10" will be treatead as base 10. So if a column contains hex values without prefix, some will be treated as base 10 and others as base 16 ? |
@Nodd Good point. I'm thinking this PR is too limited, maybe is it better to check |
Now with new improved implementation. |
8ce554f
to
d6dcf40
Compare
58207ad
to
368822f
Compare
Add _floatconv to npyio.py as a default floating point converter. This uses float() as a type conversion with a fallback on (ValueError) to float.fromhex(). Closes numpy#2517.
The strings must be produced by the python float.hex method.
368822f
to
0516465
Compare
ENH: Add support for float hex format to loadtxt.
Not sure this is worth the trouble, but merging anyway. |
Add _floatconv to npyio.py as a default floating point converter. This
uses float() as a type conversion with a fallback on (ValueError) to
float.fromhex().
Closes #2517.
Cleanup of #133.