Skip to content

Catalogue file format #46

@yunruse

Description

@yunruse

Take the following (slightly contrived) unit definition:

pascal = Pa = SI(I(Unit(pressure, 'pascal', "Pa", SI_large, info="Unit of pressure")))

This is… bleh. There is a lot of annoyance for making large catalogues, however, and I'm beginning to feel the pain – especially when I'm in the weeds making units and annoyed at having to do Python grammar, or (especially) repeat the name.

My concept is this: we have a custom file format.

Interpreting this will not be trivial. However, I believe it wise to prioritise investigating this concept before any additional major cataloguing efforts.

File format concept

Prefix definition

TODO.

PrefixSet definition

Dimension definition

TODO. Ideally we could invent the meter directly from nothing.

Units definition

The following information needs to be encapsulated:

  • Some marker to indicate the unit is ready for display
  • At least one name
  • Any number of symbols
  • An optional numeric part, here 9.980_665
  • An optional uncertainty (for contrived example let's say 0.000_001
  • A unit (here, meter / second ** 2)
  • Any number of prefix sets to assign
  • Any number of display tags (e.g. "SI unit" or "Imperial")
  • A description

One example syntax, which at least works with Python syntax highlighters, is:

@standard_gravity = 'g' = 9.980665(1) * meter / second**2
    [SI_large] #SI # defined by convention

where, here, a newline followed by indentation is treated as a line continuation.

Implementation notes

I think it would be useful to keep an file e.g. data.py which while not used is an example of how to create Units and Dimensions from Python rather than from file.

Implementing this will mean all units are loaded from file, which will annoy type checkers.
In order to fix this, we generate one huge ol' .pyi typed stub file.

Related issues

If implemented, this will greatly enable the following:

It may also enable:

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA feature request for Noether functionality.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions