Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,12 +8,12 @@ import networkx as nx
|
|
| 8 |
def generate_potentiality_matrix(sequence_length):
|
| 9 |
"""
|
| 10 |
Visualizes the "Prime Potentiality" by aligning the integer stream to Mod 10.
|
| 11 |
-
1, 3, 7, 9 are the 'Active Lanes' (Rivers)
|
| 12 |
"""
|
| 13 |
-
# 1. Create the Integer Stream
|
| 14 |
integers = np.arange(sequence_length)
|
| 15 |
|
| 16 |
-
# 2. Mod 10 Alignment (The "Natural" Width
|
| 17 |
width = 10
|
| 18 |
rows = int(np.ceil(sequence_length / width))
|
| 19 |
|
|
@@ -22,21 +22,18 @@ def generate_potentiality_matrix(sequence_length):
|
|
| 22 |
padded_ints = np.pad(integers, (0, padded_len - len(integers)), mode='constant')
|
| 23 |
|
| 24 |
# 3. Calculate "Potentiality" (The Heat)
|
| 25 |
-
# 0.0 = Ground State (Even/5s - Composite)
|
| 26 |
-
# 0.2 = Potential Lane (Odd Composite in 1,3,7,9)
|
| 27 |
-
# 1.0 = Kinetic Signal (Actual Prime)
|
| 28 |
matrix_values = np.zeros(padded_len)
|
| 29 |
|
| 30 |
for i, val in enumerate(padded_ints):
|
| 31 |
-
|
| 32 |
-
if sympy.isprime(
|
| 33 |
matrix_values[i] = 1.0 # Kinetic Signal (Prime)
|
| 34 |
-
elif
|
| 35 |
matrix_values[i] = 0.0 # Ground State (Composite)
|
| 36 |
else:
|
| 37 |
matrix_values[i] = 0.2 # Potential Energy (Odd Composite in Prime Lane)
|
| 38 |
|
| 39 |
-
# Reshape to Mod 10 Grid
|
| 40 |
grid = matrix_values.reshape(rows, width)
|
| 41 |
|
| 42 |
# 4. Visualization
|
|
@@ -53,11 +50,11 @@ def generate_potentiality_matrix(sequence_length):
|
|
| 53 |
))
|
| 54 |
|
| 55 |
fig.update_layout(
|
| 56 |
-
title=f"Prime Potentiality Rivers (Mod 10
|
| 57 |
xaxis_title="Modulus 10 Residue (Last Digit)",
|
| 58 |
yaxis_title="Sequence Depth (Time)",
|
| 59 |
template="plotly_dark",
|
| 60 |
-
yaxis=dict(autorange="reversed"), # Stream flows down
|
| 61 |
height=800
|
| 62 |
)
|
| 63 |
return fig
|
|
@@ -71,7 +68,6 @@ def visualize_prime_matroska(shells, show_feed):
|
|
| 71 |
fig = go.Figure()
|
| 72 |
|
| 73 |
# 1. Draw the "Prime Vectors" (Spokes)
|
| 74 |
-
# These are the rails the data travels on based on the Mod 10 index
|
| 75 |
max_radius = shells * 10
|
| 76 |
for i in range(10):
|
| 77 |
angle = (2 * np.pi * i) / 10
|
|
@@ -80,7 +76,6 @@ def visualize_prime_matroska(shells, show_feed):
|
|
| 80 |
color = "#00ffea" if is_prime_lane else "#333"
|
| 81 |
width = 2 if is_prime_lane else 1
|
| 82 |
|
| 83 |
-
# Draw the vector spoke
|
| 84 |
fig.add_trace(go.Scatter(
|
| 85 |
x=[0, max_radius * np.cos(angle)],
|
| 86 |
y=[0, max_radius * np.sin(angle)],
|
|
@@ -91,7 +86,6 @@ def visualize_prime_matroska(shells, show_feed):
|
|
| 91 |
))
|
| 92 |
|
| 93 |
# 2. Draw the Concentric Shells (Domains)
|
| 94 |
-
# These represent the Nested Matroska Layers
|
| 95 |
for layer in range(1, shells + 1):
|
| 96 |
radius = layer * 10
|
| 97 |
t = np.linspace(0, 2*np.pi, 100)
|
|
@@ -106,17 +100,15 @@ def visualize_prime_matroska(shells, show_feed):
|
|
| 106 |
showlegend=False
|
| 107 |
))
|
| 108 |
|
| 109 |
-
# 3. Simulate "
|
| 110 |
-
# Data atoms only inhabit the Prime Potentiality Vectors (1, 3, 7, 9)
|
| 111 |
if show_feed:
|
| 112 |
for p_mod in [1, 3, 7, 9]:
|
| 113 |
p_angle = (2 * np.pi * p_mod) / 10
|
| 114 |
-
# Add 'Data' markers at the intersection of Shells and Prime Vectors
|
| 115 |
fig.add_trace(go.Scatter(
|
| 116 |
x=[radius * np.cos(p_angle)],
|
| 117 |
y=[radius * np.sin(p_angle)],
|
| 118 |
mode='markers',
|
| 119 |
-
marker=dict(size=6, color='#ff0055'), # Red = Hot Data
|
| 120 |
showlegend=False
|
| 121 |
))
|
| 122 |
|
|
@@ -132,11 +124,11 @@ def visualize_prime_matroska(shells, show_feed):
|
|
| 132 |
|
| 133 |
# --- THE INTERFACE ---
|
| 134 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
| 135 |
-
gr.Markdown("# LOGOS: Prime-Indexed Topology
|
| 136 |
gr.Markdown("Interactive architectural validation for **Mod 10 Potentiality Rivers** and the **Radial Matroska Network**.")
|
| 137 |
|
| 138 |
with gr.Tab("Prime Potentiality (Mod 10)"):
|
| 139 |
-
gr.Markdown("
|
| 140 |
seq_len = gr.Slider(100, 10000, value=2500, label="Stream Depth")
|
| 141 |
matrix_plot = gr.Plot(label="Potentiality Matrix")
|
| 142 |
btn_matrix = gr.Button("Generate Matrix")
|
|
@@ -152,6 +144,6 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
| 152 |
btn_net = gr.Button("Build Topology")
|
| 153 |
btn_net.click(visualize_prime_matroska, inputs=[shells_slider, feed_toggle], outputs=matroska_plot)
|
| 154 |
|
| 155 |
-
# ---
|
| 156 |
-
|
| 157 |
-
demo.launch(ssr_mode=False)
|
|
|
|
| 8 |
def generate_potentiality_matrix(sequence_length):
|
| 9 |
"""
|
| 10 |
Visualizes the "Prime Potentiality" by aligning the integer stream to Mod 10.
|
| 11 |
+
1, 3, 7, 9 are the 'Active Lanes' (Rivers).
|
| 12 |
"""
|
| 13 |
+
# 1. Create the Integer Stream
|
| 14 |
integers = np.arange(sequence_length)
|
| 15 |
|
| 16 |
+
# 2. Mod 10 Alignment (The "Natural" Width)
|
| 17 |
width = 10
|
| 18 |
rows = int(np.ceil(sequence_length / width))
|
| 19 |
|
|
|
|
| 22 |
padded_ints = np.pad(integers, (0, padded_len - len(integers)), mode='constant')
|
| 23 |
|
| 24 |
# 3. Calculate "Potentiality" (The Heat)
|
|
|
|
|
|
|
|
|
|
| 25 |
matrix_values = np.zeros(padded_len)
|
| 26 |
|
| 27 |
for i, val in enumerate(padded_ints):
|
| 28 |
+
val = int(val)
|
| 29 |
+
if sympy.isprime(val) and val > 5:
|
| 30 |
matrix_values[i] = 1.0 # Kinetic Signal (Prime)
|
| 31 |
+
elif val % 2 == 0 or val % 5 == 0:
|
| 32 |
matrix_values[i] = 0.0 # Ground State (Composite)
|
| 33 |
else:
|
| 34 |
matrix_values[i] = 0.2 # Potential Energy (Odd Composite in Prime Lane)
|
| 35 |
|
| 36 |
+
# Reshape to Mod 10 Grid
|
| 37 |
grid = matrix_values.reshape(rows, width)
|
| 38 |
|
| 39 |
# 4. Visualization
|
|
|
|
| 50 |
))
|
| 51 |
|
| 52 |
fig.update_layout(
|
| 53 |
+
title=f"Prime Potentiality Rivers (Mod 10)",
|
| 54 |
xaxis_title="Modulus 10 Residue (Last Digit)",
|
| 55 |
yaxis_title="Sequence Depth (Time)",
|
| 56 |
template="plotly_dark",
|
| 57 |
+
yaxis=dict(autorange="reversed"), # Stream flows down
|
| 58 |
height=800
|
| 59 |
)
|
| 60 |
return fig
|
|
|
|
| 68 |
fig = go.Figure()
|
| 69 |
|
| 70 |
# 1. Draw the "Prime Vectors" (Spokes)
|
|
|
|
| 71 |
max_radius = shells * 10
|
| 72 |
for i in range(10):
|
| 73 |
angle = (2 * np.pi * i) / 10
|
|
|
|
| 76 |
color = "#00ffea" if is_prime_lane else "#333"
|
| 77 |
width = 2 if is_prime_lane else 1
|
| 78 |
|
|
|
|
| 79 |
fig.add_trace(go.Scatter(
|
| 80 |
x=[0, max_radius * np.cos(angle)],
|
| 81 |
y=[0, max_radius * np.sin(angle)],
|
|
|
|
| 86 |
))
|
| 87 |
|
| 88 |
# 2. Draw the Concentric Shells (Domains)
|
|
|
|
| 89 |
for layer in range(1, shells + 1):
|
| 90 |
radius = layer * 10
|
| 91 |
t = np.linspace(0, 2*np.pi, 100)
|
|
|
|
| 100 |
showlegend=False
|
| 101 |
))
|
| 102 |
|
| 103 |
+
# 3. Simulate "Data Atoms" residing in the shell
|
|
|
|
| 104 |
if show_feed:
|
| 105 |
for p_mod in [1, 3, 7, 9]:
|
| 106 |
p_angle = (2 * np.pi * p_mod) / 10
|
|
|
|
| 107 |
fig.add_trace(go.Scatter(
|
| 108 |
x=[radius * np.cos(p_angle)],
|
| 109 |
y=[radius * np.sin(p_angle)],
|
| 110 |
mode='markers',
|
| 111 |
+
marker=dict(size=6, color='#ff0055'), # Red = Hot Data
|
| 112 |
showlegend=False
|
| 113 |
))
|
| 114 |
|
|
|
|
| 124 |
|
| 125 |
# --- THE INTERFACE ---
|
| 126 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
| 127 |
+
gr.Markdown("# LOGOS: Prime-Indexed Topology")
|
| 128 |
gr.Markdown("Interactive architectural validation for **Mod 10 Potentiality Rivers** and the **Radial Matroska Network**.")
|
| 129 |
|
| 130 |
with gr.Tab("Prime Potentiality (Mod 10)"):
|
| 131 |
+
gr.Markdown("The vertical 'Rivers' of prime potential (1, 3, 7, 9) vs the Composite banks.")
|
| 132 |
seq_len = gr.Slider(100, 10000, value=2500, label="Stream Depth")
|
| 133 |
matrix_plot = gr.Plot(label="Potentiality Matrix")
|
| 134 |
btn_matrix = gr.Button("Generate Matrix")
|
|
|
|
| 144 |
btn_net = gr.Button("Build Topology")
|
| 145 |
btn_net.click(visualize_prime_matroska, inputs=[shells_slider, feed_toggle], outputs=matroska_plot)
|
| 146 |
|
| 147 |
+
# --- CRITICAL FIX: SSR DISABLED ---
|
| 148 |
+
if __name__ == "__main__":
|
| 149 |
+
demo.launch(ssr_mode=False)
|