tnfr 6.0.0__py3-none-any.whl → 7.0.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.

Files changed (176) hide show
  1. tnfr/__init__.py +50 -5
  2. tnfr/__init__.pyi +0 -7
  3. tnfr/_compat.py +0 -1
  4. tnfr/_generated_version.py +34 -0
  5. tnfr/_version.py +44 -2
  6. tnfr/alias.py +14 -13
  7. tnfr/alias.pyi +5 -37
  8. tnfr/cache.py +9 -729
  9. tnfr/cache.pyi +8 -224
  10. tnfr/callback_utils.py +16 -31
  11. tnfr/callback_utils.pyi +3 -29
  12. tnfr/cli/__init__.py +17 -11
  13. tnfr/cli/__init__.pyi +0 -21
  14. tnfr/cli/arguments.py +175 -14
  15. tnfr/cli/arguments.pyi +5 -11
  16. tnfr/cli/execution.py +434 -48
  17. tnfr/cli/execution.pyi +14 -24
  18. tnfr/cli/utils.py +20 -3
  19. tnfr/cli/utils.pyi +5 -5
  20. tnfr/config/__init__.py +2 -1
  21. tnfr/config/__init__.pyi +2 -0
  22. tnfr/config/feature_flags.py +83 -0
  23. tnfr/config/init.py +1 -1
  24. tnfr/config/operator_names.py +1 -14
  25. tnfr/config/presets.py +6 -26
  26. tnfr/constants/__init__.py +10 -13
  27. tnfr/constants/__init__.pyi +10 -22
  28. tnfr/constants/aliases.py +31 -0
  29. tnfr/constants/core.py +4 -3
  30. tnfr/constants/init.py +1 -1
  31. tnfr/constants/metric.py +3 -3
  32. tnfr/dynamics/__init__.py +64 -10
  33. tnfr/dynamics/__init__.pyi +3 -4
  34. tnfr/dynamics/adaptation.py +79 -13
  35. tnfr/dynamics/aliases.py +10 -9
  36. tnfr/dynamics/coordination.py +77 -35
  37. tnfr/dynamics/dnfr.py +575 -274
  38. tnfr/dynamics/dnfr.pyi +1 -10
  39. tnfr/dynamics/integrators.py +47 -33
  40. tnfr/dynamics/integrators.pyi +0 -1
  41. tnfr/dynamics/runtime.py +489 -129
  42. tnfr/dynamics/sampling.py +2 -0
  43. tnfr/dynamics/selectors.py +101 -62
  44. tnfr/execution.py +15 -8
  45. tnfr/execution.pyi +5 -25
  46. tnfr/flatten.py +7 -3
  47. tnfr/flatten.pyi +1 -8
  48. tnfr/gamma.py +22 -26
  49. tnfr/gamma.pyi +0 -6
  50. tnfr/glyph_history.py +37 -26
  51. tnfr/glyph_history.pyi +1 -19
  52. tnfr/glyph_runtime.py +16 -0
  53. tnfr/glyph_runtime.pyi +9 -0
  54. tnfr/immutable.py +20 -15
  55. tnfr/immutable.pyi +4 -7
  56. tnfr/initialization.py +5 -7
  57. tnfr/initialization.pyi +1 -9
  58. tnfr/io.py +6 -305
  59. tnfr/io.pyi +13 -8
  60. tnfr/mathematics/__init__.py +81 -0
  61. tnfr/mathematics/backend.py +426 -0
  62. tnfr/mathematics/dynamics.py +398 -0
  63. tnfr/mathematics/epi.py +254 -0
  64. tnfr/mathematics/generators.py +222 -0
  65. tnfr/mathematics/metrics.py +119 -0
  66. tnfr/mathematics/operators.py +233 -0
  67. tnfr/mathematics/operators_factory.py +71 -0
  68. tnfr/mathematics/projection.py +78 -0
  69. tnfr/mathematics/runtime.py +173 -0
  70. tnfr/mathematics/spaces.py +247 -0
  71. tnfr/mathematics/transforms.py +292 -0
  72. tnfr/metrics/__init__.py +10 -10
  73. tnfr/metrics/coherence.py +123 -94
  74. tnfr/metrics/common.py +22 -13
  75. tnfr/metrics/common.pyi +42 -11
  76. tnfr/metrics/core.py +72 -14
  77. tnfr/metrics/diagnosis.py +48 -57
  78. tnfr/metrics/diagnosis.pyi +3 -7
  79. tnfr/metrics/export.py +3 -5
  80. tnfr/metrics/glyph_timing.py +41 -31
  81. tnfr/metrics/reporting.py +13 -6
  82. tnfr/metrics/sense_index.py +884 -114
  83. tnfr/metrics/trig.py +167 -11
  84. tnfr/metrics/trig.pyi +1 -0
  85. tnfr/metrics/trig_cache.py +112 -15
  86. tnfr/node.py +400 -17
  87. tnfr/node.pyi +55 -38
  88. tnfr/observers.py +111 -8
  89. tnfr/observers.pyi +0 -15
  90. tnfr/ontosim.py +9 -6
  91. tnfr/ontosim.pyi +0 -5
  92. tnfr/operators/__init__.py +529 -42
  93. tnfr/operators/__init__.pyi +14 -0
  94. tnfr/operators/definitions.py +350 -18
  95. tnfr/operators/definitions.pyi +0 -14
  96. tnfr/operators/grammar.py +760 -0
  97. tnfr/operators/jitter.py +28 -22
  98. tnfr/operators/registry.py +7 -12
  99. tnfr/operators/registry.pyi +0 -2
  100. tnfr/operators/remesh.py +38 -61
  101. tnfr/rng.py +17 -300
  102. tnfr/schemas/__init__.py +8 -0
  103. tnfr/schemas/grammar.json +94 -0
  104. tnfr/selector.py +3 -4
  105. tnfr/selector.pyi +1 -1
  106. tnfr/sense.py +22 -24
  107. tnfr/sense.pyi +0 -7
  108. tnfr/structural.py +504 -21
  109. tnfr/structural.pyi +41 -18
  110. tnfr/telemetry/__init__.py +23 -1
  111. tnfr/telemetry/cache_metrics.py +226 -0
  112. tnfr/telemetry/nu_f.py +423 -0
  113. tnfr/telemetry/nu_f.pyi +123 -0
  114. tnfr/tokens.py +1 -4
  115. tnfr/tokens.pyi +1 -6
  116. tnfr/trace.py +20 -53
  117. tnfr/trace.pyi +9 -37
  118. tnfr/types.py +244 -15
  119. tnfr/types.pyi +200 -14
  120. tnfr/units.py +69 -0
  121. tnfr/units.pyi +16 -0
  122. tnfr/utils/__init__.py +107 -48
  123. tnfr/utils/__init__.pyi +80 -11
  124. tnfr/utils/cache.py +1705 -65
  125. tnfr/utils/cache.pyi +370 -58
  126. tnfr/utils/chunks.py +104 -0
  127. tnfr/utils/chunks.pyi +21 -0
  128. tnfr/utils/data.py +95 -5
  129. tnfr/utils/data.pyi +8 -17
  130. tnfr/utils/graph.py +2 -4
  131. tnfr/utils/init.py +31 -7
  132. tnfr/utils/init.pyi +4 -11
  133. tnfr/utils/io.py +313 -14
  134. tnfr/{helpers → utils}/numeric.py +50 -24
  135. tnfr/utils/numeric.pyi +21 -0
  136. tnfr/validation/__init__.py +92 -4
  137. tnfr/validation/__init__.pyi +77 -17
  138. tnfr/validation/compatibility.py +79 -43
  139. tnfr/validation/compatibility.pyi +4 -6
  140. tnfr/validation/grammar.py +55 -133
  141. tnfr/validation/grammar.pyi +37 -8
  142. tnfr/validation/graph.py +138 -0
  143. tnfr/validation/graph.pyi +17 -0
  144. tnfr/validation/rules.py +161 -74
  145. tnfr/validation/rules.pyi +55 -18
  146. tnfr/validation/runtime.py +263 -0
  147. tnfr/validation/runtime.pyi +31 -0
  148. tnfr/validation/soft_filters.py +170 -0
  149. tnfr/validation/soft_filters.pyi +37 -0
  150. tnfr/validation/spectral.py +159 -0
  151. tnfr/validation/spectral.pyi +46 -0
  152. tnfr/validation/syntax.py +28 -139
  153. tnfr/validation/syntax.pyi +7 -4
  154. tnfr/validation/window.py +39 -0
  155. tnfr/validation/window.pyi +1 -0
  156. tnfr/viz/__init__.py +9 -0
  157. tnfr/viz/matplotlib.py +246 -0
  158. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/METADATA +63 -19
  159. tnfr-7.0.0.dist-info/RECORD +185 -0
  160. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/licenses/LICENSE.md +1 -1
  161. tnfr/constants_glyphs.py +0 -16
  162. tnfr/constants_glyphs.pyi +0 -12
  163. tnfr/grammar.py +0 -25
  164. tnfr/grammar.pyi +0 -13
  165. tnfr/helpers/__init__.py +0 -151
  166. tnfr/helpers/__init__.pyi +0 -66
  167. tnfr/helpers/numeric.pyi +0 -12
  168. tnfr/presets.py +0 -15
  169. tnfr/presets.pyi +0 -7
  170. tnfr/utils/io.pyi +0 -10
  171. tnfr/utils/validators.py +0 -130
  172. tnfr/utils/validators.pyi +0 -19
  173. tnfr-6.0.0.dist-info/RECORD +0 -157
  174. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/WHEEL +0 -0
  175. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/entry_points.txt +0 -0
  176. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/top_level.txt +0 -0
