Skip to content

Add auto-detection of creator and decorator to explicitly specify plot functions

As proposed in #40 (closed), it would be nice to let a plot function declare, which decorator should be used.

What was not considered there is that the plot configuration is something that the PlotManager evaluates and only then a plot creator is instantiated. Thus, the creator argument in the plot configuration is really the only thing that can be used to identify which creator should be used.

To still make it easier to define a plot configuration, the following idea arose: Let the PlotManager ask all available types of plot creators if they can possibly work with the given plot configuration. This led to the AbstractPlotCreator.can_plot interface, which receives the plot configuration and should then return a boolean whether it deems itself capable of handling the configuration. If only one of the registered creators declares itself a candidate for this configuration, the case is clear and we have auto-detected which plot creator to use. 🎉

The plot creators can then implement can_plot themselves. For example, the ExternalPlotCreator and derived classes can check if they can resolve the plot function, if the plot function declares itself fitting for a certain creator (which is essentially #40 (closed)) or whether the plot function signature fits the required signature.

That's also where the decorator comes in: It can be used to declare a plot function as fitting for a certain creator.

Can this MR be accepted

  • Implemented the features / enhancements
    • Auto-detection interface
    • Auto-detection implementation for ExternalPlotCreator
    • Plot function decorator
  • Existing tests still work (assures backwards-compatibility)
  • Added tests for the new features
  • Added documentation
    • docstrings
    • A few paragraphs in the sphinx documentation on how it is decided which plot creator is used
    • Example for the plot function decorator
  • Pipeline passing without warnings
  • Added changelog entry
  • Bumped version to 0.7.0rc1
  • Approved by ... no-one (as @herdeanu is on holidays but this should soon be merged, review has to be postponed)

Related issues

Closes #40 (closed) (only refers to the decorator)

Edited by Utopia Developers

Merge request reports