tnfr 4.3.0__tar.gz → 4.5.1__tar.gz

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 (54) hide show
  1. tnfr-4.5.1/PKG-INFO +221 -0
  2. tnfr-4.5.1/README.md +194 -0
  3. {tnfr-4.3.0 → tnfr-4.5.1}/pyproject.toml +6 -4
  4. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/__init__.py +41 -12
  5. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/cli.py +53 -1
  6. tnfr-4.5.1/src/tnfr/config.py +41 -0
  7. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/constants.py +82 -25
  8. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/dynamics.py +191 -42
  9. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/gamma.py +17 -0
  10. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/helpers.py +33 -21
  11. tnfr-4.5.1/src/tnfr/metrics.py +597 -0
  12. tnfr-4.5.1/src/tnfr/node.py +202 -0
  13. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/observers.py +9 -1
  14. tnfr-4.5.1/src/tnfr/operators.py +525 -0
  15. tnfr-4.5.1/src/tnfr/structural.py +201 -0
  16. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/types.py +2 -1
  17. tnfr-4.5.1/src/tnfr/validators.py +38 -0
  18. tnfr-4.5.1/src/tnfr.egg-info/PKG-INFO +221 -0
  19. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr.egg-info/SOURCES.txt +11 -1
  20. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_grammar.py +13 -0
  21. tnfr-4.5.1/tests/test_integrators.py +36 -0
  22. tnfr-4.5.1/tests/test_nav.py +32 -0
  23. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_remesh.py +2 -0
  24. tnfr-4.5.1/tests/test_remesh_community.py +18 -0
  25. tnfr-4.5.1/tests/test_structural.py +47 -0
  26. tnfr-4.5.1/tests/test_validators.py +38 -0
  27. tnfr-4.5.1/tests/test_vf_coherencia.py +27 -0
  28. tnfr-4.3.0/PKG-INFO +0 -109
  29. tnfr-4.3.0/README.md +0 -82
  30. tnfr-4.3.0/src/tnfr/metrics.py +0 -234
  31. tnfr-4.3.0/src/tnfr/operators.py +0 -352
  32. tnfr-4.3.0/src/tnfr.egg-info/PKG-INFO +0 -109
  33. {tnfr-4.3.0 → tnfr-4.5.1}/LICENSE.md +0 -0
  34. {tnfr-4.3.0 → tnfr-4.5.1}/setup.cfg +0 -0
  35. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/grammar.py +0 -0
  36. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/main.py +0 -0
  37. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/ontosim.py +0 -0
  38. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/presets.py +0 -0
  39. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/program.py +0 -0
  40. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/scenarios.py +0 -0
  41. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/sense.py +0 -0
  42. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr/trace.py +0 -0
  43. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr.egg-info/dependency_links.txt +0 -0
  44. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr.egg-info/entry_points.txt +0 -0
  45. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr.egg-info/requires.txt +0 -0
  46. {tnfr-4.3.0 → tnfr-4.5.1}/src/tnfr.egg-info/top_level.txt +0 -0
  47. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_canon.py +0 -0
  48. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_cli_sanity.py +0 -0
  49. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_edge_cases.py +0 -0
  50. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_gamma.py +0 -0
  51. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_history.py +0 -0
  52. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_history_series.py +0 -0
  53. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_invariants.py +0 -0
  54. {tnfr-4.3.0 → tnfr-4.5.1}/tests/test_program.py +0 -0
