PyBaMM icon indicating copy to clipboard operation
PyBaMM copied to clipboard

Extend Step String Tagging Functionality

Open mleot opened this issue 1 year ago • 1 comments

Description

This is a feature request covering multiple related feature additions surrounding the pybamm.step.string tags functionality. Currently there is the ability to add tags to pybamm step strings, and there is the ability to search an experiment for the indices where specific tags exist. There is not currently any additional functionality of the step string tags. The proposed added functionality is the following:

  • The ability to search a solution object for specific steps based on tags
  • The added functionality to export tags along with cycle and step indices when using the Solution.get_data_dict() method

Motivation

I believe these features are the would-be natural evolution of additional functionality surrounding step string tags. I believe the true utility of these step string tags come when you can use them to filter a solution object, or to filter data exported from a solution object.

Possible Implementation

Core Implementation

I believe there are a number of steps for the proposed core implementation.

  1. Add a property to the Solution class: .tags
  2. By default, when running an experiment, each time a step_solution is generated, the tags from the associated step (from the experiment) should then be assigned as a property to the Solution object
  3. The method Solution.get_data_dict() should export a 'Tags' column along with 'Cycle' and 'Step' columns.
  4. An additional method should be added: Solution.search_tags(), similar to Experiment.search_tag(), allowing for searching of one of many tags in the solution sub_solutions

Additional Features

I also believe there are a number of additional changes that may be useful to include as well

  1. The inclusion of tags in the __repr__ of the Solution object
  2. Similar to how tags would be associated with a Solution object (as a property), there may also be the properties .cycle and .step which are associated with a Solution when the solution results from an experiment.
  3. The Solution object holds the additional variables, accessible through the __getitem__() method, being "Cycle", "Step", and "Tags"

Remaining Questions

  • Should calling Solution.get_data_dict() when there are no tags result in returning an empty "Tags" column, or no "Tags" column at all?

Additional context

No response

mleot avatar Jun 14 '24 01:06 mleot

Should calling Solution.get_data_dict() when there are no tags result in returning an empty "Tags" column, or no "Tags" column at all?

I think an empty tags column is better for consistency

valentinsulzer avatar Jun 17 '24 17:06 valentinsulzer