Skip to content

Use data transformation results in other parts of plot configuration

Utopia Developers requested to merge 218-implement-a-dagresultproxy into master

This MR ...

  • ... adds the ResultPlaceholder class, derived from Placeholder and registers it with the !dag_result YAML tag
  • ... implements a placeholder resolution function
  • ... and integrates these into the plotting framework on the level of the BasePlotCreator

This ended up being easier to do without BaseDataProxy, but directly from the Placeholder class that was implemented for the DAG.

Other changes

  • Minor bugfix in abc and base modules
  • Added a generic test function for plots, see test_dag_plotting.py, with plots configured in tests/cfg/dag_plots.yml
  • Minor other improvements (sorry, a bit all over the place):
    • BaseDataProxy no longer requires an obj ...
    • more f-strings
    • docstring improvements here and there
    • some weird leftover formatting stuff from !209 (merged)

Details

See extended documentation entry for more information and the full example.

Excerpt from there, to illustrate usage:

# ...
transform:
  # For the y values, take the mean ...
  - .mean: [!dag_tag some_data, [x, z]]
    tag: y
  # ... and use the standard deviation for the errors
  - .std: [!dag_tag some_data, [x, z]]
    tag: yerr

  # Additional transformations for ResultPlaceholders
  - .mean: [!dag_tag y]
  - .item  # ... otherwise it's still an xr.DataArray
  - .format: ["Some Data (total mean: {:.3g})", !dag_prev ]
    tag: title_str

# Now, use the place holder in the helper configuration
helpers:
  set_title:
    title: !dag_result title_str

Anything to double-check?

  • Interface and usage ok?
  • Error messages helpful?
  • Documentation understandable? Anything to add?
  • Limitations ok – for now? (Can always extend this at a later point ... but perhaps not pressing now?)

Can this MR be accepted?

  • Implementation ready
  • Tests added or adjusted
  • Documentation extended or updated
  • Code quality

Related issues

Closes #218 (closed)

Edited by Utopia Developers

Merge request reports