tnfr/cli/arguments.py CHANGED
@@ -1,6 +1,9 @@
1
+ """Argument parser helpers shared across TNFR CLI commands."""
2
+
1
3
  from __future__ import annotations
2
4
 
3
5
  import argparse
6
+ from pathlib import Path
4
7
  from typing import Any, Iterable
5
8
 
6
9
  from ..config.presets import PREFERRED_PRESET_NAMES
@@ -9,7 +12,6 @@ from ..telemetry.verbosity import TELEMETRY_VERBOSITY_LEVELS
9
12
  from ..types import ArgSpec
10
13
  from .utils import spec
11
14
 
12
-
13
15
  _PRESET_HELP = "Available presets: {}.".format(
14
16
  ", ".join(PREFERRED_PRESET_NAMES),
15
17
  )
@@ -65,12 +67,13 @@ COMMON_ARG_SPECS: tuple[ArgSpec, ...] = (
65
67
  spec("--gamma-type", choices=list(GAMMA_REGISTRY.keys()), default="none"),
66
68
  spec("--gamma-beta", type=float, default=0.0),
67
69
  spec("--gamma-R0", type=float, default=0.0),
70
+ spec("--um-candidate-count", type=int),
71
+ spec("--stop-early-window", type=int),
72
+ spec("--stop-early-fraction", type=float),
68
73
  )
