Skip to content

Commit 1b4b02b

Browse files
authored
Python 3.11 compatibility + Test on Python3.11 (#1876)
* GHA: Run tests on Python3.11 * Fixes related to Python3.11 changes to enums (https://docs.python.org/3/whatsnew/3.11.html#enum) * Fix unreliable string `is` comparison
1 parent 9ef2e36 commit 1b4b02b

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

.github/workflows/test_python_ver_matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
python-version: [3.8, 3.9, '3.10']
27+
python-version: [3.8, 3.9, '3.10', '3.11']
2828
experimental: [false]
2929

3030
steps:

python/sdist/amici/ode_export.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ def _derivative(self, eq: str, var: str, name: str = None) -> None:
18721872
cv for cv in ['w', 'tcl']
18731873
if var_in_function_signature(eq, cv)
18741874
and cv not in self._lock_total_derivative
1875-
and var is not cv
1875+
and var != cv
18761876
and min(self.sym(cv).shape)
18771877
and (
18781878
(eq, var) not in ignore_chainrule
@@ -3070,7 +3070,7 @@ def _write_model_header_cpp(self) -> None:
30703070
self._get_symbol_name_initializer_list('y'),
30713071
'OBSERVABLE_TRAFO_INITIALIZER_LIST':
30723072
'\n'.join(
3073-
f'ObservableScaling::{trafo}, // y[{idx}]'
3073+
f'ObservableScaling::{trafo.value}, // y[{idx}]'
30743074
for idx, trafo in enumerate(
30753075
self.model.get_observable_transformations()
30763076
)

python/sdist/amici/ode_model.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,15 @@ class Observable(ModelQuantity):
297297

298298
_measurement_symbol: Union[sp.Symbol, None] = None
299299

300-
def __init__(self,
301-
identifier: sp.Symbol,
302-
name: str,
303-
value: sp.Expr,
304-
measurement_symbol: Optional[sp.Symbol] = None,
305-
transformation: Optional[ObservableTransformation] = 'lin'):
300+
def __init__(
301+
self,
302+
identifier: sp.Symbol,
303+
name: str,
304+
value: sp.Expr,
305+
measurement_symbol: Optional[sp.Symbol] = None,
306+
transformation: Optional[
307+
ObservableTransformation] = ObservableTransformation.LIN
308+
):
306309
"""
307310
Create a new Observable instance.
308311

0 commit comments

Comments
 (0)