tnfr 4.5.2__py3-none-any.whl → 8.5.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.
Potentially problematic release.
This version of tnfr might be problematic. Click here for more details.
- tnfr/__init__.py +334 -50
- tnfr/__init__.pyi +33 -0
- tnfr/_compat.py +10 -0
- tnfr/_generated_version.py +34 -0
- tnfr/_version.py +49 -0
- tnfr/_version.pyi +7 -0
- tnfr/alias.py +214 -37
- tnfr/alias.pyi +108 -0
- tnfr/backends/__init__.py +354 -0
- tnfr/backends/jax_backend.py +173 -0
- tnfr/backends/numpy_backend.py +238 -0
- tnfr/backends/optimized_numpy.py +420 -0
- tnfr/backends/torch_backend.py +408 -0
- tnfr/cache.py +149 -556
- tnfr/cache.pyi +13 -0
- tnfr/cli/__init__.py +51 -16
- tnfr/cli/__init__.pyi +26 -0
- tnfr/cli/arguments.py +344 -32
- tnfr/cli/arguments.pyi +29 -0
- tnfr/cli/execution.py +676 -50
- tnfr/cli/execution.pyi +70 -0
- tnfr/cli/interactive_validator.py +614 -0
- tnfr/cli/utils.py +18 -3
- tnfr/cli/utils.pyi +7 -0
- tnfr/cli/validate.py +236 -0
- tnfr/compat/__init__.py +85 -0
- tnfr/compat/dataclass.py +136 -0
- tnfr/compat/jsonschema_stub.py +61 -0
- tnfr/compat/matplotlib_stub.py +73 -0
- tnfr/compat/numpy_stub.py +155 -0
- tnfr/config/__init__.py +224 -0
- tnfr/config/__init__.pyi +10 -0
- tnfr/{constants_glyphs.py → config/constants.py} +26 -20
- tnfr/config/constants.pyi +12 -0
- tnfr/config/defaults.py +54 -0
- tnfr/{constants/core.py → config/defaults_core.py} +59 -6
- tnfr/config/defaults_init.py +33 -0
- tnfr/config/defaults_metric.py +104 -0
- tnfr/config/feature_flags.py +81 -0
- tnfr/config/feature_flags.pyi +16 -0
- tnfr/config/glyph_constants.py +31 -0
- tnfr/config/init.py +77 -0
- tnfr/config/init.pyi +8 -0
- tnfr/config/operator_names.py +254 -0
- tnfr/config/operator_names.pyi +36 -0
- tnfr/config/physics_derivation.py +354 -0
- tnfr/config/presets.py +83 -0
- tnfr/config/presets.pyi +7 -0
- tnfr/config/security.py +927 -0
- tnfr/config/thresholds.py +114 -0
- tnfr/config/tnfr_config.py +498 -0
- tnfr/constants/__init__.py +51 -133
- tnfr/constants/__init__.pyi +92 -0
- tnfr/constants/aliases.py +33 -0
- tnfr/constants/aliases.pyi +27 -0
- tnfr/constants/init.py +3 -1
- tnfr/constants/init.pyi +12 -0
- tnfr/constants/metric.py +9 -15
- tnfr/constants/metric.pyi +19 -0
- tnfr/core/__init__.py +33 -0
- tnfr/core/container.py +226 -0
- tnfr/core/default_implementations.py +329 -0
- tnfr/core/interfaces.py +279 -0
- tnfr/dynamics/__init__.py +213 -633
- tnfr/dynamics/__init__.pyi +83 -0
- tnfr/dynamics/adaptation.py +267 -0
- tnfr/dynamics/adaptation.pyi +7 -0
- tnfr/dynamics/adaptive_sequences.py +189 -0
- tnfr/dynamics/adaptive_sequences.pyi +14 -0
- tnfr/dynamics/aliases.py +23 -0
- tnfr/dynamics/aliases.pyi +19 -0
- tnfr/dynamics/bifurcation.py +232 -0
- tnfr/dynamics/canonical.py +229 -0
- tnfr/dynamics/canonical.pyi +48 -0
- tnfr/dynamics/coordination.py +385 -0
- tnfr/dynamics/coordination.pyi +25 -0
- tnfr/dynamics/dnfr.py +2699 -398
- tnfr/dynamics/dnfr.pyi +26 -0
- tnfr/dynamics/dynamic_limits.py +225 -0
- tnfr/dynamics/feedback.py +252 -0
- tnfr/dynamics/feedback.pyi +24 -0
- tnfr/dynamics/fused_dnfr.py +454 -0
- tnfr/dynamics/homeostasis.py +157 -0
- tnfr/dynamics/homeostasis.pyi +14 -0
- tnfr/dynamics/integrators.py +496 -102
- tnfr/dynamics/integrators.pyi +36 -0
- tnfr/dynamics/learning.py +310 -0
- tnfr/dynamics/learning.pyi +33 -0
- tnfr/dynamics/metabolism.py +254 -0
- tnfr/dynamics/nbody.py +796 -0
- tnfr/dynamics/nbody_tnfr.py +783 -0
- tnfr/dynamics/propagation.py +326 -0
- tnfr/dynamics/runtime.py +908 -0
- tnfr/dynamics/runtime.pyi +77 -0
- tnfr/dynamics/sampling.py +10 -5
- tnfr/dynamics/sampling.pyi +7 -0
- tnfr/dynamics/selectors.py +711 -0
- tnfr/dynamics/selectors.pyi +85 -0
- tnfr/dynamics/structural_clip.py +207 -0
- tnfr/errors/__init__.py +37 -0
- tnfr/errors/contextual.py +492 -0
- tnfr/execution.py +77 -55
- tnfr/execution.pyi +45 -0
- tnfr/extensions/__init__.py +205 -0
- tnfr/extensions/__init__.pyi +18 -0
- tnfr/extensions/base.py +173 -0
- tnfr/extensions/base.pyi +35 -0
- tnfr/extensions/business/__init__.py +71 -0
- tnfr/extensions/business/__init__.pyi +11 -0
- tnfr/extensions/business/cookbook.py +88 -0
- tnfr/extensions/business/cookbook.pyi +8 -0
- tnfr/extensions/business/health_analyzers.py +202 -0
- tnfr/extensions/business/health_analyzers.pyi +9 -0
- tnfr/extensions/business/patterns.py +183 -0
- tnfr/extensions/business/patterns.pyi +8 -0
- tnfr/extensions/medical/__init__.py +73 -0
- tnfr/extensions/medical/__init__.pyi +11 -0
- tnfr/extensions/medical/cookbook.py +88 -0
- tnfr/extensions/medical/cookbook.pyi +8 -0
- tnfr/extensions/medical/health_analyzers.py +181 -0
- tnfr/extensions/medical/health_analyzers.pyi +9 -0
- tnfr/extensions/medical/patterns.py +163 -0
- tnfr/extensions/medical/patterns.pyi +8 -0
- tnfr/flatten.py +29 -50
- tnfr/flatten.pyi +21 -0
- tnfr/gamma.py +66 -53
- tnfr/gamma.pyi +36 -0
- tnfr/glyph_history.py +144 -57
- tnfr/glyph_history.pyi +35 -0
- tnfr/glyph_runtime.py +19 -0
- tnfr/glyph_runtime.pyi +8 -0
- tnfr/immutable.py +70 -30
- tnfr/immutable.pyi +36 -0
- tnfr/initialization.py +22 -16
- tnfr/initialization.pyi +65 -0
- tnfr/io.py +5 -241
- tnfr/io.pyi +13 -0
- tnfr/locking.pyi +7 -0
- tnfr/mathematics/__init__.py +79 -0
- tnfr/mathematics/backend.py +453 -0
- tnfr/mathematics/backend.pyi +99 -0
- tnfr/mathematics/dynamics.py +408 -0
- tnfr/mathematics/dynamics.pyi +90 -0
- tnfr/mathematics/epi.py +391 -0
- tnfr/mathematics/epi.pyi +65 -0
- tnfr/mathematics/generators.py +242 -0
- tnfr/mathematics/generators.pyi +29 -0
- tnfr/mathematics/metrics.py +119 -0
- tnfr/mathematics/metrics.pyi +16 -0
- tnfr/mathematics/operators.py +239 -0
- tnfr/mathematics/operators.pyi +59 -0
- tnfr/mathematics/operators_factory.py +124 -0
- tnfr/mathematics/operators_factory.pyi +11 -0
- tnfr/mathematics/projection.py +87 -0
- tnfr/mathematics/projection.pyi +33 -0
- tnfr/mathematics/runtime.py +182 -0
- tnfr/mathematics/runtime.pyi +64 -0
- tnfr/mathematics/spaces.py +256 -0
- tnfr/mathematics/spaces.pyi +83 -0
- tnfr/mathematics/transforms.py +305 -0
- tnfr/mathematics/transforms.pyi +62 -0
- tnfr/metrics/__init__.py +47 -9
- tnfr/metrics/__init__.pyi +20 -0
- tnfr/metrics/buffer_cache.py +163 -0
- tnfr/metrics/buffer_cache.pyi +24 -0
- tnfr/metrics/cache_utils.py +214 -0
- tnfr/metrics/coherence.py +1510 -330
- tnfr/metrics/coherence.pyi +129 -0
- tnfr/metrics/common.py +23 -16
- tnfr/metrics/common.pyi +35 -0
- tnfr/metrics/core.py +251 -36
- tnfr/metrics/core.pyi +13 -0
- tnfr/metrics/diagnosis.py +709 -110
- tnfr/metrics/diagnosis.pyi +86 -0
- tnfr/metrics/emergence.py +245 -0
- tnfr/metrics/export.py +60 -18
- tnfr/metrics/export.pyi +7 -0
- tnfr/metrics/glyph_timing.py +233 -43
- tnfr/metrics/glyph_timing.pyi +81 -0
- tnfr/metrics/learning_metrics.py +280 -0
- tnfr/metrics/learning_metrics.pyi +21 -0
- tnfr/metrics/phase_coherence.py +351 -0
- tnfr/metrics/phase_compatibility.py +349 -0
- tnfr/metrics/reporting.py +63 -28
- tnfr/metrics/reporting.pyi +25 -0
- tnfr/metrics/sense_index.py +1126 -43
- tnfr/metrics/sense_index.pyi +9 -0
- tnfr/metrics/trig.py +215 -23
- tnfr/metrics/trig.pyi +13 -0
- tnfr/metrics/trig_cache.py +148 -24
- tnfr/metrics/trig_cache.pyi +10 -0
- tnfr/multiscale/__init__.py +32 -0
- tnfr/multiscale/hierarchical.py +517 -0
- tnfr/node.py +646 -140
- tnfr/node.pyi +139 -0
- tnfr/observers.py +160 -45
- tnfr/observers.pyi +31 -0
- tnfr/ontosim.py +23 -19
- tnfr/ontosim.pyi +28 -0
- tnfr/operators/__init__.py +1358 -106
- tnfr/operators/__init__.pyi +31 -0
- tnfr/operators/algebra.py +277 -0
- tnfr/operators/canonical_patterns.py +420 -0
- tnfr/operators/cascade.py +267 -0
- tnfr/operators/cycle_detection.py +358 -0
- tnfr/operators/definitions.py +4108 -0
- tnfr/operators/definitions.pyi +78 -0
- tnfr/operators/grammar.py +1164 -0
- tnfr/operators/grammar.pyi +140 -0
- tnfr/operators/hamiltonian.py +710 -0
- tnfr/operators/health_analyzer.py +809 -0
- tnfr/operators/jitter.py +107 -38
- tnfr/operators/jitter.pyi +11 -0
- tnfr/operators/lifecycle.py +314 -0
- tnfr/operators/metabolism.py +618 -0
- tnfr/operators/metrics.py +2138 -0
- tnfr/operators/network_analysis/__init__.py +27 -0
- tnfr/operators/network_analysis/source_detection.py +186 -0
- tnfr/operators/nodal_equation.py +395 -0
- tnfr/operators/pattern_detection.py +660 -0
- tnfr/operators/patterns.py +669 -0
- tnfr/operators/postconditions/__init__.py +38 -0
- tnfr/operators/postconditions/mutation.py +236 -0
- tnfr/operators/preconditions/__init__.py +1226 -0
- tnfr/operators/preconditions/coherence.py +305 -0
- tnfr/operators/preconditions/dissonance.py +236 -0
- tnfr/operators/preconditions/emission.py +128 -0
- tnfr/operators/preconditions/mutation.py +580 -0
- tnfr/operators/preconditions/reception.py +125 -0
- tnfr/operators/preconditions/resonance.py +364 -0
- tnfr/operators/registry.py +74 -0
- tnfr/operators/registry.pyi +9 -0
- tnfr/operators/remesh.py +1415 -91
- tnfr/operators/remesh.pyi +26 -0
- tnfr/operators/structural_units.py +268 -0
- tnfr/operators/unified_grammar.py +105 -0
- tnfr/parallel/__init__.py +54 -0
- tnfr/parallel/auto_scaler.py +234 -0
- tnfr/parallel/distributed.py +384 -0
- tnfr/parallel/engine.py +238 -0
- tnfr/parallel/gpu_engine.py +420 -0
- tnfr/parallel/monitoring.py +248 -0
- tnfr/parallel/partitioner.py +459 -0
- tnfr/py.typed +0 -0
- tnfr/recipes/__init__.py +22 -0
- tnfr/recipes/cookbook.py +743 -0
- tnfr/rng.py +75 -151
- tnfr/rng.pyi +26 -0
- tnfr/schemas/__init__.py +8 -0
- tnfr/schemas/grammar.json +94 -0
- tnfr/sdk/__init__.py +107 -0
- tnfr/sdk/__init__.pyi +19 -0
- tnfr/sdk/adaptive_system.py +173 -0
- tnfr/sdk/adaptive_system.pyi +21 -0
- tnfr/sdk/builders.py +370 -0
- tnfr/sdk/builders.pyi +51 -0
- tnfr/sdk/fluent.py +1121 -0
- tnfr/sdk/fluent.pyi +74 -0
- tnfr/sdk/templates.py +342 -0
- tnfr/sdk/templates.pyi +41 -0
- tnfr/sdk/utils.py +341 -0
- tnfr/secure_config.py +46 -0
- tnfr/security/__init__.py +70 -0
- tnfr/security/database.py +514 -0
- tnfr/security/subprocess.py +503 -0
- tnfr/security/validation.py +290 -0
- tnfr/selector.py +59 -22
- tnfr/selector.pyi +19 -0
- tnfr/sense.py +92 -67
- tnfr/sense.pyi +23 -0
- tnfr/services/__init__.py +17 -0
- tnfr/services/orchestrator.py +325 -0
- tnfr/sparse/__init__.py +39 -0
- tnfr/sparse/representations.py +492 -0
- tnfr/structural.py +639 -263
- tnfr/structural.pyi +83 -0
- tnfr/telemetry/__init__.py +35 -0
- tnfr/telemetry/cache_metrics.py +226 -0
- tnfr/telemetry/cache_metrics.pyi +64 -0
- tnfr/telemetry/nu_f.py +422 -0
- tnfr/telemetry/nu_f.pyi +108 -0
- tnfr/telemetry/verbosity.py +36 -0
- tnfr/telemetry/verbosity.pyi +15 -0
- tnfr/tokens.py +2 -4
- tnfr/tokens.pyi +36 -0
- tnfr/tools/__init__.py +20 -0
- tnfr/tools/domain_templates.py +478 -0
- tnfr/tools/sequence_generator.py +846 -0
- tnfr/topology/__init__.py +13 -0
- tnfr/topology/asymmetry.py +151 -0
- tnfr/trace.py +300 -126
- tnfr/trace.pyi +42 -0
- tnfr/tutorials/__init__.py +38 -0
- tnfr/tutorials/autonomous_evolution.py +285 -0
- tnfr/tutorials/interactive.py +1576 -0
- tnfr/tutorials/structural_metabolism.py +238 -0
- tnfr/types.py +743 -12
- tnfr/types.pyi +357 -0
- tnfr/units.py +68 -0
- tnfr/units.pyi +13 -0
- tnfr/utils/__init__.py +282 -0
- tnfr/utils/__init__.pyi +215 -0
- tnfr/utils/cache.py +4223 -0
- tnfr/utils/cache.pyi +470 -0
- tnfr/{callback_utils.py → utils/callbacks.py} +26 -39
- tnfr/utils/callbacks.pyi +49 -0
- tnfr/utils/chunks.py +108 -0
- tnfr/utils/chunks.pyi +22 -0
- tnfr/utils/data.py +428 -0
- tnfr/utils/data.pyi +74 -0
- tnfr/utils/graph.py +85 -0
- tnfr/utils/graph.pyi +10 -0
- tnfr/utils/init.py +821 -0
- tnfr/utils/init.pyi +80 -0
- tnfr/utils/io.py +559 -0
- tnfr/utils/io.pyi +66 -0
- tnfr/{helpers → utils}/numeric.py +51 -24
- tnfr/utils/numeric.pyi +21 -0
- tnfr/validation/__init__.py +257 -0
- tnfr/validation/__init__.pyi +85 -0
- tnfr/validation/compatibility.py +460 -0
- tnfr/validation/compatibility.pyi +6 -0
- tnfr/validation/config.py +73 -0
- tnfr/validation/graph.py +139 -0
- tnfr/validation/graph.pyi +18 -0
- tnfr/validation/input_validation.py +755 -0
- tnfr/validation/invariants.py +712 -0
- tnfr/validation/rules.py +253 -0
- tnfr/validation/rules.pyi +44 -0
- tnfr/validation/runtime.py +279 -0
- tnfr/validation/runtime.pyi +28 -0
- tnfr/validation/sequence_validator.py +162 -0
- tnfr/validation/soft_filters.py +170 -0
- tnfr/validation/soft_filters.pyi +32 -0
- tnfr/validation/spectral.py +164 -0
- tnfr/validation/spectral.pyi +42 -0
- tnfr/validation/validator.py +1266 -0
- tnfr/validation/window.py +39 -0
- tnfr/validation/window.pyi +1 -0
- tnfr/visualization/__init__.py +98 -0
- tnfr/visualization/cascade_viz.py +256 -0
- tnfr/visualization/hierarchy.py +284 -0
- tnfr/visualization/sequence_plotter.py +784 -0
- tnfr/viz/__init__.py +60 -0
- tnfr/viz/matplotlib.py +278 -0
- tnfr/viz/matplotlib.pyi +35 -0
- tnfr-8.5.0.dist-info/METADATA +573 -0
- tnfr-8.5.0.dist-info/RECORD +353 -0
- {tnfr-4.5.2.dist-info → tnfr-8.5.0.dist-info}/entry_points.txt +1 -0
- {tnfr-4.5.2.dist-info → tnfr-8.5.0.dist-info}/licenses/LICENSE.md +1 -1
- tnfr/collections_utils.py +0 -300
- tnfr/config.py +0 -32
- tnfr/grammar.py +0 -344
- tnfr/graph_utils.py +0 -84
- tnfr/helpers/__init__.py +0 -71
- tnfr/import_utils.py +0 -228
- tnfr/json_utils.py +0 -162
- tnfr/logging_utils.py +0 -116
- tnfr/presets.py +0 -60
- tnfr/validators.py +0 -84
- tnfr/value_utils.py +0 -59
- tnfr-4.5.2.dist-info/METADATA +0 -379
- tnfr-4.5.2.dist-info/RECORD +0 -67
- {tnfr-4.5.2.dist-info → tnfr-8.5.0.dist-info}/WHEEL +0 -0
- {tnfr-4.5.2.dist-info → tnfr-8.5.0.dist-info}/top_level.txt +0 -0
tnfr/cache.pyi
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Compatibility stub removed; import from :mod:`tnfr.utils.cache` instead."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import NoReturn
|
|
6
|
+
|
|
7
|
+
__all__ = ()
|
|
8
|
+
|
|
9
|
+
def __getattr__(name: str) -> NoReturn:
|
|
10
|
+
"""Indicate that :mod:`tnfr.cache` no longer exports cache helpers."""
|
|
11
|
+
|
|
12
|
+
def __dir__() -> tuple[str, ...]:
|
|
13
|
+
"""Return an empty set of exports to mirror the removed shim."""
|
tnfr/cli/__init__.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Command-line interface entry points for TNFR."""
|
|
2
|
+
|
|
1
3
|
from __future__ import annotations
|
|
2
4
|
|
|
3
5
|
import argparse
|
|
@@ -5,25 +7,29 @@ import logging
|
|
|
5
7
|
import sys
|
|
6
8
|
from typing import Optional
|
|
7
9
|
|
|
10
|
+
from .. import __version__
|
|
11
|
+
from ..utils import _configure_root, get_logger
|
|
8
12
|
from .arguments import (
|
|
13
|
+
_add_epi_validate_parser,
|
|
14
|
+
_add_math_run_parser,
|
|
15
|
+
_add_metrics_parser,
|
|
16
|
+
_add_profile_parser,
|
|
17
|
+
_add_profile_pipeline_parser,
|
|
18
|
+
_add_run_parser,
|
|
19
|
+
_add_sequence_parser,
|
|
20
|
+
add_canon_toggle,
|
|
9
21
|
add_common_args,
|
|
10
22
|
add_grammar_args,
|
|
11
23
|
add_grammar_selector_args,
|
|
12
24
|
add_history_export_args,
|
|
13
|
-
add_canon_toggle,
|
|
14
|
-
_add_run_parser,
|
|
15
|
-
_add_sequence_parser,
|
|
16
|
-
_add_metrics_parser,
|
|
17
25
|
)
|
|
18
26
|
from .execution import (
|
|
19
|
-
build_basic_graph,
|
|
20
27
|
apply_cli_config,
|
|
28
|
+
build_basic_graph,
|
|
21
29
|
register_callbacks_and_observer,
|
|
22
|
-
run_program,
|
|
23
30
|
resolve_program,
|
|
31
|
+
run_program,
|
|
24
32
|
)
|
|
25
|
-
from ..logging_utils import get_logger
|
|
26
|
-
from .. import __version__
|
|
27
33
|
|
|
28
34
|
logger = get_logger(__name__)
|
|
29
35
|
|
|
@@ -43,27 +49,56 @@ __all__ = (
|
|
|
43
49
|
|
|
44
50
|
|
|
45
51
|
def main(argv: Optional[list[str]] = None) -> int:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)
|
|
52
|
+
"""Entry point for the ``tnfr`` CLI returning the exit status."""
|
|
53
|
+
|
|
54
|
+
_configure_root()
|
|
55
|
+
|
|
56
|
+
root = logging.getLogger()
|
|
57
|
+
root.setLevel(logging.INFO)
|
|
58
|
+
|
|
59
|
+
formatter = logging.Formatter("%(message)s")
|
|
60
|
+
for handler in list(root.handlers):
|
|
61
|
+
root.removeHandler(handler)
|
|
62
|
+
|
|
63
|
+
handler = logging.StreamHandler(stream=sys.stdout)
|
|
64
|
+
handler.setLevel(logging.INFO)
|
|
65
|
+
handler.setFormatter(formatter)
|
|
66
|
+
root.addHandler(handler)
|
|
49
67
|
|
|
50
68
|
p = argparse.ArgumentParser(
|
|
51
69
|
prog="tnfr",
|
|
52
70
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
71
|
+
description="TNFR - Resonant Fractal Nature Theory computational engine",
|
|
53
72
|
epilog=(
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
73
|
+
"Common examples:\n"
|
|
74
|
+
" # Run a preset scenario\n"
|
|
75
|
+
" tnfr run --preset resonant_bootstrap --steps 100\n\n"
|
|
76
|
+
" # Run with math engine validation\n"
|
|
77
|
+
" tnfr math.run --nodes 24 --steps 50\n\n"
|
|
78
|
+
" # Validate EPI integrity\n"
|
|
79
|
+
" tnfr epi.validate --preset coupling_exploration\n\n"
|
|
80
|
+
" # Execute custom sequence from YAML\n"
|
|
81
|
+
" tnfr sequence --sequence-file presets/resonant_bootstrap.yaml\n\n"
|
|
82
|
+
" # Export metrics to JSON\n"
|
|
83
|
+
" tnfr metrics --save metrics.json --steps 200\n\n"
|
|
84
|
+
"For detailed help on any subcommand:\n"
|
|
85
|
+
" tnfr <subcommand> --help"
|
|
57
86
|
),
|
|
58
87
|
)
|
|
59
88
|
p.add_argument(
|
|
60
|
-
"--version",
|
|
89
|
+
"--version",
|
|
90
|
+
action="store_true",
|
|
91
|
+
help=("show the actual version and exit (reads pyproject.toml in development)"),
|
|
61
92
|
)
|
|
62
|
-
sub = p.add_subparsers(dest="cmd")
|
|
93
|
+
sub = p.add_subparsers(dest="cmd", help="Available subcommands")
|
|
63
94
|
|
|
64
95
|
_add_run_parser(sub)
|
|
96
|
+
_add_math_run_parser(sub)
|
|
97
|
+
_add_epi_validate_parser(sub)
|
|
65
98
|
_add_sequence_parser(sub)
|
|
66
99
|
_add_metrics_parser(sub)
|
|
100
|
+
_add_profile_parser(sub)
|
|
101
|
+
_add_profile_pipeline_parser(sub)
|
|
67
102
|
|
|
68
103
|
args = p.parse_args(argv)
|
|
69
104
|
if args.version:
|
tnfr/cli/__init__.pyi
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
from ..types import ProgramTokens, TNFRGraph
|
|
7
|
+
|
|
8
|
+
__all__: tuple[str, ...]
|
|
9
|
+
|
|
10
|
+
def main(argv: Optional[list[str]] = None) -> int: ...
|
|
11
|
+
def add_common_args(parser: argparse.ArgumentParser) -> None: ...
|
|
12
|
+
def add_grammar_args(parser: argparse.ArgumentParser) -> None: ...
|
|
13
|
+
def add_grammar_selector_args(parser: argparse.ArgumentParser) -> None: ...
|
|
14
|
+
def add_history_export_args(parser: argparse.ArgumentParser) -> None: ...
|
|
15
|
+
def add_canon_toggle(parser: argparse.ArgumentParser) -> None: ...
|
|
16
|
+
def build_basic_graph(args: argparse.Namespace) -> TNFRGraph: ...
|
|
17
|
+
def apply_cli_config(G: TNFRGraph, args: argparse.Namespace) -> None: ...
|
|
18
|
+
def register_callbacks_and_observer(G: TNFRGraph) -> None: ...
|
|
19
|
+
def resolve_program(
|
|
20
|
+
args: argparse.Namespace, default: Optional[ProgramTokens] = None
|
|
21
|
+
) -> Optional[ProgramTokens]: ...
|
|
22
|
+
def run_program(
|
|
23
|
+
G: Optional[TNFRGraph],
|
|
24
|
+
program: Optional[ProgramTokens],
|
|
25
|
+
args: argparse.Namespace,
|
|
26
|
+
) -> TNFRGraph: ...
|
tnfr/cli/arguments.py
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
"""Argument parser helpers shared across TNFR CLI commands."""
|
|
2
|
+
|
|
1
3
|
from __future__ import annotations
|
|
2
4
|
|
|
3
5
|
import argparse
|
|
4
|
-
from
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any, Iterable
|
|
5
8
|
|
|
9
|
+
from ..config.presets import PREFERRED_PRESET_NAMES
|
|
6
10
|
from ..gamma import GAMMA_REGISTRY
|
|
11
|
+
from ..telemetry.verbosity import TELEMETRY_VERBOSITY_LEVELS
|
|
12
|
+
from ..types import ArgSpec
|
|
7
13
|
from .utils import spec
|
|
8
14
|
|
|
15
|
+
_PRESET_HELP = "Available presets: {}.".format(
|
|
16
|
+
", ".join(PREFERRED_PRESET_NAMES),
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
TELEMETRY_VERBOSITY_CHOICES = TELEMETRY_VERBOSITY_LEVELS
|
|
9
20
|
|
|
10
|
-
GRAMMAR_ARG_SPECS = (
|
|
21
|
+
GRAMMAR_ARG_SPECS: tuple[ArgSpec, ...] = (
|
|
11
22
|
spec("--grammar.enabled", action=argparse.BooleanOptionalAction),
|
|
12
23
|
spec("--grammar.zhir_requires_oz_window", type=int),
|
|
13
24
|
spec("--grammar.zhir_dnfr_min", type=float),
|
|
@@ -18,26 +29,34 @@ GRAMMAR_ARG_SPECS = (
|
|
|
18
29
|
spec("--glyph.hysteresis_window", type=int),
|
|
19
30
|
)
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
HISTORY_ARG_SPECS = (
|
|
32
|
+
# History export/save specifications
|
|
33
|
+
HISTORY_ARG_SPECS: tuple[ArgSpec, ...] = (
|
|
24
34
|
spec("--save-history", type=str),
|
|
25
35
|
spec("--export-history-base", type=str),
|
|
26
36
|
spec("--export-format", choices=["csv", "json"], default="json"),
|
|
27
37
|
)
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
COMMON_ARG_SPECS = (
|
|
39
|
+
# Arguments shared by CLI subcommands
|
|
40
|
+
COMMON_ARG_SPECS: tuple[ArgSpec, ...] = (
|
|
32
41
|
spec("--nodes", type=int, default=24),
|
|
33
42
|
spec("--topology", choices=["ring", "complete", "erdos"], default="ring"),
|
|
34
43
|
spec("--seed", type=int, default=1),
|
|
35
44
|
spec(
|
|
36
45
|
"--p",
|
|
37
46
|
type=float,
|
|
38
|
-
help="
|
|
47
|
+
help="Edge probability when topology=erdos",
|
|
48
|
+
),
|
|
49
|
+
spec("--observer", action="store_true", help="Attach standard observer"),
|
|
50
|
+
spec(
|
|
51
|
+
"--trace-verbosity",
|
|
52
|
+
choices=TELEMETRY_VERBOSITY_CHOICES,
|
|
53
|
+
help="Select the trace capture preset",
|
|
54
|
+
),
|
|
55
|
+
spec(
|
|
56
|
+
"--metrics-verbosity",
|
|
57
|
+
choices=TELEMETRY_VERBOSITY_CHOICES,
|
|
58
|
+
help="Select the metrics capture preset",
|
|
39
59
|
),
|
|
40
|
-
spec("--observer", action="store_true", help="Adjunta observador estándar"),
|
|
41
60
|
spec("--config", type=str),
|
|
42
61
|
spec("--dt", type=float),
|
|
43
62
|
spec("--integrator", choices=["euler", "rk4"]),
|
|
@@ -45,10 +64,13 @@ COMMON_ARG_SPECS = (
|
|
|
45
64
|
spec("--gamma-type", choices=list(GAMMA_REGISTRY.keys()), default="none"),
|
|
46
65
|
spec("--gamma-beta", type=float, default=0.0),
|
|
47
66
|
spec("--gamma-R0", type=float, default=0.0),
|
|
67
|
+
spec("--um-candidate-count", type=int),
|
|
68
|
+
spec("--stop-early-window", type=int),
|
|
69
|
+
spec("--stop-early-fraction", type=float),
|
|
48
70
|
)
|
|
49
71
|
|
|
50
72
|
|
|
51
|
-
def add_arg_specs(parser: argparse._ActionsContainer, specs) -> None:
|
|
73
|
+
def add_arg_specs(parser: argparse._ActionsContainer, specs: Iterable[ArgSpec]) -> None:
|
|
52
74
|
"""Register arguments from ``specs`` on ``parser``."""
|
|
53
75
|
for opt, kwargs in specs:
|
|
54
76
|
parser.add_argument(opt, **kwargs)
|
|
@@ -69,17 +91,15 @@ def add_common_args(parser: argparse.ArgumentParser) -> None:
|
|
|
69
91
|
|
|
70
92
|
|
|
71
93
|
def add_grammar_args(parser: argparse.ArgumentParser) -> None:
|
|
72
|
-
"""Add grammar and
|
|
94
|
+
"""Add grammar and structural operator hysteresis options."""
|
|
73
95
|
group = parser.add_argument_group("Grammar")
|
|
74
96
|
add_arg_specs(group, GRAMMAR_ARG_SPECS)
|
|
75
97
|
|
|
76
98
|
|
|
77
99
|
def add_grammar_selector_args(parser: argparse.ArgumentParser) -> None:
|
|
78
|
-
"""Add grammar options and
|
|
100
|
+
"""Add grammar options and structural operator selector."""
|
|
79
101
|
add_grammar_args(parser)
|
|
80
|
-
parser.add_argument(
|
|
81
|
-
"--selector", choices=["basic", "param"], default="basic"
|
|
82
|
-
)
|
|
102
|
+
parser.add_argument("--selector", choices=["basic", "param"], default="basic")
|
|
83
103
|
|
|
84
104
|
|
|
85
105
|
def add_history_export_args(parser: argparse.ArgumentParser) -> None:
|
|
@@ -94,26 +114,45 @@ def add_canon_toggle(parser: argparse.ArgumentParser) -> None:
|
|
|
94
114
|
dest="grammar_canon",
|
|
95
115
|
action="store_false",
|
|
96
116
|
default=True,
|
|
97
|
-
help="
|
|
117
|
+
help="Disable canonical grammar",
|
|
98
118
|
)
|
|
99
119
|
|
|
100
120
|
|
|
101
121
|
def _add_run_parser(sub: argparse._SubParsersAction) -> None:
|
|
102
122
|
"""Configure the ``run`` subcommand."""
|
|
103
|
-
|
|
123
|
+
|
|
124
|
+
from .execution import DEFAULT_SUMMARY_SERIES_LIMIT, cmd_run
|
|
104
125
|
|
|
105
126
|
p_run = sub.add_parser(
|
|
106
127
|
"run",
|
|
107
|
-
help=(
|
|
108
|
-
"Correr escenario libre o preset y opcionalmente exportar history"
|
|
109
|
-
),
|
|
128
|
+
help=("Run a free scenario or preset and optionally export history"),
|
|
110
129
|
)
|
|
111
130
|
add_common_args(p_run)
|
|
112
131
|
p_run.add_argument("--steps", type=int, default=100)
|
|
132
|
+
p_run.add_argument(
|
|
133
|
+
"--use-Si",
|
|
134
|
+
dest="use_Si",
|
|
135
|
+
action=argparse.BooleanOptionalAction,
|
|
136
|
+
default=None,
|
|
137
|
+
help="Recompute the Sense Index during the run (use --no-use-Si to disable)",
|
|
138
|
+
)
|
|
139
|
+
p_run.add_argument(
|
|
140
|
+
"--apply-glyphs",
|
|
141
|
+
dest="apply_glyphs",
|
|
142
|
+
action=argparse.BooleanOptionalAction,
|
|
143
|
+
default=None,
|
|
144
|
+
help="Apply structural operators at every step (use --no-apply-glyphs to disable)",
|
|
145
|
+
)
|
|
146
|
+
p_run.add_argument(
|
|
147
|
+
"--dnfr-n-jobs",
|
|
148
|
+
dest="dnfr_n_jobs",
|
|
149
|
+
type=int,
|
|
150
|
+
help="Override ΔNFR parallel jobs forwarded to the runtime",
|
|
151
|
+
)
|
|
113
152
|
add_canon_toggle(p_run)
|
|
114
153
|
add_grammar_selector_args(p_run)
|
|
115
154
|
add_history_export_args(p_run)
|
|
116
|
-
p_run.add_argument("--preset", type=str, default=None)
|
|
155
|
+
p_run.add_argument("--preset", type=str, default=None, help=_PRESET_HELP)
|
|
117
156
|
p_run.add_argument("--sequence-file", type=str, default=None)
|
|
118
157
|
p_run.add_argument("--summary", action="store_true")
|
|
119
158
|
p_run.add_argument(
|
|
@@ -121,10 +160,68 @@ def _add_run_parser(sub: argparse._SubParsersAction) -> None:
|
|
|
121
160
|
type=int,
|
|
122
161
|
default=DEFAULT_SUMMARY_SERIES_LIMIT,
|
|
123
162
|
help=(
|
|
124
|
-
"
|
|
125
|
-
"
|
|
163
|
+
"Maximum number of samples per series in the summary (<=0 to"
|
|
164
|
+
" disable trimming)"
|
|
165
|
+
),
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
math_group = p_run.add_argument_group("Mathematical dynamics")
|
|
169
|
+
math_group.add_argument(
|
|
170
|
+
"--math-engine",
|
|
171
|
+
action=argparse.BooleanOptionalAction,
|
|
172
|
+
default=False,
|
|
173
|
+
help=(
|
|
174
|
+
"Enable the spectral mathematical dynamics engine to project nodes"
|
|
175
|
+
" onto Hilbert space vectors and validate norm, coherence and"
|
|
176
|
+
" structural frequency invariants"
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
math_group.add_argument(
|
|
180
|
+
"--math-dimension",
|
|
181
|
+
type=int,
|
|
182
|
+
help="Hilbert space dimension to use when the math engine is enabled",
|
|
183
|
+
)
|
|
184
|
+
math_group.add_argument(
|
|
185
|
+
"--math-coherence-spectrum",
|
|
186
|
+
type=float,
|
|
187
|
+
nargs="+",
|
|
188
|
+
metavar="λ",
|
|
189
|
+
help=(
|
|
190
|
+
"Eigenvalues for the coherence operator (defaults to a flat"
|
|
191
|
+
" spectrum when omitted)"
|
|
192
|
+
),
|
|
193
|
+
)
|
|
194
|
+
math_group.add_argument(
|
|
195
|
+
"--math-coherence-c-min",
|
|
196
|
+
type=float,
|
|
197
|
+
help="Explicit coherence floor C_min for the operator",
|
|
198
|
+
)
|
|
199
|
+
math_group.add_argument(
|
|
200
|
+
"--math-coherence-threshold",
|
|
201
|
+
type=float,
|
|
202
|
+
help="Coherence expectation threshold enforced during validation",
|
|
203
|
+
)
|
|
204
|
+
math_group.add_argument(
|
|
205
|
+
"--math-frequency-diagonal",
|
|
206
|
+
type=float,
|
|
207
|
+
nargs="+",
|
|
208
|
+
metavar="ν",
|
|
209
|
+
help=(
|
|
210
|
+
"Diagonal entries for the structural frequency operator"
|
|
211
|
+
" (defaults to the identity spectrum)"
|
|
212
|
+
),
|
|
213
|
+
)
|
|
214
|
+
math_group.add_argument(
|
|
215
|
+
"--math-generator-diagonal",
|
|
216
|
+
type=float,
|
|
217
|
+
nargs="+",
|
|
218
|
+
metavar="ω",
|
|
219
|
+
help=(
|
|
220
|
+
"Diagonal ΔNFR generator used by the mathematical dynamics"
|
|
221
|
+
" engine (defaults to the null generator)"
|
|
126
222
|
),
|
|
127
223
|
)
|
|
224
|
+
|
|
128
225
|
p_run.set_defaults(func=cmd_run)
|
|
129
226
|
|
|
130
227
|
|
|
@@ -134,10 +231,10 @@ def _add_sequence_parser(sub: argparse._SubParsersAction) -> None:
|
|
|
134
231
|
|
|
135
232
|
p_seq = sub.add_parser(
|
|
136
233
|
"sequence",
|
|
137
|
-
help="
|
|
234
|
+
help="Execute a sequence (preset or YAML/JSON)",
|
|
138
235
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
139
236
|
epilog=(
|
|
140
|
-
"
|
|
237
|
+
"JSON sequence example:\n"
|
|
141
238
|
"[\n"
|
|
142
239
|
' "A",\n'
|
|
143
240
|
' {"WAIT": 1},\n'
|
|
@@ -146,7 +243,7 @@ def _add_sequence_parser(sub: argparse._SubParsersAction) -> None:
|
|
|
146
243
|
),
|
|
147
244
|
)
|
|
148
245
|
add_common_args(p_seq)
|
|
149
|
-
p_seq.add_argument("--preset", type=str, default=None)
|
|
246
|
+
p_seq.add_argument("--preset", type=str, default=None, help=_PRESET_HELP)
|
|
150
247
|
p_seq.add_argument("--sequence-file", type=str, default=None)
|
|
151
248
|
add_history_export_args(p_seq)
|
|
152
249
|
add_grammar_args(p_seq)
|
|
@@ -157,9 +254,7 @@ def _add_metrics_parser(sub: argparse._SubParsersAction) -> None:
|
|
|
157
254
|
"""Configure the ``metrics`` subcommand."""
|
|
158
255
|
from .execution import cmd_metrics
|
|
159
256
|
|
|
160
|
-
p_met = sub.add_parser(
|
|
161
|
-
"metrics", help="Correr breve y volcar métricas clave"
|
|
162
|
-
)
|
|
257
|
+
p_met = sub.add_parser("metrics", help="Run briefly and export key metrics")
|
|
163
258
|
add_common_args(p_met)
|
|
164
259
|
p_met.add_argument("--steps", type=int, default=None)
|
|
165
260
|
add_canon_toggle(p_met)
|
|
@@ -170,8 +265,225 @@ def _add_metrics_parser(sub: argparse._SubParsersAction) -> None:
|
|
|
170
265
|
type=int,
|
|
171
266
|
default=None,
|
|
172
267
|
help=(
|
|
173
|
-
"
|
|
174
|
-
"
|
|
268
|
+
"Maximum number of samples per series in the summary (<=0 to"
|
|
269
|
+
" disable trimming)"
|
|
175
270
|
),
|
|
176
271
|
)
|
|
177
272
|
p_met.set_defaults(func=cmd_metrics)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def _add_profile_parser(sub: argparse._SubParsersAction) -> None:
|
|
276
|
+
"""Configure the ``profile-si`` subcommand."""
|
|
277
|
+
|
|
278
|
+
from .execution import cmd_profile_si
|
|
279
|
+
|
|
280
|
+
p_prof = sub.add_parser(
|
|
281
|
+
"profile-si",
|
|
282
|
+
help="Profile compute_Si with and without NumPy",
|
|
283
|
+
)
|
|
284
|
+
p_prof.add_argument("--nodes", type=int, default=240)
|
|
285
|
+
p_prof.add_argument("--chord-step", type=int, default=7)
|
|
286
|
+
p_prof.add_argument("--loops", type=int, default=5)
|
|
287
|
+
p_prof.add_argument("--output-dir", type=Path, default=Path("profiles"))
|
|
288
|
+
p_prof.add_argument("--format", choices=("pstats", "json"), default="pstats")
|
|
289
|
+
p_prof.add_argument("--sort", choices=("cumtime", "tottime"), default="cumtime")
|
|
290
|
+
p_prof.set_defaults(func=cmd_profile_si)
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def _add_profile_pipeline_parser(sub: argparse._SubParsersAction) -> None:
|
|
294
|
+
"""Configure the ``profile-pipeline`` subcommand."""
|
|
295
|
+
|
|
296
|
+
from .execution import cmd_profile_pipeline
|
|
297
|
+
|
|
298
|
+
p_profile = sub.add_parser(
|
|
299
|
+
"profile-pipeline",
|
|
300
|
+
help="Profile the Sense Index + ΔNFR pipeline",
|
|
301
|
+
)
|
|
302
|
+
p_profile.add_argument("--nodes", type=int, default=240, help="Number of nodes")
|
|
303
|
+
p_profile.add_argument(
|
|
304
|
+
"--edge-probability",
|
|
305
|
+
type=float,
|
|
306
|
+
default=0.32,
|
|
307
|
+
help="Probability passed to the Erdos-Renyi generator",
|
|
308
|
+
)
|
|
309
|
+
p_profile.add_argument(
|
|
310
|
+
"--loops",
|
|
311
|
+
type=int,
|
|
312
|
+
default=5,
|
|
313
|
+
help="How many times to execute the pipeline inside the profiler",
|
|
314
|
+
)
|
|
315
|
+
p_profile.add_argument(
|
|
316
|
+
"--seed",
|
|
317
|
+
type=int,
|
|
318
|
+
default=42,
|
|
319
|
+
help="Random seed used when generating the graph",
|
|
320
|
+
)
|
|
321
|
+
p_profile.add_argument(
|
|
322
|
+
"--output-dir",
|
|
323
|
+
type=Path,
|
|
324
|
+
default=Path("profiles"),
|
|
325
|
+
help="Directory where profiling artefacts will be written",
|
|
326
|
+
)
|
|
327
|
+
p_profile.add_argument(
|
|
328
|
+
"--sort",
|
|
329
|
+
choices=("cumtime", "tottime"),
|
|
330
|
+
default="cumtime",
|
|
331
|
+
help="Sort order applied to profiling rows",
|
|
332
|
+
)
|
|
333
|
+
p_profile.add_argument(
|
|
334
|
+
"--si-chunk-sizes",
|
|
335
|
+
nargs="+",
|
|
336
|
+
metavar="SIZE",
|
|
337
|
+
help="Chunk sizes forwarded to G.graph['SI_CHUNK_SIZE']; use 'auto' for heuristics",
|
|
338
|
+
)
|
|
339
|
+
p_profile.add_argument(
|
|
340
|
+
"--dnfr-chunk-sizes",
|
|
341
|
+
nargs="+",
|
|
342
|
+
metavar="SIZE",
|
|
343
|
+
help="Chunk sizes forwarded to G.graph['DNFR_CHUNK_SIZE']; use 'auto' for heuristics",
|
|
344
|
+
)
|
|
345
|
+
p_profile.add_argument(
|
|
346
|
+
"--si-workers",
|
|
347
|
+
nargs="+",
|
|
348
|
+
metavar="COUNT",
|
|
349
|
+
help="Worker counts forwarded to G.graph['SI_N_JOBS']; use 'auto' for serial runs",
|
|
350
|
+
)
|
|
351
|
+
p_profile.add_argument(
|
|
352
|
+
"--dnfr-workers",
|
|
353
|
+
nargs="+",
|
|
354
|
+
metavar="COUNT",
|
|
355
|
+
help="Worker counts forwarded to G.graph['DNFR_N_JOBS']; use 'auto' for defaults",
|
|
356
|
+
)
|
|
357
|
+
p_profile.set_defaults(func=cmd_profile_pipeline)
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def _add_math_run_parser(sub: argparse._SubParsersAction) -> None:
|
|
361
|
+
"""Configure the ``math.run`` subcommand."""
|
|
362
|
+
from .execution import cmd_math_run
|
|
363
|
+
|
|
364
|
+
p_math = sub.add_parser(
|
|
365
|
+
"math.run",
|
|
366
|
+
help="Run simulation with mathematical dynamics engine validation",
|
|
367
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
368
|
+
epilog=(
|
|
369
|
+
"Examples:\n"
|
|
370
|
+
" # Run with default math engine settings\n"
|
|
371
|
+
" tnfr math.run --nodes 24 --steps 100\n\n"
|
|
372
|
+
" # Run with custom Hilbert dimension\n"
|
|
373
|
+
" tnfr math.run --math-dimension 32 --steps 50\n\n"
|
|
374
|
+
" # Run with custom coherence spectrum\n"
|
|
375
|
+
" tnfr math.run --math-coherence-spectrum 1.0 0.8 0.6 --steps 100\n"
|
|
376
|
+
),
|
|
377
|
+
)
|
|
378
|
+
add_common_args(p_math)
|
|
379
|
+
p_math.add_argument("--steps", type=int, default=100)
|
|
380
|
+
p_math.add_argument(
|
|
381
|
+
"--preset",
|
|
382
|
+
type=str,
|
|
383
|
+
default=None,
|
|
384
|
+
help=_PRESET_HELP,
|
|
385
|
+
)
|
|
386
|
+
p_math.add_argument("--sequence-file", type=str, default=None)
|
|
387
|
+
add_canon_toggle(p_math)
|
|
388
|
+
add_grammar_selector_args(p_math)
|
|
389
|
+
add_history_export_args(p_math)
|
|
390
|
+
|
|
391
|
+
# Math engine is always enabled for math.run
|
|
392
|
+
math_group = p_math.add_argument_group("Mathematical dynamics (always enabled)")
|
|
393
|
+
math_group.add_argument(
|
|
394
|
+
"--math-dimension",
|
|
395
|
+
type=int,
|
|
396
|
+
help="Hilbert space dimension",
|
|
397
|
+
)
|
|
398
|
+
math_group.add_argument(
|
|
399
|
+
"--math-coherence-spectrum",
|
|
400
|
+
type=float,
|
|
401
|
+
nargs="+",
|
|
402
|
+
metavar="λ",
|
|
403
|
+
help="Eigenvalues for the coherence operator",
|
|
404
|
+
)
|
|
405
|
+
math_group.add_argument(
|
|
406
|
+
"--math-coherence-c-min",
|
|
407
|
+
type=float,
|
|
408
|
+
help="Explicit coherence floor C_min",
|
|
409
|
+
)
|
|
410
|
+
math_group.add_argument(
|
|
411
|
+
"--math-coherence-threshold",
|
|
412
|
+
type=float,
|
|
413
|
+
help="Coherence threshold for validation",
|
|
414
|
+
)
|
|
415
|
+
math_group.add_argument(
|
|
416
|
+
"--math-frequency-diagonal",
|
|
417
|
+
type=float,
|
|
418
|
+
nargs="+",
|
|
419
|
+
metavar="ν",
|
|
420
|
+
help="Diagonal entries for the frequency operator",
|
|
421
|
+
)
|
|
422
|
+
math_group.add_argument(
|
|
423
|
+
"--math-generator-diagonal",
|
|
424
|
+
type=float,
|
|
425
|
+
nargs="+",
|
|
426
|
+
metavar="ω",
|
|
427
|
+
help="ΔNFR generator diagonal",
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
p_math.set_defaults(func=cmd_math_run)
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def _add_epi_validate_parser(sub: argparse._SubParsersAction) -> None:
|
|
434
|
+
"""Configure the ``epi.validate`` subcommand."""
|
|
435
|
+
from .execution import cmd_epi_validate
|
|
436
|
+
|
|
437
|
+
p_epi = sub.add_parser(
|
|
438
|
+
"epi.validate",
|
|
439
|
+
help="Validate EPI structural integrity and coherence",
|
|
440
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
441
|
+
epilog=(
|
|
442
|
+
"Examples:\n"
|
|
443
|
+
" # Validate a preset\n"
|
|
444
|
+
" tnfr epi.validate --preset resonant_bootstrap\n\n"
|
|
445
|
+
" # Validate with custom topology\n"
|
|
446
|
+
" tnfr epi.validate --nodes 48 --topology complete\n\n"
|
|
447
|
+
" # Validate from sequence file\n"
|
|
448
|
+
" tnfr epi.validate --sequence-file presets/resonant_bootstrap.yaml\n"
|
|
449
|
+
),
|
|
450
|
+
)
|
|
451
|
+
add_common_args(p_epi)
|
|
452
|
+
p_epi.add_argument("--steps", type=int, default=50)
|
|
453
|
+
p_epi.add_argument(
|
|
454
|
+
"--preset",
|
|
455
|
+
type=str,
|
|
456
|
+
default=None,
|
|
457
|
+
help=_PRESET_HELP,
|
|
458
|
+
)
|
|
459
|
+
p_epi.add_argument("--sequence-file", type=str, default=None)
|
|
460
|
+
add_canon_toggle(p_epi)
|
|
461
|
+
add_grammar_selector_args(p_epi)
|
|
462
|
+
|
|
463
|
+
validation_group = p_epi.add_argument_group("Validation options")
|
|
464
|
+
validation_group.add_argument(
|
|
465
|
+
"--check-coherence",
|
|
466
|
+
action="store_true",
|
|
467
|
+
default=True,
|
|
468
|
+
help="Validate coherence preservation (enabled by default)",
|
|
469
|
+
)
|
|
470
|
+
validation_group.add_argument(
|
|
471
|
+
"--check-frequency",
|
|
472
|
+
action="store_true",
|
|
473
|
+
default=True,
|
|
474
|
+
help="Validate structural frequency positivity (enabled by default)",
|
|
475
|
+
)
|
|
476
|
+
validation_group.add_argument(
|
|
477
|
+
"--check-phase",
|
|
478
|
+
action="store_true",
|
|
479
|
+
default=True,
|
|
480
|
+
help="Validate phase synchrony in couplings (enabled by default)",
|
|
481
|
+
)
|
|
482
|
+
validation_group.add_argument(
|
|
483
|
+
"--tolerance",
|
|
484
|
+
type=float,
|
|
485
|
+
default=1e-6,
|
|
486
|
+
help="Numerical tolerance for validation checks",
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
p_epi.set_defaults(func=cmd_epi_validate)
|
tnfr/cli/arguments.pyi
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
from typing import Any, Iterable
|
|
5
|
+
|
|
6
|
+
from ..gamma import GAMMA_REGISTRY
|
|
7
|
+
from ..types import ArgSpec
|
|
8
|
+
from .utils import spec
|
|
9
|
+
|
|
10
|
+
GRAMMAR_ARG_SPECS: tuple[ArgSpec, ...]
|
|
11
|
+
HISTORY_ARG_SPECS: tuple[ArgSpec, ...]
|
|
12
|
+
COMMON_ARG_SPECS: tuple[ArgSpec, ...]
|
|
13
|
+
|
|
14
|
+
def add_arg_specs(
|
|
15
|
+
parser: argparse._ActionsContainer, specs: Iterable[ArgSpec]
|
|
16
|
+
) -> None: ...
|
|
17
|
+
def _args_to_dict(args: argparse.Namespace, prefix: str) -> dict[str, Any]: ...
|
|
18
|
+
def add_common_args(parser: argparse.ArgumentParser) -> None: ...
|
|
19
|
+
def add_grammar_args(parser: argparse.ArgumentParser) -> None: ...
|
|
20
|
+
def add_grammar_selector_args(parser: argparse.ArgumentParser) -> None: ...
|
|
21
|
+
def add_history_export_args(parser: argparse.ArgumentParser) -> None: ...
|
|
22
|
+
def add_canon_toggle(parser: argparse.ArgumentParser) -> None: ...
|
|
23
|
+
def _add_run_parser(sub: argparse._SubParsersAction) -> None: ...
|
|
24
|
+
def _add_sequence_parser(sub: argparse._SubParsersAction) -> None: ...
|
|
25
|
+
def _add_metrics_parser(sub: argparse._SubParsersAction) -> None: ...
|
|
26
|
+
def _add_profile_parser(sub: argparse._SubParsersAction) -> None: ...
|
|
27
|
+
def _add_profile_pipeline_parser(sub: argparse._SubParsersAction) -> None: ...
|
|
28
|
+
def _add_math_run_parser(sub: argparse._SubParsersAction) -> None: ...
|
|
29
|
+
def _add_epi_validate_parser(sub: argparse._SubParsersAction) -> None: ...
|