hybrax 0.1.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.
- hybrax/__init__.py +5 -0
- hybrax/format/__init__.py +160 -0
- hybrax/format/_logging.py +18 -0
- hybrax/format/dataclasses.py +599 -0
- hybrax/format/inspect.py +1428 -0
- hybrax/format/json_io.py +154 -0
- hybrax/format/mechanistic.py +1051 -0
- hybrax/format/monotone_spline.py +648 -0
- hybrax/format/serialization.py +993 -0
- hybrax/format/simulation.py +384 -0
- hybrax/format/splines.py +1853 -0
- hybrax/format/time_series/__init__.py +6 -0
- hybrax/format/time_series/constants.py +11 -0
- hybrax/format/time_series/grid_utils.py +74 -0
- hybrax/format/time_series/io.py +49 -0
- hybrax/format/time_series/ppoly.py +120 -0
- hybrax/format/time_series/spline_ops.py +260 -0
- hybrax/format/time_series/timeseries.py +660 -0
- hybrax/format/validate.py +1383 -0
- hybrax/train/__init__.py +277 -0
- hybrax/train/augmentation.py +457 -0
- hybrax/train/augmentation_plot.py +155 -0
- hybrax/train/bounds_loss.py +244 -0
- hybrax/train/checkpointing.py +245 -0
- hybrax/train/cli.py +1312 -0
- hybrax/train/constants.py +10 -0
- hybrax/train/controls.py +490 -0
- hybrax/train/controls_store.py +1431 -0
- hybrax/train/defaults.py +684 -0
- hybrax/train/dense.py +141 -0
- hybrax/train/diffrax_callbacks/README.md +345 -0
- hybrax/train/diffrax_callbacks/__init__.py +26 -0
- hybrax/train/diffrax_callbacks/_callbacks.py +392 -0
- hybrax/train/diffrax_callbacks/_solution.py +124 -0
- hybrax/train/diffrax_callbacks/_solve.py +883 -0
- hybrax/train/diffrax_callbacks/examples/01_basic_fed_batch.py +164 -0
- hybrax/train/diffrax_callbacks/examples/02_multiple_callbacks.py +153 -0
- hybrax/train/diffrax_callbacks/examples/03_hybrid_node_control.py +362 -0
- hybrax/train/forward_plotting.py +367 -0
- hybrax/train/harness.py +2731 -0
- hybrax/train/inspect.py +424 -0
- hybrax/train/logging.py +416 -0
- hybrax/train/loo.py +1423 -0
- hybrax/train/loo_metrics.py +1045 -0
- hybrax/train/model_api.py +1157 -0
- hybrax/train/physical_solve.py +421 -0
- hybrax/train/postprocessing.py +743 -0
- hybrax/train/preflight.py +171 -0
- hybrax/train/prepare.py +599 -0
- hybrax/train/run_config.py +802 -0
- hybrax/train/runtime_artifact.py +1614 -0
- hybrax/train/runtime_context.py +534 -0
- hybrax/train/serialization.py +658 -0
- hybrax/train/trainer.py +717 -0
- hybrax/train/training_data.py +920 -0
- hybrax/train/utils.py +97 -0
- hybrax/train/validate.py +330 -0
- hybrax/train/wrapper.py +645 -0
- hybrax-0.1.0.dist-info/METADATA +132 -0
- hybrax-0.1.0.dist-info/RECORD +64 -0
- hybrax-0.1.0.dist-info/WHEEL +5 -0
- hybrax-0.1.0.dist-info/entry_points.txt +2 -0
- hybrax-0.1.0.dist-info/licenses/LICENSE +21 -0
- hybrax-0.1.0.dist-info/top_level.txt +1 -0
hybrax/__init__.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"""Bioprocess data structures, validation, serialization, and mechanistic modeling."""
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
from typing import TYPE_CHECKING, Any
|
|
7
|
+
|
|
8
|
+
# hybrax.format requires float64 throughout. Configure future JAX imports without
|
|
9
|
+
# importing JAX just to initialize this package.
|
|
10
|
+
os.environ["JAX_ENABLE_X64"] = "true"
|
|
11
|
+
if "jax" in sys.modules:
|
|
12
|
+
importlib.import_module("jax").config.update("jax_enable_x64", True)
|
|
13
|
+
|
|
14
|
+
from hybrax import __version__
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from . import mechanistic, serialization, splines, validate # noqa: F401
|
|
18
|
+
from .dataclasses import ( # noqa: F401
|
|
19
|
+
AugmentedBioProcess,
|
|
20
|
+
BioProcess,
|
|
21
|
+
BioProcessCollection,
|
|
22
|
+
BioProcessMetadata,
|
|
23
|
+
Bounds,
|
|
24
|
+
DiscreteEvents,
|
|
25
|
+
FeedMedium,
|
|
26
|
+
FeedMediumComponent,
|
|
27
|
+
Inflow,
|
|
28
|
+
Outflow,
|
|
29
|
+
ProcessOrdering,
|
|
30
|
+
ProcessVariable,
|
|
31
|
+
PseudobatchTransform,
|
|
32
|
+
ReactionOde,
|
|
33
|
+
ReactorMedium,
|
|
34
|
+
ReactorMediumComponent,
|
|
35
|
+
StaticVariable,
|
|
36
|
+
TimeAxis,
|
|
37
|
+
TimeSeries,
|
|
38
|
+
Volume,
|
|
39
|
+
VolumeChange,
|
|
40
|
+
silence_assumptions,
|
|
41
|
+
)
|
|
42
|
+
from .inspect import ( # noqa: F401
|
|
43
|
+
plot_collection,
|
|
44
|
+
plot_process,
|
|
45
|
+
print_collection_structure,
|
|
46
|
+
print_process_structure,
|
|
47
|
+
print_rhs_ode,
|
|
48
|
+
)
|
|
49
|
+
from .simulation import Simulation, SimulationEvent, SimulationResult # noqa: F401
|
|
50
|
+
from .validate import ( # noqa: F401
|
|
51
|
+
validate_augmented_parent_refs,
|
|
52
|
+
validate_biomass_in_reactor_medium,
|
|
53
|
+
validate_bounds,
|
|
54
|
+
validate_bounds_against_data,
|
|
55
|
+
validate_cross_process_consistency,
|
|
56
|
+
validate_discrete_events,
|
|
57
|
+
validate_for_publication,
|
|
58
|
+
validate_initial_state_alignment,
|
|
59
|
+
validate_measurement_sampling_alignment,
|
|
60
|
+
validate_outflow_retention,
|
|
61
|
+
validate_process,
|
|
62
|
+
validate_reaction_ode,
|
|
63
|
+
validate_reaction_ode_equivalence,
|
|
64
|
+
validate_time_axis,
|
|
65
|
+
validate_timeseries_shape,
|
|
66
|
+
validate_timestamp_bounds,
|
|
67
|
+
validate_volume_change_sign,
|
|
68
|
+
validate_volume_change_states,
|
|
69
|
+
validate_volume_consistency,
|
|
70
|
+
validate_volume_units,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
_EXPORT_MODULES = {
|
|
74
|
+
".dataclasses": (
|
|
75
|
+
"TimeAxis",
|
|
76
|
+
"DiscreteEvents",
|
|
77
|
+
"TimeSeries",
|
|
78
|
+
"StaticVariable",
|
|
79
|
+
"BioProcessMetadata",
|
|
80
|
+
"ProcessVariable",
|
|
81
|
+
"FeedMediumComponent",
|
|
82
|
+
"ReactorMediumComponent",
|
|
83
|
+
"VolumeChange",
|
|
84
|
+
"Inflow",
|
|
85
|
+
"Outflow",
|
|
86
|
+
"Volume",
|
|
87
|
+
"FeedMedium",
|
|
88
|
+
"ReactorMedium",
|
|
89
|
+
"Bounds",
|
|
90
|
+
"ReactionOde",
|
|
91
|
+
"ProcessOrdering",
|
|
92
|
+
"PseudobatchTransform",
|
|
93
|
+
"BioProcess",
|
|
94
|
+
"AugmentedBioProcess",
|
|
95
|
+
"BioProcessCollection",
|
|
96
|
+
"silence_assumptions",
|
|
97
|
+
),
|
|
98
|
+
".simulation": ("Simulation", "SimulationEvent", "SimulationResult"),
|
|
99
|
+
".inspect": (
|
|
100
|
+
"print_process_structure",
|
|
101
|
+
"print_collection_structure",
|
|
102
|
+
"print_rhs_ode",
|
|
103
|
+
"plot_process",
|
|
104
|
+
"plot_collection",
|
|
105
|
+
),
|
|
106
|
+
".validate": (
|
|
107
|
+
"validate_time_axis",
|
|
108
|
+
"validate_timeseries_shape",
|
|
109
|
+
"validate_discrete_events",
|
|
110
|
+
"validate_timestamp_bounds",
|
|
111
|
+
"validate_volume_change_sign",
|
|
112
|
+
"validate_volume_change_states",
|
|
113
|
+
"validate_volume_units",
|
|
114
|
+
"validate_outflow_retention",
|
|
115
|
+
"validate_biomass_in_reactor_medium",
|
|
116
|
+
"validate_initial_state_alignment",
|
|
117
|
+
"validate_measurement_sampling_alignment",
|
|
118
|
+
"validate_process",
|
|
119
|
+
"validate_volume_consistency",
|
|
120
|
+
"validate_for_publication",
|
|
121
|
+
"validate_augmented_parent_refs",
|
|
122
|
+
"validate_reaction_ode",
|
|
123
|
+
"validate_reaction_ode_equivalence",
|
|
124
|
+
"validate_bounds",
|
|
125
|
+
"validate_bounds_against_data",
|
|
126
|
+
"validate_cross_process_consistency",
|
|
127
|
+
),
|
|
128
|
+
}
|
|
129
|
+
_EXPORTS = {
|
|
130
|
+
name: module_name
|
|
131
|
+
for module_name, names in _EXPORT_MODULES.items()
|
|
132
|
+
for name in names
|
|
133
|
+
}
|
|
134
|
+
_EXPORTS.update(
|
|
135
|
+
{
|
|
136
|
+
"serialization": ".serialization",
|
|
137
|
+
"validate": ".validate",
|
|
138
|
+
"mechanistic": ".mechanistic",
|
|
139
|
+
"splines": ".splines",
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
# Ruff cannot infer that unpacking _EXPORTS yields only string keys.
|
|
144
|
+
__all__ = ["__version__", *_EXPORTS] # noqa: PLE0604
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def __getattr__(name: str) -> Any:
|
|
148
|
+
"""Load public objects only when accessed."""
|
|
149
|
+
module_name = _EXPORTS.get(name)
|
|
150
|
+
if module_name is None:
|
|
151
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
152
|
+
module = importlib.import_module(module_name, __name__)
|
|
153
|
+
value = module if name == module_name.removeprefix(".") else getattr(module, name)
|
|
154
|
+
globals()[name] = value
|
|
155
|
+
return value
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def __dir__() -> list[str]:
|
|
159
|
+
"""Include lazy exports in interactive discovery."""
|
|
160
|
+
return sorted(set(globals()) | set(__all__))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Shared logging setup for hybrax.format."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_logger(name: str) -> logging.Logger:
|
|
7
|
+
"""Return a logger under the ``hybrax.format`` namespace.
|
|
8
|
+
|
|
9
|
+
Library code must never call ``logging.basicConfig()`` or set a shared
|
|
10
|
+
logger's level — that decision belongs solely to the hosting application.
|
|
11
|
+
A ``NullHandler`` is attached once so that, absent app-level logging
|
|
12
|
+
configuration, records are silently discarded instead of falling through
|
|
13
|
+
to ``logging.lastResort``.
|
|
14
|
+
"""
|
|
15
|
+
top = logging.getLogger("hybrax.format")
|
|
16
|
+
if not top.handlers:
|
|
17
|
+
top.addHandler(logging.NullHandler())
|
|
18
|
+
return logging.getLogger(name)
|