69
74
 
70
75
 
71
- def add_arg_specs(
72
- parser: argparse._ActionsContainer, specs: Iterable[ArgSpec]
73
- ) -> None:
76
+ def add_arg_specs(parser: argparse._ActionsContainer, specs: Iterable[ArgSpec]) -> None:
74
77
  """Register arguments from ``specs`` on ``parser``."""
75
78
  for opt, kwargs in specs:
76
79
  parser.add_argument(opt, **kwargs)
@@ -99,9 +102,7 @@ def add_grammar_args(parser: argparse.ArgumentParser) -> None:
99
102
  def add_grammar_selector_args(parser: argparse.ArgumentParser) -> None:
100
103
  """Add grammar options and glyph selector."""
101
104
  add_grammar_args(parser)
102
- parser.add_argument(
103
- "--selector", choices=["basic", "param"], default="basic"
104
- )
105
+ parser.add_argument("--selector", choices=["basic", "param"], default="basic")
105
106
 
106
107
 
107
108
  def add_history_export_args(parser: argparse.ArgumentParser) -> None:
@@ -122,16 +123,35 @@ def add_canon_toggle(parser: argparse.ArgumentParser) -> None:
122
123
 
123
124
  def _add_run_parser(sub: argparse._SubParsersAction) -> None:
124
125
  """Configure the ``run`` subcommand."""
125
- from .execution import cmd_run, DEFAULT_SUMMARY_SERIES_LIMIT
126
+
127
+ from .execution import DEFAULT_SUMMARY_SERIES_LIMIT, cmd_run
126
128
 
127
129
  p_run = sub.add_parser(
128
130
  "run",
129
- help=(
130
- "Run a free scenario or preset and optionally export history"
131
- ),
131
+ help=("Run a free scenario or preset and optionally export history"),
132
132
  )
133
133
  add_common_args(p_run)
134
134
  p_run.add_argument("--steps", type=int, default=100)
