tnfr 1.0__py3-none-any.whl → 3.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.

tnfr/utils/helpers.py DELETED
@@ -1,357 +0,0 @@
1
- from tnfr.matrix.operators import aplicar_glifo
2
- from tnfr.constants import glifo_categoria
3
- import numpy as np
4
-
5
- def emergencia_nodal(nodo, media_vf, std_dNFR):
6
- return nodo["νf"] > media_vf * 0.9 and abs(nodo["ΔNFR"]) < std_dNFR
7
-
8
- def promover_emergente(nodo_id, G, paso, historial_glifos_por_nodo, historia_glifos):
9
- if nodo_id not in G:
10
- return
11
- nodo = G.nodes[nodo_id]
12
-
13
- # Asegurarse de que tiene valores previos
14
- if "EPI_prev" not in nodo:
15
- nodo["EPI_prev"] = nodo["EPI"] if np.isfinite(nodo["EPI"]) else 1.0
16
- if "θ_prev" not in nodo:
17
- nodo["θ_prev"] = nodo["θ"]
18
-
19
- # Evaluar glifo emergente canónico
20
- if abs(nodo["EPI"] - nodo["EPI_prev"]) < 0.01 and abs(nodo["ΔNFR"]) < 0.05:
21
- glifo = "REMESH"
22
- elif abs(nodo.get("θ", 0) - nodo.get("θ_prev", 0)) > 0.2:
23
- glifo = "ZHIR"
24
- elif nodo.get("Si", 0) > 0.8 and nodo.get("glifo") == "UM":
25
- glifo = "RA"
26
- else:
27
- glifo = "THOL"
28
-
29
- aplicar_glifo(G, nodo, nodo_id, glifo, historial_glifos_por_nodo, paso)
30
- historia_glifos.append(f"{paso},{nodo_id},{glifo}")
31
- nodo["glifo"] = glifo
32
- nodo["categoria"] = glifo_categoria.get(glifo, "ninguna")
33
-
34
- def detectar_nodos_pulsantes(historial_glifos_por_nodo, min_ciclos=3):
35
- nodos_maestros = []
36
- for nodo_id, eventos in historial_glifos_por_nodo.items():
37
- glifos = [g for _, g in eventos]
38
- ciclos = 0
39
- for i in range(len(glifos) - 1):
40
- if glifos[i] == "VAL" and glifos[i+1] == "NUL":
41
- ciclos += 1
42
- if ciclos >= min_ciclos:
43
- nodos_maestros.append(nodo_id)
44
- return nodos_maestros
45
-
46
- def detectar_macronodos(G, historial_glifos_por_nodo, epi_compuestas, paso, umbral_coherencia=0.05, visualizar=True):
47
- historial_macronodos = []
48
- candidatos = []
49
- for n in list(G.nodes):
50
- historial = historial_glifos_por_nodo.get(n, [])
51
- if len(historial) >= 5:
52
- glifos_ultimos = [g for _, g in historial[-5:]]
53
- candidatos.append((n, glifos_ultimos))
54
-
55
- grupos = []
56
- visitados = set()
57
- for n1, glifos1 in candidatos:
58
- if n1 in visitados:
59
- continue
60
- grupo = [n1]
61
- for n2, glifos2 in candidatos:
62
- if n1 == n2 or n2 in visitados:
63
- continue
64
- if glifos1 == glifos2:
65
- nodo1, nodo2 = G.nodes[n1], G.nodes[n2]
66
- if abs(nodo1["θ"] - nodo2["θ"]) < 0.1 and abs(nodo1["EPI"] - nodo2["EPI"]) < umbral_coherencia:
67
- grupo.append(n2)
68
- if len(grupo) >= 4:
69
- grupos.append(grupo)
70
- visitados.update(grupo)
71
-
72
- log_macros = []
73
- nuevos_nodos = []
74
- conexiones = []
75
-
76
- for idx, grupo in enumerate(grupos):
77
- # Determinar glifo predominante
78
- glifos_grupo = []
79
- for nodo in grupo:
80
- glifos_grupo += [g for _, g in historial_glifos_por_nodo.get(nodo, [])]
81
- if glifos_grupo:
82
- glifo_predominante = max(set(glifos_grupo), key=glifos_grupo.count)
83
- else:
84
- glifo_predominante = "X"
85
-
86
- # Determinar EPI media categorizada
87
- macro_epi = np.mean([G.nodes[n]["EPI"] for n in grupo])
88
- if macro_epi > 2.0:
89
- epi_cat = "H"
90
- elif macro_epi > 1.2:
91
- epi_cat = "M"
92
- else:
93
- epi_cat = "L"
94
-
95
- nombre_macro = f"M_{glifo_predominante}_{epi_cat}_{idx:02d}"
96
-
97
- macro_epi = np.mean([G.nodes[n]["EPI"] for n in grupo])
98
- macro_vf = np.mean([G.nodes[n]["νf"] for n in grupo])
99
- macro_Si = np.mean([G.nodes[n]["Si"] for n in grupo])
100
- macro_theta = np.mean([G.nodes[n]["θ"] for n in grupo])
101
-
102
- nuevo_id = f"{nombre_macro}_N"
103
- nuevos_nodos.append((nuevo_id, {
104
- "EPI": macro_epi,
105
- "νf": macro_vf,
106
- "Si": macro_Si,
107
- "θ": macro_theta,
108
- "ΔNFR": 0.01,
109
- "glifo": "NAV",
110
- "estado": "activo",
111
- "macro": nombre_macro
112
- }))
113
-
114
- for nodo_id in grupo:
115
- historial_glifos_por_nodo[nodo_id].append((paso, 13)) # REMESH
116
- G.nodes[nodo_id]["_marcar_para_remover"] = True
117
-
118
- historial_glifos_por_nodo[nuevo_id] = [
119
- (paso, "REMESH"),
120
- (paso, "UM"),
121
- (paso, "THOL")
122
- ]
123
-
124
- for otro in list(G.nodes):
125
- if otro == nuevo_id:
126
- continue
127
- if G.nodes[otro].get("_marcar_para_remover"):
128
- continue
129
- nodo_o = G.nodes[otro]
130
- condiciones = [
131
- abs(nodo_o.get("θ", 0) - macro_theta) < 0.1,
132
- abs(nodo_o.get("EPI", 0) - macro_epi) < 0.2,
133
- abs(nodo_o.get("νf", 0) - macro_vf) < 0.15,
134
- abs(nodo_o.get("Si", 0) - macro_Si) < 0.2
135
- ]
136
- if sum(condiciones) >= 3:
137
- conexiones.append((nuevo_id, otro))
138
-
139
- log_macros.append({
140
- "entidad": nombre_macro,
141
- "paso": G.graph.get("paso_actual", "NA"),
142
- "nodo": nuevo_id,
143
- "EPI": round(macro_epi, 3),
144
- "νf": round(macro_vf, 3),
145
- "Si": round(macro_Si, 3),
146
- "θ": round(macro_theta, 3),
147
- "subnodos": grupo
148
- })
149
-
150
- for entrada in epi_compuestas:
151
- paso = entrada["paso"]
152
- glifo = entrada["glifo"]
153
- nodos = entrada["nodos"]
154
-
155
- for nodo in nodos:
156
- historial_macronodos.append({
157
- "paso": paso,
158
- "glifo": glifo,
159
- "miembros": nodos
160
- })
161
-
162
- for n_id in list(G.nodes):
163
- if G.nodes[n_id].get("_marcar_para_remover"):
164
- G.remove_node(n_id)
165
-
166
- for nuevo_id, attr in nuevos_nodos:
167
- G.add_node(nuevo_id, **attr)
168
-
169
- for a, b in conexiones:
170
- G.add_edge(a, b)
171
-
172
- # Asegurar que todos los nodos tienen los atributos necesarios
173
- atributos_defecto = {
174
- "estado": "latente",
175
- "EPI": 1.0,
176
- "νf": 1.0,
177
- "Si": 0.5,
178
- "θ": 0.0,
179
- "ΔNFR": 0.0,
180
- "glifo": "NAV",
181
- "categoria": "ninguna"
182
- }
183
-
184
- for n in G.nodes:
185
- for k, v in atributos_defecto.items():
186
- if k not in G.nodes[n]:
187
- G.nodes[n][k] = v
188
-
189
- macronodes_info = {
190
- 'nodos': [nuevo_id for nuevo_id, _ in nuevos_nodos],
191
- 'conexiones': conexiones
192
- }
193
-
194
- return historial_macronodos, macronodes_info
195
-
196
- def algo_se_mueve(G, historial_glifos_por_nodo, paso, umbral=0.01):
197
- for nodo in G.nodes:
198
- datos = G.nodes[nodo]
199
-
200
- if datos.get("estado") == "activo":
201
- return True # hay actividad
202
-
203
- # Comparar cambio reciente de EPI
204
- epi_actual = datos.get("EPI", 0)
205
- epi_anterior = datos.get("EPI_prev", epi_actual)
206
- if abs(epi_actual - epi_anterior) > umbral:
207
- return True
208
-
209
- # Si hay glifos recientes cambiando
210
- historial = historial_glifos_por_nodo.get(nodo, [])
211
- if len(historial) >= 5:
212
- glifos_ultimos = [g for _, g in historial[-5:]]
213
- if len(set(glifos_ultimos)) > 1:
214
- return True
215
-
216
- return False
217
-
218
- def extraer_dinamica_si(G_historia):
219
- historia_si = []
220
- for paso, G in enumerate(G_historia):
221
- paso_data = []
222
- for n in G.nodes:
223
- paso_data.append({
224
- "nodo": n,
225
- "paso": paso,
226
- "Si": round(G.nodes[n]["Si"], 3)
227
- })
228
- historia_si.append(paso_data)
229
- return historia_si
230
-
231
- def evaluar_si_nodal(nodo, paso=None):
232
- # Factor de estructura vibratoria
233
- vf = nodo.get("νf", 1.0)
234
- dNFR = nodo.get("ΔNFR", 0.0)
235
- theta = nodo.get("θ", 0.5)
236
-
237
- # Glifo actual
238
- glifo = nodo.get("glifo", "ninguno")
239
-
240
- # Peso estructural simbólico del glifo
241
- pesos_glifo = {
242
- "AL": 1.0,
243
- "EN": 1.1,
244
- "IL": 1.3,
245
- "OZ": 0.6,
246
- "UM": 1.2,
247
- "RA": 1.5,
248
- "SHA": 0.4,
249
- "VAL": 1.4,
250
- "NUL": 0.8,
251
- "THOL": 1.6,
252
- "ZHIR": 1.7,
253
- "NAV": 1.0,
254
- "REMESH": 1.3,
255
- "ninguno": 1.0
256
- }
257
- k_glifo = pesos_glifo.get(glifo, 1.0)
258
-
259
- # Cálculo de Si resonante
260
- Si_nuevo = round((vf / (1 + abs(dNFR))) * k_glifo * theta, 3)
261
-
262
- # Asignar al nodo
263
- nodo["Si"] = Si_nuevo
264
-
265
- if paso is not None:
266
- if "historial_Si" not in nodo:
267
- nodo["historial_Si"] = []
268
- nodo["historial_Si"].append((paso, Si_nuevo))
269
-
270
- return Si_nuevo
271
-
272
- def reciente_glifo(nodo_id, glifo_objetivo, historial, pasos=5):
273
- eventos = historial.get(nodo_id, [])
274
- if not eventos:
275
- return False
276
- try:
277
- ultimo_paso = int(eventos[-1][0])
278
- except (ValueError, TypeError):
279
- return False
280
- return any(
281
- g == glifo_objetivo and int(p) >= ultimo_paso - pasos
282
- for p, g in eventos[-(pasos+1):]
283
- )
284
-
285
- def obtener_nodos_emitidos(G):
286
- if len(G.nodes) == 0:
287
- return [], []
288
-
289
- # Extraer nodos emitidos por coherencia estructural
290
- emitidos_final = [
291
- n for n in G.nodes
292
- if G.nodes[n]["glifo"] != "ninguno"
293
- and G.nodes[n].get("categoria", "ninguna") not in ["sin categoría", "ninguna"]
294
- ]
295
-
296
- # Generar resultado detallado con información completa
297
- resultado_detallado = []
298
- for n in emitidos_final:
299
- nodo = G.nodes[n]
300
- entrada = {
301
- "nodo": n,
302
- "glifo": nodo["glifo"],
303
- "EPI": round(nodo["EPI"], 4),
304
- "Si": round(nodo.get("Si", 0), 4),
305
- "ΔNFR": round(nodo.get("ΔNFR", 0), 4),
306
- "θ": round(nodo.get("θ", 0), 4),
307
- "νf": round(nodo.get("νf", 1.0), 4),
308
- "categoria": nodo.get("categoria", "ninguna")
309
- }
310
- resultado_detallado.append(entrada)
311
-
312
- return emitidos_final, resultado_detallado
313
-
314
- def exportar_nodos_emitidos(G, emitidos_final=None, archivo='nodos_emitidos.json'):
315
- try:
316
- # Obtener nodos emitidos si no se proporcionan
317
- if emitidos_final is None:
318
- emitidos_final, _ = obtener_nodos_emitidos(G)
319
-
320
- if not emitidos_final:
321
- return {
322
- 'exitosa': False,
323
- 'razon': 'No hay nodos emitidos para exportar',
324
- 'nodos_exportados': 0
325
- }
326
-
327
- return {
328
- 'exitosa': True,
329
- 'archivo': archivo,
330
- 'nodos_exportados': len(emitidos_final)
331
- }
332
-
333
- except Exception as e:
334
- return {
335
- 'exitosa': False,
336
- 'razon': f"Error durante exportación: {str(e)}",
337
- 'nodos_exportados': 0
338
- }
339
-
340
- def crear_diccionario_nodos_emitidos(emitidos_final):
341
- return {n: True for n in emitidos_final}
342
-
343
- # Al final del archivo
344
- __all__ = [
345
- 'emergencia_nodal',
346
- 'promover_emergente',
347
- 'detectar_nodos_pulsantes',
348
- 'detectar_macronodos',
349
- 'algo_se_mueve',
350
- 'obtener_nodos_emitidos',
351
- 'evaluar_si_nodal',
352
- 'reciente_glifo',
353
- 'algo_se_mueve',
354
- 'extraer_dinamica_si',
355
- 'exportar_nodos_emitidos',
356
- 'crear_diccionario_nodos_emitidos'
357
- ]
@@ -1,95 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: tnfr
3
- Version: 1.0
4
- Summary: TNFR
5
- Author-email: "F.F. Martinez Gamo" <fmartinezgamo@gmail.com>
6
- License: MIT
7
- Project-URL: Homepage, https://fermga.github.io/Teoria-de-la-naturaleza-fractal-resonante-TNFR-/
8
- Project-URL: Repository, https://github.com/fermga/Teoria-de-la-naturaleza-fractal-resonante-TNFR-
9
- Keywords: tnfr,fractal,resonance,symbolic,emergence,coherence
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Intended Audience :: Science/Research
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Topic :: Scientific/Engineering
20
- Requires-Python: >=3.8
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE.txt
23
- Requires-Dist: networkx>=2.8
24
- Requires-Dist: numpy>=1.21.0
25
- Requires-Dist: pandas>=1.3.0
26
- Requires-Dist: matplotlib>=3.5.0
27
- Provides-Extra: dev
28
- Requires-Dist: pytest>=7.0; extra == "dev"
29
- Requires-Dist: pytest-cov; extra == "dev"
30
- Requires-Dist: black; extra == "dev"
31
- Requires-Dist: flake8; extra == "dev"
32
- Requires-Dist: mypy; extra == "dev"
33
- Provides-Extra: docs
34
- Requires-Dist: sphinx>=4.0; extra == "docs"
35
- Requires-Dist: sphinx-rtd-theme; extra == "docs"
36
- Dynamic: license-file
37
-
38
- # TNFR - Teoría de la naturaleza fractal resonante
39
-
40
- **TNFR** is a Python package implementing the Teoría de la naturaleza fractal resonante (TNFR), a paradigm for modeling and simulating complex emergent systems based on structural coherence and resonant dynamics.
41
-
42
- ---
43
-
44
- ## What is TNFR?
45
-
46
- TNFR provides a computational framework for studying how complex, self-organizing structures arise from simple interactions. Inspired by natural systems—such as biological networks, physical resonances, and social dynamics—TNFR models systems as networks of nodes with evolving structural properties.
47
-
48
- ---
49
-
50
- ## Key Features
51
-
52
- - **Structural Coherence Modeling:**
53
- - Each node in a TNFR network is characterized by parameters such as structural coherence (EPI), resonant frequency (νf), sense index (Si), and structural threshold (θ).
54
- - **Emergent Dynamics Simulation:**
55
- - The package allows you to simulate the evolution of networks over time, capturing how local interactions and transformations lead to global patterns and behaviors.
56
- - **Symbolic Transformations (Glyphs):**
57
- - TNFR includes a system of symbolic transformations (glyphs) that modify node properties, enabling the study of processes like emergence, mutation, resonance, and self-organization.
58
- - **Adaptive Thresholds and Bifurcations:**
59
- - The framework supports dynamic threshold calculations and the detection of structural bifurcations, allowing for the exploration of phase transitions and critical phenomena.
60
- - **Flexible Analysis and Export:**
61
- - TNFR provides tools for analyzing network evolution, detecting emergent patterns, and exporting results for further study.
62
-
63
- ---
64
-
65
- ## Who is TNFR for?
66
-
67
- - **Researchers in complex systems, artificial intelligence, and network science**
68
- - **Developers interested in novel paradigms for modeling and simulation**
69
- - **Anyone curious about the principles of emergence, self-organization, and resonance in natural and artificial systems**
70
-
71
- ---
72
-
73
- ## Installation
74
-
75
- ```bash
76
- pip install tnfr
77
- ```
78
-
79
- ---
80
-
81
- ## Documentation
82
-
83
- For detailed documentation and API reference, see the TNFR Documentation.
84
-
85
- ---
86
-
87
- ## License
88
-
89
- TNFR is released under the MIT License
90
-
91
- ---
92
-
93
- Explore the fractal-resonant nature of complex systems with a new computational paradigm.
94
- https://github.com/fermga/Teoria-de-la-naturaleza-fractal-resonante-TNFR-
95
- https://fermga.github.io/Teoria-de-la-naturaleza-fractal-resonante-TNFR-/
tnfr-1.0.dist-info/RECORD DELETED
@@ -1,14 +0,0 @@
1
- core/ontosim.py,sha256=yqtN33wchxhDh2te5gcOkb6mVBUwqTHJvxSo_626A9I,30540
2
- matrix/operators.py,sha256=VJejtvF1s6pj60y1OPenFf7QN1ZJna_7Z27QyLUtQJg,16858
3
- tnfr/__init__.py,sha256=m1Bpzon78OtHcVucc-bcWLmQiKyaCJaBuOh9dbPdvso,1080
4
- tnfr/constants.py,sha256=BC7t3lbhdYUyxyEoTXs4Aj-Ib_kD9mQNoEDGOUGESTE,315
5
- tnfr/core/ontosim.py,sha256=xhT-YK6jHnGKRFpeJqfGA_nnmOyD5GsI0tyh2KAgIxI,43621
6
- tnfr/matrix/operators.py,sha256=-a1sXXKNT_NyWuOghakI3eYSQkkv4LudPozG7ejdOxo,16903
7
- tnfr/resonance/dynamics.py,sha256=OW4-MoZFhgUBa5rLMoGt9bZHLoDoNqlEISKQZYgZLYA,56313
8
- tnfr/utils/helpers.py,sha256=KzFWTVd1VmXypnYsQ85Ltj3Aeqq7eGwIMWsNV88r1UU,11399
9
- tnfr-1.0.dist-info/licenses/LICENSE.txt,sha256=xTjBNhy3N8pomFljrCkD1d34SmAEWv8hyJMMOjNMH0M,1071
10
- tnfr-1.0.dist-info/METADATA,sha256=ylv51bRdUt1BESO2LB3T3XtnKBx_L7MXQ5E7_SHx9H4,3953
11
- tnfr-1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- tnfr-1.0.dist-info/entry_points.txt,sha256=IOtR5J0S4TH9yJ5waYWCw-y7yiKvNiDeu0YcaCw2UiM,48
13
- tnfr-1.0.dist-info/top_level.txt,sha256=eIPBHPa6ClW75HadoaFllMXaYg6N4cKANYWNz4zWoyg,17
14
- tnfr-1.0.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- tnfr-simulate = tnfr.cli:main
@@ -1,3 +0,0 @@
1
- core
2
- matrix
3
- tnfr
File without changes