tnfr-4.5.1/PKG-INFO ADDED
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: tnfr
3
+ Version: 4.5.1
4
+ Summary: modular structural-based dynamics on networks
5
+ Author: fmg
6
+ License: MIT
7
+ Project-URL: Homepage, https://pypi.org/project/tnfr/
8
+ Project-URL: Repository, https://github.com/fermga/Teoria-de-la-naturaleza-fractal-resonante-TNFR-
9
+ Keywords: TNFR,resonant fractal,resonance,glyphs,networkx,dynamics,coherence,EPI,Kuramoto
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE.md
25
+ Requires-Dist: networkx>=2.6
26
+ Dynamic: license-file
27
+
28
+ # tnfr · Python package
29
+
30
+ > Engine for **modeling, simulation, and measurement** of multiscale structural coherence through **structural operators** (emission, reception, coherence, dissonance, coupling, resonance, silence, expansion, contraction, self‑organization, mutation, transition, recursivity).
31
+
32
+ ---
33
+
34
+ ## What is `tnfr`?
35
+
36
+ `tnfr` is a Python library to **operate with form**: build nodes, couple them into networks, and **modulate their coherence** over time using structural operators. It does not describe “things”; it **activates processes**. Its theoretical basis is the Resonant Fractal Nature Theory (TNFR), which understands reality as **networks of coherence** that persist because they **resonate**.
37
+
38
+ In practical terms, `tnfr` lets you:
39
+
40
+ * Model **Resonant Fractal Nodes (NFR)** with parameters for **frequency** (νf), **phase** (θ), and **form** (EPI).
41
+ * Apply **structural operators** to start, stabilize, propagate, or reconfigure coherence.
42
+ * **Simulate** nodal dynamics with discrete/continuous integrators.
43
+ * **Measure** global coherence C(t), nodal gradient ΔNFR, and the **Sense Index** (Si).
44
+ * **Visualize** states and trajectories (coupling matrices, C(t) curves, graphs).
45
+
46
+ > **Nodal equation (operational core)**
47
+ >
48
+ > $\frac{\partial \mathrm{EPI}}{\partial t} = \nu_f\,\cdot\,\Delta\mathrm{NFR}(t)$
49
+ >
50
+ > A form emerges and persists when **internal reorganization** (ΔNFR) **resonates** with the node’s **frequency** (νf).
51
+
52
+ ---
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ pip install tnfr
58
+ ```
59
+
60
+ Requires **Python ≥ 3.9**.
61
+
62
+ ---
63
+
64
+ ## Why TNFR (in 60 seconds)
65
+
66
+ * **From objects to coherences:** you model **processes** that hold, not fixed entities.
67
+ * **Operators instead of rules:** you compose **structural operators** (e.g., *emission*, *coherence*, *dissonance*) to **build trajectories**.
68
+ * **Operational fractality:** the same pattern works for **ideas, teams, tissues, narratives**; the scales change, **the logic doesn’t**.
69
+
70
+ ---
71
+
72
+ ## Getting started (minimal recipe)
73
+
74
+ > *The high‑level API centers on three things: nodes, operators, simulation.*
75
+
76
+ ```python
77
+ # 1) Nodes and network
78
+ import tnfr as T
79
+
80
+ # A minimal set of nodes with initial frequency (νf)
81
+ A = T.Node(label="seed", nu_f=0.8)
82
+ B = T.Node(label="context", nu_f=0.6)
83
+ net = T.Network([A, B], edges=[(A, B, 0.7)]) # coupling 0..1
84
+
85
+ # 2) Sequence of structural operators
86
+ ops = [
87
+ T.ops.Emission(strength=0.4), # start pattern
88
+ T.ops.Coupling(weight=0.7), # synchronize nodes
89
+ T.ops.Coherence(), # stabilize form
90
+ ]
91
+
92
+ # 3) Simulation and metrics
93
+ traj = T.sim.run(net, ops, steps=200, dt=0.05)
94
+ print("C(t) =", T.metrics.coherence(traj)[-1])
95
+ print("Si =", T.metrics.sense_index(traj))
96
+
97
+ # 4) Quick visualization
98
+ T.viz.plot_coherence(traj) # C(t) curve
99
+ T.viz.plot_network(net) # graph/couplings
100
+ ```
101
+
102
+ > **Note:** Specific class/function names may vary across minor versions. Check `help(T.ops)` and `help(T.sim)` for your installed API.
103
+
104
+ ---
105
+
106
+ ## Key concepts (operational summary)
107
+
108
+ * **Node (NFR):** a unit that persists because it **resonates**. Parameterized by **νf** (frequency), **θ** (phase), and **EPI** (coherent form).
109
+ * **Structural operators:** functions that reorganize the network. We use **functional** names (not phonemes):
110
+
111
+ * **Emission** (start), **Reception** (open), **Coherence** (stabilize), **Dissonance** (creative tension), **Coupling** (synchrony), **Resonance** (propagate), **Silence** (latency), **Expansion**, **Contraction**, **Self‑organization**, **Mutation**, **Transition**, **Recursivity**.
112
+ * **Magnitudes:**
113
+
114
+ * **C(t):** global coherence.
115
+ * **ΔNFR:** nodal gradient (need for reorganization).
116
+ * **νf:** structural frequency (Hz\_str).
117
+ * **Si:** sense index (ability to generate stable shared coherence).
118
+
119
+ ---
120
+
121
+ ## Typical workflow
122
+
123
+ 1. **Model** your system as a network: nodes (agents, ideas, tissues, modules) and couplings.
124
+ 2. **Select** a **trajectory of operators** aligned with your goal (e.g., *start → couple → stabilize*).
125
+ 3. **Simulate** the dynamics: number of steps, step size, tolerances.
126
+ 4. **Measure**: C(t), ΔNFR, Si; identify bifurcations and collapses.
127
+ 5. **Iterate** with controlled **dissonance** to open mutations without losing form.
128
+
129
+ ---
130
+
131
+ ## High‑level API (orientation map)
132
+
133
+ > The typical module layout in `tnfr` is:
134
+
135
+ * `tnfr.core`: `Node`, `Network`, `EPI`, `State`
136
+ * `tnfr.ops`: structural operators (Emission, Reception, Coherence, Dissonance, ...)
137
+ * `tnfr.sim`: integrators (`run`, `step`, `integrate`), dt control and thresholds
138
+ * `tnfr.metrics`: `coherence`, `gradient`, `sense_index`, `phase_sync`
139
+ * `tnfr.viz`: plotting utilities (`plot_coherence`, `plot_network`, `plot_phase`)
140
+
141
+ Usage examples:
142
+
143
+ ```python
144
+ from tnfr import core, ops, sim, metrics
145
+
146
+ net = core.Network.from_edges([
147
+ ("n1", "n2", 0.6),
148
+ ("n2", "n3", 0.8),
149
+ ])
150
+
151
+ sequence = [ops.Emission(0.3), ops.Coupling(0.5), ops.Coherence()]
152
+ traj = sim.run(net, sequence, steps=500)
153
+
154
+ print(metrics.coherence(traj))
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Parametric modeling
160
+
161
+ ```python
162
+ import tnfr as T
163
+
164
+ net = T.Network.uniform(n=25, nu_f=0.4, coupling=0.3)
165
+ plan = (
166
+ T.ops.Emission(0.2)
167
+ >> T.ops.Expansion(0.4)
168
+ >> T.ops.Coupling(0.6)
169
+ >> T.ops.Coherence()
170
+ )
171
+ traj = T.sim.run(net, plan, steps=800)
172
+ T.viz.plot_phase(traj)
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Main metrics
178
+
179
+ * `coherence(traj) → C(t)`: global stability; higher values indicate sustained form.
180
+ * `gradient(state) → ΔNFR`: local demand for reorganization (high = risk of collapse/bifurcation).
181
+ * `sense_index(traj) → Si`: proxy for **structural sense** (capacity to generate shared coherence) combining **νf**, phase, and topology.
182
+
183
+ ---
184
+
185
+ ## Best practices
186
+
187
+ * **Short sequences** and frequent C(t) checks avoid unnecessary collapses.
188
+ * Use **dissonance** as a tool: introduce it to open possibilities, but **seal** with coherence.
189
+ * **Scale first, detail later:** tune coarse couplings before micro‑parameters.
190
+
191
+ ---
192
+
193
+ ## Project status
194
+
195
+ * **pre‑1.0 API**: signatures may be refined; concepts and magnitudes are stable.
196
+ * **Pure‑Python** core with minimal dependencies (optional: `numpy`, `matplotlib`, `networkx`).
197
+
198
+ ---
199
+
200
+ ## Contributing
201
+
202
+ Suggestions, issues, and PRs are welcome. Guidelines:
203
+
204
+ 1. Prioritize **operational clarity** (names, docstrings, examples).
205
+ 2. Add **tests** and **notebooks** that show the structural effect of each PR.
206
+ 3. Keep **semantic neutrality**: operators act on form, not on contents.
207
+
208
+ ---
209
+
210
+ ## License
211
+
212
+ MIT
213
+
214
+ ---
215
+
216
+ ## References & notes
217
+
218
+ * Theoretical foundations: TNFR operational manual.
219
+ * Operational definitions: nodal equation, dimensions (frequency, phase, form), and structural operators.
220
+
221
+ > If you use `tnfr` in research or projects, please cite the TNFR conceptual framework and link to the PyPI package.
tnfr-4.5.1/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # tnfr · Python package
2
+
3
+ > Engine for **modeling, simulation, and measurement** of multiscale structural coherence through **structural operators** (emission, reception, coherence, dissonance, coupling, resonance, silence, expansion, contraction, self‑organization, mutation, transition, recursivity).
4
+
5
+ ---
6
+
7
+ ## What is `tnfr`?
8
+
9
+ `tnfr` is a Python library to **operate with form**: build nodes, couple them into networks, and **modulate their coherence** over time using structural operators. It does not describe “things”; it **activates processes**. Its theoretical basis is the Resonant Fractal Nature Theory (TNFR), which understands reality as **networks of coherence** that persist because they **resonate**.
10
+
11
+ In practical terms, `tnfr` lets you:
12
+
13
+ * Model **Resonant Fractal Nodes (NFR)** with parameters for **frequency** (νf), **phase** (θ), and **form** (EPI).
14
+ * Apply **structural operators** to start, stabilize, propagate, or reconfigure coherence.
15
+ * **Simulate** nodal dynamics with discrete/continuous integrators.
16
+ * **Measure** global coherence C(t), nodal gradient ΔNFR, and the **Sense Index** (Si).
17
+ * **Visualize** states and trajectories (coupling matrices, C(t) curves, graphs).
18
+
19
+ > **Nodal equation (operational core)**
20
+ >
21
+ > $\frac{\partial \mathrm{EPI}}{\partial t} = \nu_f\,\cdot\,\Delta\mathrm{NFR}(t)$
22
+ >
23
+ > A form emerges and persists when **internal reorganization** (ΔNFR) **resonates** with the node’s **frequency** (νf).
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install tnfr
31
+ ```
32
+
33
+ Requires **Python ≥ 3.9**.
34
+
35
+ ---
36
+
37
+ ## Why TNFR (in 60 seconds)
38
+
39
+ * **From objects to coherences:** you model **processes** that hold, not fixed entities.
40
+ * **Operators instead of rules:** you compose **structural operators** (e.g., *emission*, *coherence*, *dissonance*) to **build trajectories**.
41
+ * **Operational fractality:** the same pattern works for **ideas, teams, tissues, narratives**; the scales change, **the logic doesn’t**.
42
+
43
+ ---
44
+
45
+ ## Getting started (minimal recipe)
46
+
47
+ > *The high‑level API centers on three things: nodes, operators, simulation.*
48
+
49
+ ```python
50
+ # 1) Nodes and network
51
+ import tnfr as T
52
+
53
+ # A minimal set of nodes with initial frequency (νf)
54
+ A = T.Node(label="seed", nu_f=0.8)
55
+ B = T.Node(label="context", nu_f=0.6)
56
+ net = T.Network([A, B], edges=[(A, B, 0.7)]) # coupling 0..1
57
+
58
+ # 2) Sequence of structural operators
59
+ ops = [
60
+ T.ops.Emission(strength=0.4), # start pattern
61
+ T.ops.Coupling(weight=0.7), # synchronize nodes
62
+ T.ops.Coherence(), # stabilize form
63
+ ]
64
+
65
+ # 3) Simulation and metrics
66
+ traj = T.sim.run(net, ops, steps=200, dt=0.05)
67
+ print("C(t) =", T.metrics.coherence(traj)[-1])
68
+ print("Si =", T.metrics.sense_index(traj))
69
+
70
+ # 4) Quick visualization
71
+ T.viz.plot_coherence(traj) # C(t) curve
72
+ T.viz.plot_network(net) # graph/couplings
73
+ ```
74
+
75
+ > **Note:** Specific class/function names may vary across minor versions. Check `help(T.ops)` and `help(T.sim)` for your installed API.
76
+
77
+ ---
78
+
79
+ ## Key concepts (operational summary)
80
+
81
+ * **Node (NFR):** a unit that persists because it **resonates**. Parameterized by **νf** (frequency), **θ** (phase), and **EPI** (coherent form).
82
+ * **Structural operators:** functions that reorganize the network. We use **functional** names (not phonemes):
83
+
84
+ * **Emission** (start), **Reception** (open), **Coherence** (stabilize), **Dissonance** (creative tension), **Coupling** (synchrony), **Resonance** (propagate), **Silence** (latency), **Expansion**, **Contraction**, **Self‑organization**, **Mutation**, **Transition**, **Recursivity**.
85
+ * **Magnitudes:**
86
+
87
+ * **C(t):** global coherence.
88
+ * **ΔNFR:** nodal gradient (need for reorganization).
89
+ * **νf:** structural frequency (Hz\_str).
90
+ * **Si:** sense index (ability to generate stable shared coherence).
91
+
92
+ ---
93
+
94
+ ## Typical workflow
95
+
96
+ 1. **Model** your system as a network: nodes (agents, ideas, tissues, modules) and couplings.
97
+ 2. **Select** a **trajectory of operators** aligned with your goal (e.g., *start → couple → stabilize*).
98
+ 3. **Simulate** the dynamics: number of steps, step size, tolerances.
99
+ 4. **Measure**: C(t), ΔNFR, Si; identify bifurcations and collapses.
100
+ 5. **Iterate** with controlled **dissonance** to open mutations without losing form.
101
+
102
+ ---
103
+
104
+ ## High‑level API (orientation map)
105
+
106
+ > The typical module layout in `tnfr` is:
107
+
108
+ * `tnfr.core`: `Node`, `Network`, `EPI`, `State`
109
+ * `tnfr.ops`: structural operators (Emission, Reception, Coherence, Dissonance, ...)
110
+ * `tnfr.sim`: integrators (`run`, `step`, `integrate`), dt control and thresholds
111
+ * `tnfr.metrics`: `coherence`, `gradient`, `sense_index`, `phase_sync`
112
+ * `tnfr.viz`: plotting utilities (`plot_coherence`, `plot_network`, `plot_phase`)
113
+
114
+ Usage examples:
115
+
116
+ ```python
117
+ from tnfr import core, ops, sim, metrics
118
+
119
+ net = core.Network.from_edges([
120
+ ("n1", "n2", 0.6),
121
+ ("n2", "n3", 0.8),
122
+ ])
123
+
124
+ sequence = [ops.Emission(0.3), ops.Coupling(0.5), ops.Coherence()]
125
+ traj = sim.run(net, sequence, steps=500)
126
+
127
+ print(metrics.coherence(traj))
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Parametric modeling
133
+
134
+ ```python
135
+ import tnfr as T
136
+
137
+ net = T.Network.uniform(n=25, nu_f=0.4, coupling=0.3)
138
+ plan = (
139
+ T.ops.Emission(0.2)
140
+ >> T.ops.Expansion(0.4)
141
+ >> T.ops.Coupling(0.6)
142
+ >> T.ops.Coherence()
143
+ )
144
+ traj = T.sim.run(net, plan, steps=800)
145
+ T.viz.plot_phase(traj)
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Main metrics
151
+
152
+ * `coherence(traj) → C(t)`: global stability; higher values indicate sustained form.
153
+ * `gradient(state) → ΔNFR`: local demand for reorganization (high = risk of collapse/bifurcation).
154
+ * `sense_index(traj) → Si`: proxy for **structural sense** (capacity to generate shared coherence) combining **νf**, phase, and topology.
155
+
156
+ ---
157
+
158
+ ## Best practices
159
+
160
+ * **Short sequences** and frequent C(t) checks avoid unnecessary collapses.
161
+ * Use **dissonance** as a tool: introduce it to open possibilities, but **seal** with coherence.
162
+ * **Scale first, detail later:** tune coarse couplings before micro‑parameters.
163
+
164
+ ---
165
+
166
+ ## Project status
167
+
168
+ * **pre‑1.0 API**: signatures may be refined; concepts and magnitudes are stable.
169
+ * **Pure‑Python** core with minimal dependencies (optional: `numpy`, `matplotlib`, `networkx`).
170
+
171
+ ---
172
+
173
+ ## Contributing
174
+
175
+ Suggestions, issues, and PRs are welcome. Guidelines:
176
+
177
+ 1. Prioritize **operational clarity** (names, docstrings, examples).
178
+ 2. Add **tests** and **notebooks** that show the structural effect of each PR.
179
+ 3. Keep **semantic neutrality**: operators act on form, not on contents.
180
+
181
+ ---
182
+
183
+ ## License
184
+
185
+ MIT
186
+
187
+ ---
188
+
189
+ ## References & notes
190
+
191
+ * Theoretical foundations: TNFR operational manual.
192
+ * Operational definitions: nodal equation, dimensions (frequency, phase, form), and structural operators.
193
+
194
+ > If you use `tnfr` in research or projects, please cite the TNFR conceptual framework and link to the PyPI package.
@@ -1,14 +1,14 @@
1
1
  [project]