135
+ p_run.add_argument(
136
+ "--use-Si",
137
+ dest="use_Si",
138
+ action=argparse.BooleanOptionalAction,
139
+ default=None,
140
+ help="Recompute the Sense Index during the run (use --no-use-Si to disable)",
141
+ )
142
+ p_run.add_argument(
143
+ "--apply-glyphs",
144
+ dest="apply_glyphs",
145
+ action=argparse.BooleanOptionalAction,
146
+ default=None,
147
+ help="Apply glyphs at every step (use --no-apply-glyphs to disable)",
148
+ )
149
+ p_run.add_argument(
150
+ "--dnfr-n-jobs",
151
+ dest="dnfr_n_jobs",
152
+ type=int,
153
+ help="Override ΔNFR parallel jobs forwarded to the runtime",
154
+ )
135
155
  add_canon_toggle(p_run)
136
156
  add_grammar_selector_args(p_run)
137
157
  add_history_export_args(p_run)
@@ -147,6 +167,64 @@ def _add_run_parser(sub: argparse._SubParsersAction) -> None:
147
167
  " disable trimming)"
148
168
  ),
149
169
  )
170
+
171
+ math_group = p_run.add_argument_group("Mathematical dynamics")
172
+ math_group.add_argument(
173
+ "--math-engine",
174
+ action=argparse.BooleanOptionalAction,
175
+ default=False,
176
+ help=(
177
+ "Enable the spectral mathematical dynamics engine to project nodes"
178
+ " onto Hilbert space vectors and validate norm, coherence and"
179
+ " structural frequency invariants"
180
+ ),
181
+ )
182
+ math_group.add_argument(
183
+ "--math-dimension",
184
+ type=int,
185
+ help="Hilbert space dimension to use when the math engine is enabled",
186
+ )
187
+ math_group.add_argument(
188
+ "--math-coherence-spectrum",
189
+ type=float,
190
+ nargs="+",
191
+ metavar="λ",
192
+ help=(
193
+ "Eigenvalues for the coherence operator (defaults to a flat"
194
+ " spectrum when omitted)"
195
+ ),
196
+ )
197
+ math_group.add_argument(
198
+ "--math-coherence-c-min",
199
+ type=float,
200
+ help="Explicit coherence floor C_min for the operator",
201
+ )
202
+ math_group.add_argument(
203
+ "--math-coherence-threshold",
204
+ type=float,
205
+ help="Coherence expectation threshold enforced during validation",
206
+ )
207
+ math_group.add_argument(
208
+ "--math-frequency-diagonal",
209
+ type=float,
210
+ nargs="+",
211
+ metavar="ν",
212
+ help=(
213
+ "Diagonal entries for the structural frequency operator"
214
+ " (defaults to the identity spectrum)"
215
+ ),
216
+ )
217
+ math_group.add_argument(
218
+ "--math-generator-diagonal",
219
+ type=float,
220
+ nargs="+",
221
+ metavar="ω",
222
+ help=(
223
+ "Diagonal ΔNFR generator used by the mathematical dynamics"
224
+ " engine (defaults to the null generator)"
225
+ ),
226
+ )
227
+
150
228
  p_run.set_defaults(func=cmd_run)
151
229
 
152
230
 
@@ -179,9 +257,7 @@ def _add_metrics_parser(sub: argparse._SubParsersAction) -> None:
179
257
  """Configure the ``metrics`` subcommand."""
180
258
  from .execution import cmd_metrics
181
259
 
182
- p_met = sub.add_parser(
183
- "metrics", help="Run briefly and export key metrics"
184
- )
260
+ p_met = sub.add_parser("metrics", help="Run briefly and export key metrics")
185
261
  add_common_args(p_met)
186
262
  p_met.add_argument("--steps", type=int, default=None)
187
263
  add_canon_toggle(p_met)
@@ -197,3 +273,88 @@ def _add_metrics_parser(sub: argparse._SubParsersAction) -> None:
197
273
  ),
198
274
  )
199
275
  p_met.set_defaults(func=cmd_metrics)
