HopkinsIDD / flepiMoP

The Flexible Epidemic Modeling Pipeline
https://flepimop.org
GNU General Public License v3.0
9 stars 4 forks source link

[Feature request]: Extract `Compartments.plot` Into A Standalone Function #349

Open TimothyWillard opened 6 days ago

TimothyWillard commented 6 days ago

Label

gempyor

Priority Label

low priority

Is your feature request related to a problem? Please describe.

Currently the function to plot compartments is attached to the Compartments class in gempyor.compartments. Which bloats the object and isn't core to its logic of parsing and handling compartments/transitions. Lightly related to GH-345.

Is your feature request related to a new application, scenario round, pathogen? Please describe.

n/a

Describe the solution you'd like

Create a new function, called plot_compartments or similar, that is separate from the Compartments class and takes a an instance of the Compartments class. In the future this could be split out into a separate package if desired, but currently should be put into a new module in gempyor called viz or similar. Could also allow us to move the graphviz dependency into a separate dependency group.

jcblemai commented 5 days ago

Interesting, I would trust you on what's best but I believe there are some arguments for having the plot function as one function for each object.

One of them is that it is core to the object functionnality, as much as it's possibility to be printed and exported. We want to be able to plot both the internal representation (the closest to what the rk4 integrator is getting) and the external representation (the exported dataframe). It's the same with the DataFrame.plot methods in pandas, or the xarray.plot method. These are very convienient while working with these librairies

While it would be important to improve these functions (return axes, take axes as potential arguements, ...), the code to plot each object is very much addhoc to the object internal (even external) representation that I don't see it working well outside of that object remit.

from gempyor import compartments

cp = compartments.Compartments(config_snippet)
cp.plot_graph(filters={"age":"age0to17"})

vs

from gempyor import compartments, viz
viz.plot_comparments_graph(cp, filters={"age":"age0to17"})