Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TimothyWillard opened this issue Oct 17, 2024 · 1 comment
Labels
gempyor Concerns the Python core. low priority Low priority. plotting Relating to plotting and/or visualizations.

Comments

@TimothyWillard
Copy link
Contributor

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.

@TimothyWillard TimothyWillard added gempyor Concerns the Python core. low priority Low priority. labels Oct 18, 2024
@jcblemai
Copy link
Collaborator

jcblemai commented Oct 18, 2024

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"})

@TimothyWillard TimothyWillard added the plotting Relating to plotting and/or visualizations. label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gempyor Concerns the Python core. low priority Low priority. plotting Relating to plotting and/or visualizations.
Projects
None yet
Development

No branches or pull requests

2 participants