Common string parser #9
Replies: 2 comments 2 replies
-
To avoid this ambiguity, maybe we should avoid guess work entirely and never infer the operation implied by whitespace ? |
Beta Was this translation helpful? Give feedback.
-
Going to quote from https://github.com/quantity-dev/dimension-api/issues/3 which discussed a common parser for dimensions. But the ideas are similar to units.
So yes, a common string parser would be a good library. Here's why it shouldn't be baked into an API library: this is entirely about implementation, not behaviour. E.g. Astropy implements a number of different unit parsers because there are different standards. But all units, once initialized behave the same way because they are following Astropy's API. If we look to https://data-apis.org/array-api/latest/API_specification/data_types.html, we see that while they discuss what are the minimum required set of dtypes, there is no object to actually describe these data types, no way to initialize them, no way to parse them. It's purely discussion, but constitutes expectations for conforming to the API. Bringing this back to units, the equivalent would be if we enumerated in the API docs what are the minimum set of units (and the strings which can be used to initialize them) (we probably should do this). But again, no implementation! That's left to implementing libraries. We can, as this discussion suggestions and of which I am a majorly in favor of, have a common parser library that helps implement these API requirements. This is an implementation of part of the API and one which implementing libraries can choose to have as a runtime dependency. It is not, however, baked into the API itself. Really all I'm saying is 💯🎉 to the idea. 👎 to accessing the parser as |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Should the API provide a common parser to convert strings to a dict-like object for the libraries to use? I think this is necessary to ensure a consistency between libraries whch may use slightly different rules for parsing.
m / kg s
could interpreted asm^11 kg^-1 s^-1
orm^11 kg^-1 s^1
Beta Was this translation helpful? Give feedback.
All reactions