Wrapping `ValuesBounded` or anything that uses it

The problem

ValuesBounded has a units attribute in Fortran. This is important so we can set the units correctly in Fortran and important for both communication between Fortran modules but also when returning these containers back out to Python. However, the units attribute shouldn't exist in the Python equivalent because we have Pint for that. Crucially, the unit is not coupled to the class i.e. ValuesBounded could have any units, rather than e.g. always having units of mass (which is the case for example a Flux class, which always has units of "kg / s", say).

We can't support these arbitrary units with our current pattern/schema because it relies on the thing being wrapped always having the same unit dimensions (i.e. kind of unit e.g. mass, time, mass per time). The pattern is further complicated because ValuesBounded has two attributes that are pint arrays, so we have to convert them to the same unit before passing them to Fortran-world.

Definition of "done"

  • Decision is made about whether we need to support wrapping this class at all. I think the answer is that we do, but maybe there is a way we can avoid this by doing something else.
  • If we decide that we need to wrap this class, we should be able to do the following:
    • create a ValuesBounded class in Python using Pint quantities only
    • have the units and magnitudes appear correctly on the Fortran side
    • error is raised if ValuesBounded.values and ValuesBounded.value_last_bound can't be converted to the same unit
    • the values and value_last_bound attributes are exposed in Python as Pint quantities
    • the units attribute is not exposed in Python (doesn't make sense on the Python side)

Additional context

Arose in !56 (merged), where the relevant tests where simply xfailed (https://gitlab.com/magicc/fgen/-/blob/012e4d79fb1da7c328341765351780851847df36/tests/test-data/two_layer_model/test_module.py#L49). We should probably make a dedicated test directory for working with this, rather than having it be tightly coupled into the two-layer tests.

Edited by Zebedee Nicholls