Skip to content

Commit

Permalink
documented evolving conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjamesgarza committed Apr 27, 2024
1 parent a52acc1 commit e7df9c5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/acom_music_box/music_box_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def from_UI_JSON(cls, UI_JSON, species_list, reaction_list):
reaction_list (ReactionList): A ReactionList containing the reactions involved in the simulation.
Returns:
object: An instance of the class with the settings from the UI JSON object.
object: An instance of the Conditions class with the settings from the UI JSON object.
"""
pressure = convert_pressure(UI_JSON['conditions']['environmental conditions']['pressure'], 'initial value')

Expand Down Expand Up @@ -97,7 +97,7 @@ def from_config_JSON(cls, path_to_json, config_JSON, species_list, reaction_list
reaction_list (ReactionList): A ReactionList containing the reactions involved in the simulation.
Returns:
object: An instance of the class with the settings from the configuration JSON object.
object: An instance of the Conditions class with the settings from the configuration JSON object.
"""
pressure = convert_pressure(config_JSON['environmental conditions']['pressure'], 'initial value')

Expand Down
37 changes: 31 additions & 6 deletions src/acom_music_box/music_box_evolving_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ class EvolvingConditions:

def __init__(self, headers=None, times=None, conditions=None):
"""
Initializes a new instance of the EvolvingConditions class.
Initializes an instance of the EvolvingConditions class.
Args:
time (List[float]): A list of time points. Default is an empty list.
conditions (List[Conditions]): A list of associated conditions. Default is an empty list.
headers (list, optional): A list of headers for the data. Defaults to None.
times (list, optional): A list of times at which the conditions are recorded. Defaults to None.
conditions (list, optional): A list of conditions at each time point. Defaults to None.
"""
self.headers = headers if headers is not None else []
self.times = times if times is not None else []
Expand All @@ -33,7 +34,7 @@ def from_UI_JSON(cls, UI_JSON, species_list, reaction_list):
Create a new instance of the EvolvingConditions class from a JSON object.
Args:
UI_JSON (dict): A JSON object representing the evolving conditions.
UI_JSON (dict): A JSON object representing the evolving conditions.
Returns:
EvolvingConditions: A new instance of the EvolvingConditions class.
Expand Down Expand Up @@ -86,8 +87,22 @@ def from_UI_JSON(cls, UI_JSON, species_list, reaction_list):

@classmethod
def from_config_JSON(cls, path_to_json ,config_JSON, species_list, reaction_list):
# Initialize empty lists for times and conditions

"""
Creates an instance of the EvolvingConditions class from a configuration JSON object.
This class method takes a path to a JSON file, a configuration JSON object, a SpeciesList,
and a ReactionList, and uses them to create a new instance of the EvolvingConditions class.
Args:
path_to_json (str): The path to the JSON file containing the initial conditions and settings.
config_JSON (dict): The configuration JSON object containing the initial conditions and settings.
species_list (SpeciesList): A SpeciesList containing the species involved in the simulation.
reaction_list (ReactionList): A ReactionList containing the reactions involved in the simulation.
Returns:
EvolvingConditions: An instance of the EvolvingConditions class with the settings from the configuration JSON object.
"""


evolving_conditions = EvolvingConditions()

Expand Down Expand Up @@ -186,4 +201,14 @@ def read_conditions_from_file(cls, file_path, species_list, reaction_list):

#allows len overload for this class
def __len__(self):
"""
Returns the number of time points in the EvolvingConditions instance.
This method is a part of Python's data model methods and allows the built-in
`len()` function to work with an instance of the EvolvingConditions class.
It should return the number of time points for which conditions are recorded.
Returns:
int: The number of time points in the EvolvingConditions instance.
"""
return len(self.times)

0 comments on commit e7df9c5

Please sign in to comment.