biocrnpyler.Parameter
- class biocrnpyler.Parameter(parameter_name: str, parameter_value: str | Real, unit=None)[source]
Base class for representing parameters in BioCRNpyler.
Parameters represent kinetic constants, initial concentrations, and other numerical values used in chemical reaction networks. This class provides validation for parameter names, values, and units.
- Parameters:
- parameter_namestr
Name of the parameter. Must start with a letter and contain at least one character.
- parameter_valuefloat or str
Value of the parameter. Can be a number or a string in formats: ‘1.00’, ‘1e4’, or ‘2/5’ (rational). Strings are automatically converted to numerical values.
- unitstr, optional
Unit of the parameter (e.g., ‘1/s’, ‘nM’, ‘molecules’). If None, defaults to empty string.
- Attributes:
parameter_namestrstr: The name of the parameter.
valuefloatfloat: The numerical value of the parameter.
unitstrstr: The unit string for the parameter.
See also
ParameterEntryParameter with database lookup keys.
ModelParameterParameter with search and found keys for defaulting.
ParameterDatabaseDatabase for storing and retrieving parameters.
Notes
This is the base class for all parameter types in BioCRNpyler. In practice, subclasses
ParameterEntryandModelParameterare more commonly used as they support the parameter lookup and defaulting system.Parameter values provided as strings are automatically converted:
‘1e4’ –> 10000.0
‘2/5’ –> 0.4
‘1.23’ –> 1.23
Examples
Create a basic parameter:
>>> param = bcp.Parameter('kb', 100.0, unit='1/s') >>> param.parameter_name 'kb' >>> param.value 100.0
Create a parameter from a string value:
>>> param = bcp.Parameter('ku', '1e-4', unit='1/s') >>> param.value 0.0001
Create a parameter from a rational string:
>>> param = bcp.Parameter('ratio', '3/4') >>> param.value 0.75
- __init__(parameter_name: str, parameter_value: str | Real, unit=None)[source]
Initialize a Parameter object.
See class docstring for parameter descriptions.
Methods
__init__(parameter_name, parameter_value[, unit])Initialize a Parameter object.
Attributes
str: The name of the parameter.
str: The unit string for the parameter.
float: The numerical value of the parameter.
- __eq__(other)[source]
Test equality between parameters or parameter and number.
- Parameters:
- otherParameter or float
Object to compare with. Can be another Parameter object or a numerical value.
- Returns:
- bool
True if values are equal, False otherwise.
- Raises:
- TypeError
If
othercannot be compared (not a Parameter or number).
- __hash__()[source]
Return hash value for the parameter.
- Returns:
- int
Hash value based on parameter name, value, and unit.
- property parameter_name: str
str: The name of the parameter.
- property unit: str
str: The unit string for the parameter.
- property value: Real
float: The numerical value of the parameter.