2
2
  name = "tnfr"
3
- version = "4.3.0"
4
- description = "Canonical TNFR: modular glyph-based dynamics on networks."
3
+ version = "4.5.1"
4
+ description = "modular structural-based dynamics on networks"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"
7
7
  license = { text = "MIT" }
8
8
  authors = [{ name = "fmg" }]
9
9
  keywords = [
10
- "TNFR", "resonant fractal", "resonance", "glyphs",
11
- "networkx", "dynamics", "coherence", "EPI", "Kuramoto"
10
+ "TNFR", "resonant fractal", "resonance", "glyphs",
11
+ "networkx", "dynamics", "coherence", "EPI", "Kuramoto"
12
12
  ]
13
13
  classifiers = [
14
14
  "Programming Language :: Python :: 3",
@@ -39,3 +39,5 @@ requires = ["setuptools>=61", "wheel"]
39
39
  build-backend = "setuptools.build_meta"
40
40
 
41
41
 
42
+
43
+
@@ -8,10 +8,10 @@ Ecuación nodal:
8
8
  ∂EPI/∂t = νf · ΔNFR(t)
9
9
  """
10
10
 
11
- __version__ = "4.3.0"
11
+ __version__ = "4.5.1"
12
12
 
13
13
  # Re-exports de la API pública
14
- from .dynamics import step, run, set_delta_nfr_hook, validate_canon
14
+ from .dynamics import step, run, set_delta_nfr_hook, validate_canon
15
15
  from .ontosim import preparar_red
16
16
  from .observers import attach_standard_observer, coherencia_global, orden_kuramoto
17
17
  from .gamma import GAMMA_REGISTRY, eval_gamma, kuramoto_R_psi
@@ -22,23 +22,44 @@ from .sense import (
22
22
  push_sigma_snapshot, sigma_series, sigma_rose,
23
23
  register_sigma_callback,
24
24
  )
25
- from .metrics import (
26
- register_metrics_callbacks,
27
- Tg_global, Tg_by_node,
28
- latency_series, glifogram_series,
29
- glyph_top, glyph_dwell_stats, export_history,
30
- )
25
+ from .metrics import (
26
+ register_metrics_callbacks,
27
+ Tg_global, Tg_by_node,
28
+ latency_series, glifogram_series,
29
+ glyph_top, glyph_dwell_stats, export_history,
30
+ )
31
+ from .operators import aplicar_remesh_red_topologico
31
32
  from .trace import register_trace
32
33
  from .program import play, seq, block, target, wait, THOL, TARGET, WAIT, ejemplo_canonico_basico
33
34
  from .cli import main as cli_main
34
35
  from .scenarios import build_graph
35
36
  from .presets import get_preset
36
37
  from .types import NodeState
38
+ from .structural import (
39
+ create_nfr,
40
+ Operador,
41
+ Emision,
42
+ Recepcion,
43
+ Coherencia,
44
+ Disonancia,
45
+ Acoplamiento,
46
+ Resonancia,
47
+ Silencio,
48
+ Expansion,
49
+ Contraccion,
50
+ Autoorganizacion,
51
+ Mutacion,
52
+ Transicion,
53
+ Recursividad,
54
+ OPERADORES,
55
+ validate_sequence,
56
+ run_sequence,
57
+ )
37
58
 
38
59
 
39
60
  __all__ = [
40
- "preparar_red",
41
- "step", "run", "set_delta_nfr_hook", "validate_canon",
61
+ "preparar_red",
62
+ "step", "run", "set_delta_nfr_hook", "validate_canon",
42
63
 
43
64
  "attach_standard_observer", "coherencia_global", "orden_kuramoto",
44
65
  "GAMMA_REGISTRY", "eval_gamma", "kuramoto_R_psi",
@@ -51,11 +72,19 @@ __all__ = [
51
72
  "register_trace",
52
73
  "Tg_global", "Tg_by_node",
53
74
  "latency_series", "glifogram_series",
54
- "glyph_top", "glyph_dwell_stats",
55
- "export_history",
75
+ "glyph_top", "glyph_dwell_stats",
76
+ "export_history",
77
+ "aplicar_remesh_red_topologico",
56
78
  "play", "seq", "block", "target", "wait", "THOL", "TARGET", "WAIT",
57
79
  "cli_main", "build_graph", "get_preset", "NodeState",
58
80
  "ejemplo_canonico_basico",
81
+ "create_nfr",
82
+ "Operador", "Emision", "Recepcion", "Coherencia", "Disonancia",
83
+ "Acoplamiento", "Resonancia", "Silencio", "Expansion", "Contraccion",
84
+ "Autoorganizacion", "Mutacion", "Transicion", "Recursividad",
85
+ "OPERADORES", "validate_sequence", "run_sequence",
59
86
  "__version__",
60
87
  ]
61
88
 
89
+
90
+
@@ -26,6 +26,7 @@ from .dynamics import step, _update_history, default_glyph_selector, parametric_
26
26
  from .gamma import GAMMA_REGISTRY
27
27
  from .scenarios import build_graph
28
28
  from .presets import get_preset
29
+ from .config import apply_config
29
30
 
30
31
 
31
32
  def _save_json(path: str, data: Any) -> None:
@@ -91,8 +92,16 @@ def _attach_callbacks(G: nx.Graph) -> None:
91
92
 
92
93
  def cmd_run(args: argparse.Namespace) -> int:
93
94
  G = build_graph(n=args.nodes, topology=args.topology, seed=args.seed)
95
+ if getattr(args, "config", None):
96
+ apply_config(G, args.config)
94
97
  _attach_callbacks(G)
95
98
  validate_canon(G)
99
+ if args.dt is not None:
100
+ G.graph["DT"] = float(args.dt)
101
+ if args.integrator is not None:
102
+ G.graph["INTEGRATOR_METHOD"] = str(args.integrator)
103
+ if getattr(args, "remesh_mode", None):
104
+ G.graph["REMESH_MODE"] = str(args.remesh_mode)
96
105
  gcanon = dict(DEFAULTS["GRAMMAR_CANON"])
97
106
  gcanon.update(_args_to_dict(args, prefix="grammar."))
98
107
  if hasattr(args, "grammar_canon") and args.grammar_canon is not None:
@@ -120,10 +129,25 @@ def cmd_run(args: argparse.Namespace) -> int:
120
129
  if args.export_history_base:
121
130
  export_history(G, args.export_history_base, fmt=args.export_format)
122
131
 
132
+ # Resúmenes rápidos (si están activados)
133
+ if G.graph.get("COHERENCE", DEFAULTS["COHERENCE"]).get("enabled", True):
134
+ Wstats = G.graph.get("history", {}).get(
135
+ G.graph.get("COHERENCE", DEFAULTS["COHERENCE"]).get("stats_history_key", "W_stats"), []
136
+ )
137
+ if Wstats:
138
+ print("[COHERENCE] último paso:", Wstats[-1])
139
+ if G.graph.get("DIAGNOSIS", DEFAULTS["DIAGNOSIS"]).get("enabled", True):
140
+ last_diag = G.graph.get("history", {}).get(
141
+ G.graph.get("DIAGNOSIS", DEFAULTS["DIAGNOSIS"]).get("history_key", "nodal_diag"), []
142
+ )
143
+ if last_diag:
144
+ sample = list(last_diag[-1].values())[:3]
145
+ print("[DIAGNOSIS] ejemplo:", sample)
146
+
123
147
  if args.summary:
124
148
  tg = Tg_global(G, normalize=True)
125
149
  lat = latency_series(G)
126
- print("Top glifos por Tg:", glyph_top(G, k=5))
150
+ print("Top operadores por Tg:", glyph_top(G, k=5))
127
151
  if lat["value"]:
128
152
  print("Latencia media:", sum(lat["value"]) / max(1, len(lat["value"])) )
129
153
  return 0
@@ -131,8 +155,16 @@ def cmd_run(args: argparse.Namespace) -> int:
131
155
 
132
156
  def cmd_sequence(args: argparse.Namespace) -> int:
133
157
  G = build_graph(n=args.nodes, topology=args.topology, seed=args.seed)
158
+ if getattr(args, "config", None):
159
+ apply_config(G, args.config)
134
160
  _attach_callbacks(G)
135
161
  validate_canon(G)
162
+ if args.dt is not None:
163
+ G.graph["DT"] = float(args.dt)
164
+ if args.integrator is not None:
165
+ G.graph["INTEGRATOR_METHOD"] = str(args.integrator)
166
+ if getattr(args, "remesh_mode", None):
167
+ G.graph["REMESH_MODE"] = str(args.remesh_mode)
136
168
  gcanon = dict(DEFAULTS["GRAMMAR_CANON"])
137
169
  gcanon.update(_args_to_dict(args, prefix="grammar."))
138
170
  if hasattr(args, "grammar_canon") and args.grammar_canon is not None:
@@ -165,8 +197,16 @@ def cmd_sequence(args: argparse.Namespace) -> int:
165
197
 
166
198
  def cmd_metrics(args: argparse.Namespace) -> int:
167
199
  G = build_graph(n=args.nodes, topology=args.topology, seed=args.seed)
200
+ if getattr(args, "config", None):
201
+ apply_config(G, args.config)
168
202
  _attach_callbacks(G)
169
203
  validate_canon(G)
204
+ if args.dt is not None:
205
+ G.graph["DT"] = float(args.dt)
206
+ if args.integrator is not None:
207
+ G.graph["INTEGRATOR_METHOD"] = str(args.integrator)
208
+ if getattr(args, "remesh_mode", None):
209
+ G.graph["REMESH_MODE"] = str(args.remesh_mode)
170
210
  G.graph.setdefault("GRAMMAR_CANON", DEFAULTS["GRAMMAR_CANON"]).update({"enabled": bool(args.grammar_canon)})
171
211
  G.graph["glyph_selector"] = default_glyph_selector if args.selector == "basic" else parametric_glyph_selector
172
212
  G.graph["GAMMA"] = {
@@ -205,10 +245,14 @@ def main(argv: Optional[List[str]] = None) -> int:
205
245
  p_run.add_argument("--steps", type=int, default=200)
206
246
  p_run.add_argument("--seed", type=int, default=1)
207
247
  p_run.add_argument("--preset", type=str, default=None)
248
+ p_run.add_argument("--config", type=str, default=None)
249
+ p_run.add_argument("--dt", type=float, default=None)
250
+ p_run.add_argument("--integrator", choices=["euler", "rk4"], default=None)
208
251
  p_run.add_argument("--save-history", dest="save_history", type=str, default=None)
209
252
  p_run.add_argument("--export-history-base", dest="export_history_base", type=str, default=None)
210
253
  p_run.add_argument("--export-format", dest="export_format", choices=["csv", "json"], default="json")
211
254
  p_run.add_argument("--summary", action="store_true")
255
+ p_run.add_argument("--remesh-mode", choices=["knn", "mst", "community"], default=None)
212
256
  p_run.add_argument("--no-canon", dest="grammar_canon", action="store_false", default=True, help="Desactiva gramática canónica")
213
257
  p_run.add_argument("--grammar.enabled", dest="grammar_enabled", type=_str2bool, default=None)
214
258
  p_run.add_argument("--grammar.zhir_requires_oz_window", dest="grammar_zhir_requires_oz_window", type=int, default=None)
@@ -230,9 +274,13 @@ def main(argv: Optional[List[str]] = None) -> int:
230
274
  p_seq.add_argument("--seed", type=int, default=1)
231
275
  p_seq.add_argument("--preset", type=str, default=None)
232
276
  p_seq.add_argument("--sequence-file", type=str, default=None)
277
+ p_seq.add_argument("--config", type=str, default=None)
278
+ p_seq.add_argument("--dt", type=float, default=None)
279
+ p_seq.add_argument("--integrator", choices=["euler", "rk4"], default=None)
233
280
  p_seq.add_argument("--save-history", dest="save_history", type=str, default=None)
234
281
  p_seq.add_argument("--export-history-base", dest="export_history_base", type=str, default=None)
235
282
  p_seq.add_argument("--export-format", dest="export_format", choices=["csv", "json"], default="json")
283
+ p_seq.add_argument("--remesh-mode", choices=["knn", "mst", "community"], default=None)
236
284
  p_seq.add_argument("--gamma-type", choices=list(GAMMA_REGISTRY.keys()), default="none")
237
285
  p_seq.add_argument("--gamma-beta", type=float, default=0.0)
238
286
  p_seq.add_argument("--gamma-R0", type=float, default=0.0)
@@ -251,12 +299,16 @@ def main(argv: Optional[List[str]] = None) -> int:
251
299
  p_met.add_argument("--topology", choices=["ring", "complete", "erdos"], default="ring")
252
300
  p_met.add_argument("--steps", type=int, default=300)
253
301
  p_met.add_argument("--seed", type=int, default=1)
302
+ p_met.add_argument("--dt", type=float, default=None)
303
+ p_met.add_argument("--integrator", choices=["euler", "rk4"], default=None)
254
304
  p_met.add_argument("--no-canon", dest="grammar_canon", action="store_false", default=True, help="Desactiva gramática canónica")
255
305
  p_met.add_argument("--selector", choices=["basic", "param"], default="basic")
256
306
  p_met.add_argument("--gamma-type", choices=list(GAMMA_REGISTRY.keys()), default="none")
257
307
  p_met.add_argument("--gamma-beta", type=float, default=0.0)
258
308
  p_met.add_argument("--gamma-R0", type=float, default=0.0)
309
+ p_met.add_argument("--remesh-mode", choices=["knn", "mst", "community"], default=None)
259
310
  p_met.add_argument("--save", type=str, default=None)
311
+ p_met.add_argument("--config", type=str, default=None)
260
312
  p_met.set_defaults(func=cmd_metrics)
261
313
 
262
314
  args = p.parse_args(argv)