Skip to content

Commit 5069b82

Browse files
committed
Refactor tools.py by removing the get_all_parameters function and simplifying measurement condition extraction. Updated import statements and fixed a typo in the docstring for _get_measurement_conditions.
1 parent fbc069e commit 5069b82

1 file changed

Lines changed: 3 additions & 23 deletions

File tree

pyenzyme/tools.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from pydantic import BaseModel
77

8-
from pyenzyme.versions.v2 import EnzymeMLDocument, Measurement, Parameter
8+
from pyenzyme.versions.v2 import EnzymeMLDocument, Measurement
99

1010

1111
def to_dict_wo_json_ld(obj: BaseModel):
@@ -58,18 +58,6 @@ def _recursive_key_removal(obj: dict | list, key: str):
5858
_recursive_key_removal(entry, key)
5959

6060

61-
def get_all_parameters(enzmldoc: EnzymeMLDocument):
62-
"""Extracts all parameters from an EnzymeMLDocument.
63-
64-
Args:
65-
enzmldoc (EnzymeMLDocument): The EnzymeMLDocument to extract parameters from.
66-
67-
Returns:
68-
list[Parameter]: A list of all parameters in the EnzymeMLDocument.
69-
"""
70-
return find_unique(enzmldoc, target=Parameter)
71-
72-
7361
def find_unique(obj, target):
7462
"""Composite function that extracts all instances of a specified target type from a given object.
7563
@@ -200,7 +188,7 @@ def _get_measurement_conditions(
200188
attribute: Literal["initial", "prepared"] = "initial",
201189
) -> dict:
202190
"""
203-
Extract measurement conditions as a dictionary, inclding pH and temperature.
191+
Extract measurement conditions as a dictionary, including pH and temperature.
204192
Does not account for variation in units.
205193
206194
Args:
@@ -214,15 +202,7 @@ def _get_measurement_conditions(
214202

215203
# Add species conditions using the specified attribute
216204
for species_data in measurement.species_data:
217-
if attribute == "initial":
218-
value = species_data.initial
219-
elif attribute == "prepared":
220-
value = species_data.prepared
221-
else:
222-
raise ValueError(
223-
f"Invalid attribute: {attribute}. Attribute must be 'initial' or 'prepared'."
224-
)
225-
205+
value = getattr(species_data, attribute)
226206
if value is not None:
227207
conditions[species_data.species_id] = value
228208

0 commit comments

Comments
 (0)