Open bendichter opened 1 year ago
Thanks for helpful description. If I understand it correctly, this issue touches on two separate questions:
Just a few thoughts for a few possible ways to address this:
Re 1.:
HDMFIO.write
and/or the BuildManager
to allow escalating of conversion warnings to errorsRe 2.:
I'm sure there are other options. Any thoughts?
Thanks for breaking this down, @oruebel. This is exactly right. As per our conversation, let's focus first on catching non-castable data in the constructor.
Since type
and shape
are already specified via separate arguments in docval, I'm wondering whether the simplest approach may be to add a dtype
key in docval to specify the data type for arrays.
That could work!
@mavaylon1 can you help with this?
What would you like to see added to HDMF?
I would be great if we could check the data types of arrays during construction. Right now our solution is to cast during write and throw a warning, but this is problematic because it could lead to incorrect conversions. Consider this example:
Here,
data
contains0.3
, which is wrong since it should only take integers (uint32
, to be precise). This throws a warning:I'm all for casting values if it makes sense, but I don't think it makes sense to cast a float as an int if the value changes. The other problem is the user doesn't see this error until write occurs. I'd much rather the data type be clearly communicated in the function signature and the documentation and that it be caught on construction.
Is your feature request related to a problem?
No response
What solution would you like?
see above
Do you have any interest in helping implement the feature?
No.
Code of Conduct