mxlpy 0.22.0__py3-none-any.whl → 0.23.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mxlpy/__init__.py +11 -2
- mxlpy/carousel.py +6 -4
- mxlpy/compare.py +2 -2
- mxlpy/integrators/__init__.py +4 -0
- mxlpy/integrators/int_assimulo.py +3 -3
- mxlpy/integrators/int_diffrax.py +119 -0
- mxlpy/integrators/int_scipy.py +12 -6
- mxlpy/label_map.py +1 -2
- mxlpy/mc.py +22 -22
- mxlpy/mca.py +8 -4
- mxlpy/meta/codegen_model.py +2 -1
- mxlpy/meta/codegen_mxlpy.py +194 -58
- mxlpy/meta/source_tools.py +124 -80
- mxlpy/meta/sympy_tools.py +5 -5
- mxlpy/model.py +288 -91
- mxlpy/plot.py +16 -14
- mxlpy/sbml/_export.py +13 -5
- mxlpy/sbml/_import.py +68 -547
- mxlpy/scan.py +38 -242
- mxlpy/simulator.py +4 -359
- mxlpy/types.py +655 -83
- mxlpy/units.py +5 -0
- {mxlpy-0.22.0.dist-info → mxlpy-0.23.0.dist-info}/METADATA +4 -1
- {mxlpy-0.22.0.dist-info → mxlpy-0.23.0.dist-info}/RECORD +26 -27
- mxlpy/sbml/_mathml.py +0 -692
- mxlpy/sbml/_unit_conversion.py +0 -74
- {mxlpy-0.22.0.dist-info → mxlpy-0.23.0.dist-info}/WHEEL +0 -0
- {mxlpy-0.22.0.dist-info → mxlpy-0.23.0.dist-info}/licenses/LICENSE +0 -0
mxlpy/plot.py
CHANGED
@@ -28,6 +28,7 @@ import numpy as np
|
|
28
28
|
import pandas as pd
|
29
29
|
import seaborn as sns
|
30
30
|
from cycler import cycler
|
31
|
+
from matplotlib import colormaps
|
31
32
|
from matplotlib import pyplot as plt
|
32
33
|
from matplotlib.axes import Axes
|
33
34
|
from matplotlib.colors import (
|
@@ -37,6 +38,8 @@ from matplotlib.colors import (
|
|
37
38
|
colorConverter, # type: ignore
|
38
39
|
)
|
39
40
|
from matplotlib.figure import Figure
|
41
|
+
from matplotlib.legend import Legend
|
42
|
+
from matplotlib.patches import Patch
|
40
43
|
from mpl_toolkits.mplot3d import Axes3D
|
41
44
|
|
42
45
|
from mxlpy.label_map import LabelMapper
|
@@ -541,7 +544,7 @@ def bars(
|
|
541
544
|
sns.barplot(data=cast(pd.DataFrame, x), ax=ax)
|
542
545
|
|
543
546
|
if xlabel is None:
|
544
|
-
xlabel = x.index.name if x.index.name is not None else ""
|
547
|
+
xlabel = x.index.name if x.index.name is not None else "" # type: ignore
|
545
548
|
_default_labels(ax, xlabel=xlabel, ylabel=ylabel)
|
546
549
|
if isinstance(x, pd.DataFrame):
|
547
550
|
ax.legend(x.columns)
|
@@ -651,7 +654,7 @@ def lines(
|
|
651
654
|
)
|
652
655
|
_default_labels(
|
653
656
|
ax,
|
654
|
-
xlabel=x.index.name if xlabel is None else xlabel,
|
657
|
+
xlabel=x.index.name if xlabel is None else xlabel, # type: ignore
|
655
658
|
ylabel=ylabel,
|
656
659
|
)
|
657
660
|
if legend:
|
@@ -792,7 +795,11 @@ def line_mean_std(
|
|
792
795
|
color=color,
|
793
796
|
alpha=alpha,
|
794
797
|
)
|
795
|
-
_default_labels(
|
798
|
+
_default_labels(
|
799
|
+
ax,
|
800
|
+
xlabel=df.index.name, # type: ignore
|
801
|
+
ylabel=None,
|
802
|
+
)
|
796
803
|
return fig, ax
|
797
804
|
|
798
805
|
|
@@ -865,11 +872,11 @@ def _create_heatmap(
|
|
865
872
|
if title is not None:
|
866
873
|
ax.set_title(title)
|
867
874
|
ax.set_xticks(
|
868
|
-
np.arange(0, len(df.columns), 1, dtype=float) + 0.5,
|
875
|
+
np.arange(0, len(df.columns), 1, dtype=float) + 0.5, # type: ignore
|
869
876
|
labels=xticklabels,
|
870
877
|
)
|
871
878
|
ax.set_yticks(
|
872
|
-
np.arange(0, len(df.index), 1, dtype=float) + 0.5,
|
879
|
+
np.arange(0, len(df.index), 1, dtype=float) + 0.5, # type: ignore
|
873
880
|
labels=yticklabels,
|
874
881
|
)
|
875
882
|
|
@@ -906,8 +913,8 @@ def heatmap(
|
|
906
913
|
ax=ax,
|
907
914
|
df=df,
|
908
915
|
title=title,
|
909
|
-
xlabel=df.index.name,
|
910
|
-
ylabel=df.columns.name,
|
916
|
+
xlabel=df.index.name, # type: ignore
|
917
|
+
ylabel=df.columns.name, # type: ignore
|
911
918
|
xticklabels=cast(list, df.columns),
|
912
919
|
yticklabels=cast(list, df.index),
|
913
920
|
annotate=annotate,
|
@@ -943,8 +950,8 @@ def heatmap_from_2d_idx(
|
|
943
950
|
|
944
951
|
return _create_heatmap(
|
945
952
|
df=df2d,
|
946
|
-
xlabel=df2d.index.name,
|
947
|
-
ylabel=df2d.columns.name,
|
953
|
+
xlabel=df2d.index.name, # type: ignore
|
954
|
+
ylabel=df2d.columns.name, # type: ignore
|
948
955
|
xticklabels=[f"{i:.2f}" for i in df2d.columns],
|
949
956
|
yticklabels=[f"{i:.2f}" for i in df2d.index],
|
950
957
|
ax=ax,
|
@@ -1064,11 +1071,6 @@ def shade_protocol(
|
|
1064
1071
|
add_legend: bool = True,
|
1065
1072
|
) -> None:
|
1066
1073
|
"""Shade the given protocol on the given axis."""
|
1067
|
-
from matplotlib import colormaps
|
1068
|
-
from matplotlib.colors import Normalize
|
1069
|
-
from matplotlib.legend import Legend
|
1070
|
-
from matplotlib.patches import Patch
|
1071
|
-
|
1072
1074
|
cmap = colormaps[cmap_name]
|
1073
1075
|
norm = Normalize(
|
1074
1076
|
vmin=protocol.min() if vmin is None else vmin,
|
mxlpy/sbml/_export.py
CHANGED
@@ -10,7 +10,7 @@ import numpy as np
|
|
10
10
|
|
11
11
|
from mxlpy.meta.source_tools import get_fn_ast
|
12
12
|
from mxlpy.sbml._data import AtomicUnit, Compartment
|
13
|
-
from mxlpy.types import Derived
|
13
|
+
from mxlpy.types import Derived, InitialAssignment
|
14
14
|
|
15
15
|
if TYPE_CHECKING:
|
16
16
|
from collections.abc import Callable
|
@@ -448,7 +448,7 @@ def _create_sbml_variables(
|
|
448
448
|
cpd.setBoundaryCondition(False)
|
449
449
|
cpd.setHasOnlySubstanceUnits(False)
|
450
450
|
# cpd.setUnit() # FIXME: implement
|
451
|
-
if isinstance((init := variable.initial_value),
|
451
|
+
if isinstance((init := variable.initial_value), InitialAssignment):
|
452
452
|
ar = sbml_model.createInitialAssignment()
|
453
453
|
ar.setId(_convert_id_to_sbml(id_=name, prefix="IA"))
|
454
454
|
ar.setName(_convert_id_to_sbml(id_=name, prefix="IA"))
|
@@ -494,11 +494,19 @@ def _create_sbml_parameters(
|
|
494
494
|
sbml_model : libsbml.Model
|
495
495
|
|
496
496
|
"""
|
497
|
-
for
|
497
|
+
for name, value in model.get_raw_parameters().items():
|
498
498
|
k = sbml_model.createParameter()
|
499
|
-
k.setId(_convert_id_to_sbml(id_=
|
499
|
+
k.setId(_convert_id_to_sbml(id_=name, prefix="PAR"))
|
500
500
|
k.setConstant(True)
|
501
|
-
|
501
|
+
|
502
|
+
if isinstance((init := value.value), InitialAssignment):
|
503
|
+
ar = sbml_model.createInitialAssignment()
|
504
|
+
ar.setId(_convert_id_to_sbml(id_=name, prefix="IA"))
|
505
|
+
ar.setName(_convert_id_to_sbml(id_=name, prefix="IA"))
|
506
|
+
ar.setVariable(_convert_id_to_sbml(id_=name, prefix="IA"))
|
507
|
+
ar.setMath(_sbmlify_fn(init.fn, init.args))
|
508
|
+
else:
|
509
|
+
k.setValue(float(init))
|
502
510
|
|
503
511
|
|
504
512
|
def _create_sbml_derived_parameters(*, model: Model, sbml_model: libsbml.Model) -> None:
|