to_xarray: auto-convert units
1 unresolved thread
1 unresolved thread
Closes #85 (closed)
data.tools
:
- auto-convert units in
to_xarray
-
(this causes a lot of trouble, should be done in a separate merge request)Info
: always have units in meta - added convenience routines for unit comparison (
compatible_units
,equivalent_units
)
Edited by Sebastian Müller
Merge request reports
Activity
Filter activity
requested review from @mlange
assigned to @muellese
Regarding test errors... Example code from
test_parametric.py
:time = datetime(2000, 1, 1) in_info = fm.Info( time=None, grid=fm.UniformGrid((20,)), units="m", ) source = fm.modules.ParametricGrid( info=in_info, func=lambda t, x: x, ) trigger = fm.modules.TimeTrigger( in_info=fm.Info(time=None, grid=None, units=None), start=time, step=timedelta(days=1), ) sink = fm.modules.DebugConsumer( {"Input": fm.Info(None, grid=None)}, start=datetime(2000, 1, 1), step=timedelta(days=1), ) composition = fm.Composition([source, trigger, sink]) composition.initialize() source.outputs["Grid"] >> trigger.inputs["In"] trigger.outputs["Out"] >> sink.inputs["Input"]
Here,
trigger
just passes on the data, in meters.
sink
specifies no units, so with the new units handling, it expectsdimensionless
. This does not work, and also should not.It worked before, because
units
was not in the info and thus ignored. Which was a bug.I can do the test fixes in an MR on top of this.
Edited by Martin Lange
mentioned in merge request !215 (merged)
This is contained in !215 (merged), minus revert, plus test fixes.