276
+
277
+
278
+ def _add_profile_parser(sub: argparse._SubParsersAction) -> None:
279
+ """Configure the ``profile-si`` subcommand."""
280
+
281
+ from .execution import cmd_profile_si
282
+
283
+ p_prof = sub.add_parser(
284
+ "profile-si",
285
+ help="Profile compute_Si with and without NumPy",
286
+ )
287
+ p_prof.add_argument("--nodes", type=int, default=240)
288
+ p_prof.add_argument("--chord-step", type=int, default=7)
289
+ p_prof.add_argument("--loops", type=int, default=5)
290
+ p_prof.add_argument("--output-dir", type=Path, default=Path("profiles"))
291
+ p_prof.add_argument("--format", choices=("pstats", "json"), default="pstats")
292
+ p_prof.add_argument("--sort", choices=("cumtime", "tottime"), default="cumtime")
293
+ p_prof.set_defaults(func=cmd_profile_si)
294
+
295
+
296
+ def _add_profile_pipeline_parser(sub: argparse._SubParsersAction) -> None:
297
+ """Configure the ``profile-pipeline`` subcommand."""
298
+
299
+ from .execution import cmd_profile_pipeline
300
+
301
+ p_profile = sub.add_parser(
302
+ "profile-pipeline",
303
+ help="Profile the Sense Index + ΔNFR pipeline",
304
+ )
305
+ p_profile.add_argument("--nodes", type=int, default=240, help="Number of nodes")
306
+ p_profile.add_argument(
307
+ "--edge-probability",
308
+ type=float,
309
+ default=0.32,
310
+ help="Probability passed to the Erdos-Renyi generator",
311
+ )
312
+ p_profile.add_argument(
313
+ "--loops",
314
+ type=int,
315
+ default=5,
316
+ help="How many times to execute the pipeline inside the profiler",
317
+ )
318
+ p_profile.add_argument(
319
+ "--seed",
320
+ type=int,
321
+ default=42,
322
+ help="Random seed used when generating the graph",
323
+ )
324
+ p_profile.add_argument(
325
+ "--output-dir",
326
+ type=Path,
327
+ default=Path("profiles"),
328
+ help="Directory where profiling artefacts will be written",
329
+ )
330
+ p_profile.add_argument(
331
+ "--sort",
332
+ choices=("cumtime", "tottime"),
333
+ default="cumtime",
334
+ help="Sort order applied to profiling rows",
335
+ )
336
+ p_profile.add_argument(
337
+ "--si-chunk-sizes",
338
+ nargs="+",
339
+ metavar="SIZE",
340
+ help="Chunk sizes forwarded to G.graph['SI_CHUNK_SIZE']; use 'auto' for heuristics",
341
+ )
342
+ p_profile.add_argument(
343
+ "--dnfr-chunk-sizes",
344
+ nargs="+",
345
+ metavar="SIZE",
346
+ help="Chunk sizes forwarded to G.graph['DNFR_CHUNK_SIZE']; use 'auto' for heuristics",
347
+ )
348
+ p_profile.add_argument(
349
+ "--si-workers",
350
+ nargs="+",
351
+ metavar="COUNT",
352
+ help="Worker counts forwarded to G.graph['SI_N_JOBS']; use 'auto' for serial runs",
353
+ )
354
+ p_profile.add_argument(
355
+ "--dnfr-workers",
356
+ nargs="+",
357
+ metavar="COUNT",
358
+ help="Worker counts forwarded to G.graph['DNFR_N_JOBS']; use 'auto' for defaults",
359
+ )
360
+ p_profile.set_defaults(func=cmd_profile_pipeline)
tnfr/cli/arguments.pyi CHANGED
@@ -11,23 +11,17 @@ GRAMMAR_ARG_SPECS: tuple[ArgSpec, ...]
11
11
  HISTORY_ARG_SPECS: tuple[ArgSpec, ...]
12
12
  COMMON_ARG_SPECS: tuple[ArgSpec, ...]
13
13
 
14
-
15
- def add_arg_specs(parser: argparse._ActionsContainer, specs: Iterable[ArgSpec]) -> None: ...
16
-
14
+ def add_arg_specs(
15
+ parser: argparse._ActionsContainer, specs: Iterable[ArgSpec]
16
+ ) -> None: ...
17
17
  def _args_to_dict(args: argparse.Namespace, prefix: str) -> dict[str, Any]: ...
18
-
19
18
  def add_common_args(parser: argparse.ArgumentParser) -> None: ...
20
-
21
19
  def add_grammar_args(parser: argparse.ArgumentParser) -> None: ...
22
-
23
20
  def add_grammar_selector_args(parser: argparse.ArgumentParser) -> None: ...
24
-
25
21
  def add_history_export_args(parser: argparse.ArgumentParser) -> None: ...
26
-
27
22
  def add_canon_toggle(parser: argparse.ArgumentParser) -> None: ...
28
-
29
23
  def _add_run_parser(sub: argparse._SubParsersAction) -> None: ...
30
-
31
24
  def _add_sequence_parser(sub: argparse._SubParsersAction) -> None: ...
32
-
33
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: ...