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

Add a method to get a dict of _all_ summary variables #4765

Closed
rtimms opened this issue Jan 16, 2025 · 1 comment · Fixed by #4824
Closed

Add a method to get a dict of _all_ summary variables #4765

rtimms opened this issue Jan 16, 2025 · 1 comment · Fixed by #4824
Assignees

Comments

@rtimms
Copy link
Contributor

rtimms commented Jan 16, 2025

As of #4621, summary variables are now evaluated lazily to improve performance. However, it has made getting a data frame of all the summary results a little clunky. E.g. instead of df = pd.DataFrame(sim.solution.summary_variables) you now need to do

summary_variables = sim.solution.summary_variables
all_summary_variables = {
    k: summary_variables[k] for k in summary_variables.all_variables
}
all_summary_variables["Cycle number"] = list(
    summary_variables.cycle_number
)
df = pd.DataFrame(all_summary_variables)

or something equivalent. I propose we add an all_summary_variables attribute that returns the same as all_summary_variables in the above snippet. Or just make it so that summary_variables["Cycle number"] returns list(summary_variables.cycle_number). This would (almost) be consistent with Solution where you can do sol.t or sol["Time [s]"].data.

@pipliggins let me know if this is sensible or if I'm missing something from the new SummaryVariables class.

@pipliggins
Copy link
Contributor

@rtimms this proposal looks fine to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants