Skip to content

Allow arbitrary precision for generic numeric types #1631

@bendichter

Description

@bendichter

What would you like to see added to PyNWB?

I just got this question from @urut

We're exporting things with matnwb and running through pynwb validator and it gives error below. question is, what is meant by 'int' here -- int32? single?

image (25)

The answer is int32, but I think this brings up a good point, and this is a common hurdle users producing NWB files outside of PyNWB.

IMO, specifying type precision this way has two problems:

  1. It's unclear. I get that single precision is often the default, so int can be shorthand for int32, but that isn't always the case: MATLAB does not have a default integer precision (int64(5) works but int(5) does not) and the default precision for floats is double (64). Of course when you are creating a variable you must choose a precision, but when used in a schema to me it's more natural to interpret this an int of any precision in this case.
  2. It is inflexible. I would also prefer the "any precision" interpretation because it would allow the user to decide what precision they need. Enforcing a higher precision than necessary is wasteful and honestly I don't really see an upside.

Is your feature request related to a problem?

No response

What solution would you like?

My most preferred solution would be to map "int" to "int8", "uint" to "uint8", and "float" to "float8". I'm pretty sure this would not invalidate any currently valid NWB files and would not break any tools.

If there is some reason why keeping single-precision is important, then my next favorite solution would be to change the schema to make the data requirement explicit, changing all instances of "int" to "int32".

If that is too big of a lift, then another solution that would at least move us in the right direction would be to enhance the messages produced by the validator to be explicit about the precision requirement.

Do you have any interest in helping implement the feature?

Yes.

Code of Conduct

Metadata

Metadata

Assignees

Labels

category: proposalproposed enhancements or new featurespriority: highimpacts proper operation or use of feature important to most userstopic: validatorissues related to validation of files

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions