data-exp-lab / analysis_schema

Experimental declarative analysis schema for yt
MIT License
2 stars 2 forks source link

Can only specify a visaulization once #34

Open samwalkow opened 2 years ago

samwalkow commented 2 years ago

Description

Once you pick a visualization, that option disappears. What if you want to create a list of two projection plots? That's not possible right now.

What I Did

In the schema_model.py file, this is how the Plot attribute is set up. How can we reuse specifications?

 Plot: Optional[List[Visualizations]]

I think we'll have to change the Visaulizations dataclass. Maybe we make more lists?

Right now we have:

class Visualizations(ytBaseModel):
    """
    This class organizes the attributes below so users
    can select the plot by name,
    and see the correct arguments as suggestions
    """

    SlicePlot: Optional[SlicePlot]
    ProjectionPlot: Optional[ProjectionPlot]
    PhasePlot: Optional[PhasePlot]

Should it be:

    SlicePlot: Optional[List[SlicePlot]]
    ProjectionPlot: Optional[List[ProjectionPlot]]
    PhasePlot: Optional[List[PhasePlot]]
chrishavlin commented 2 years ago

I think your suggestion of putting the *Plots into lists would work. If we do that, how do you feel about renaming the Visualizations attributes to be plural? i.e.,:

class Visualizations(ytBaseModel):
    """
    This class organizes the attributes below so users
    can select the plot by name,
    and see the correct arguments as suggestions
    """

    SlicePlots: Optional[List[SlicePlot]]
    ProjectionPlots: Optional[List[ProjectionPlot]]
    PhasePlots: Optional[List[PhasePlot]]

IMO it's a nice way to grammatically signal that you can put multiples of any of them.

The new Visualizations runner in _model_instantiation would need some minor tweaking to account for the lists. See here:

https://github.com/data-exp-lab/analysis_schema/blob/f264deba28fe69f98c2f09bdbcb71487239f9668/analysis_schema/_model_instantiation.py#L155-L164