-
Notifications
You must be signed in to change notification settings - Fork 76
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
added utility function to automate data type str generation #185
Conversation
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.
This seems like a good useful function. My comments are minor, we should get @Teque5's review.
sigmf/utils.py
Outdated
if atype.byteorder == '>': | ||
return '_be' | ||
# must be '=' (native) or '|' (doesn't matter) | ||
return '_le' if sys.byteorder == 'little' else '_be' |
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.
Is this meant to be effectively a catch case where if the endianness is not already defined, it gets set to whatever the current system's endianness is? I don't think I follow the comment on L90
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.
I think L90 is the case where it gets past L86 & L88.
This should be slightly modified to just if, elif, else
and it will make more sense.
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.
With small changes this is ready to merge.
sigmf/utils.py
Outdated
if atype.byteorder == '>': | ||
return '_be' | ||
# must be '=' (native) or '|' (doesn't matter) | ||
return '_le' if sys.byteorder == 'little' else '_be' |
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.
I think L90 is the case where it gets past L86 & L88.
This should be slightly modified to just if, elif, else
and it will make more sense.
sigmf/utils.py
Outdated
# must be '=' (native) or '|' (doesn't matter) | ||
return '_le' if sys.byteorder == 'little' else '_be' | ||
|
||
def get_data_type_str(a): |
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.
Remember to add a docstring. Also single letter variables aren't the best. Maybe change it to ray
.
d33ae71
to
84149f4
Compare
The get_endian_str() function is separate to support my own hack for generating the string for complex int16 data ... >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype=float)) 'f64_le' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype=complex)) 'cf128_le' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype=numpy.uint32)) 'u32_le' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype=numpy.uint16)) 'u16_le' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype=numpy.complex64)) 'cf64_le' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype='>f4')) 'f32_be' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype='=f4')) 'f32_le' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype='<f4')) 'f32_le' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype='<c8')) 'cf64_le' >>> sigmf.utils.get_data_type_str(numpy.zeros(1, dtype='?')) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/s/sigmf/utils.py", line 98, in get_data_type_str raise error.SigMFError('Unsupported data type:', atype) sigmf.error.SigMFError: ('Unsupported data type:', dtype('bool'))
84149f4
to
30b72d8
Compare
@Teque5 @bhilburn Ok, I think I have now fully integrated that helpful feedback. |
@gmabey - You're correct, it can be left off for single byte datatypes, and while the spec provides an example of that, it doesn't explicitly say that. It would be good to clarify that in the spec (that's a note for another PR 😅). @gmabey - According to Github, it says there is one change requested by @Teque5 that is still unresolved, his comment on L110 regarding the import statement. Do you mind addressing that and pushing, and marking the change as resolved? I think this is then ready to merge 👍 |
@bhilburn @Teque5 Forgive my GitHub follies, but I do believe I addressed that issue (the only one I can find is to replace line 110 with When I try to find and close the change request, I get: "Sometimes commits can disappear after a force-push." |
Thanks @gmabey - two approvals and Ben has given his ✅. Merging. |
The get_endian_str() function is separate to support my own hack
for generating the string for complex int16 data ...