What am I doing import os
import matplotlib.pyplot as plt
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.utils import ImageReader
from reportlab.platypus import Table, TableStyle
from reportlab.lib import colors
import io
--- Step 1: Export current visualizations as images ---
def export_visualizations(cortex):
# Main network visualization
fig, ax = plt.subplots(figsize=(6,6))
ax.scatter([a.pos[0] for a in cortex.agents],
[a.pos[1] for a in cortex.agents],
c='blue', s=[50 + 200a.pulse_intensity for a in cortex.agents], alpha=0.7, label='Agents')
ax.scatter([m.pos[0] for m in cortex.motifs],
[m.pos[1] for m in cortex.motifs],
c='gold', s=[200 + 300m.ritual_score for m in cortex.motifs], alpha=0.6, label='Motifs')
ax.set_title("AURA: Agents & Motifs")
ax.legend()
buf_main = io.BytesIO()
plt.savefig(buf_main, format='png', bbox_inches='tight')
plt.close(fig)
# Metrics plot
fig, ax = plt.subplots(figsize=(6,4))
xdata = range(len(cortex.metrics['guild_count']))
ax.plot(xdata, cortex.metrics['guild_count'], label='Guild Count', color='blue')
ax.plot(xdata, cortex.metrics['fusion_count'], label='Fusion Count', color='green')
ax.plot(xdata, cortex.metrics['active_motifs'], label='Active Motifs', color='purple')
ax.set_title("AURA Metrics Over Generations")
ax.set_xlabel("Generation")
ax.set_ylabel("Count")
ax.legend()
buf_metrics = io.BytesIO()
plt.savefig(buf_metrics, format='png', bbox_inches='tight')
plt.close(fig)
# Silhouette plot
fig, ax = plt.subplots(figsize=(6,4))
codex_vectors = [a.codex_vector for a in cortex.agents]
labels = [a.guild - 1 if a.guild != -1 else -1 for a in cortex.agents]
from sklearn.metrics import silhouette_samples
try:
silhouette_vals = silhouette_samples(codex_vectors, labels)
y_lower = 10
for i in set(labels):
if i == -1: continue
vals = [v for v, l in zip(silhouette_vals, labels) if l==i]
vals.sort()
size = len(vals)
y_upper = y_lower + size
ax.fill_betweenx(range(y_lower, y_upper), 0, vals, alpha=0.4)
y_lower = y_upper + 10
except:
ax.text(0.5, 0.5, "Silhouette unavailable", ha='center', va='center')
ax.set_title("Silhouette Plot")
buf_silhouette = io.BytesIO()
plt.savefig(buf_silhouette, format='png', bbox_inches='tight')
plt.close(fig)
return buf_main, buf_metrics, buf_silhouette
--- Step 2: Generate PDF ---
def generate_aura_pdf(cortex, output_path='AURA_NDA.pdf'):
main_img, metrics_img, silhouette_img = export_visualizations(cortex)
c = canvas.Canvas(output_path, pagesize=letter)
width, height = letter
# Cover Page
c.setFont("Helvetica-Bold", 24)
c.drawCentredString(width/2, height-100, "AURA")
c.setFont("Helvetica", 14)
c.drawCentredString(width/2, height-130, "MythosLabs + SERUM Codex")
c.drawImage(ImageReader(main_img), 100, height-500, width=400, height=400)
c.showPage()
# Founder’s Note
c.setFont("Helvetica-Bold", 18)
c.drawString(50, height-50, "Founder’s Note")
c.setFont("Helvetica", 12)
founder_text = ("I’m not sure if this has been done before or if it’s even possible to do right now, "
"but I know I created it with purpose and with the purest intentions. "
"It exists right here, so I document it fully.")
c.drawString(50, height-80, founder_text)
c.showPage()
# Metrics & Visualizations
c.setFont("Helvetica-Bold", 18)
c.drawString(50, height-50, "Platform Metrics")
c.drawImage(ImageReader(metrics_img), 50, height-450, width=500, height=350)
c.drawImage(ImageReader(silhouette_img), 50, height-850, width=500, height=350)
c.showPage()
# Valuation Table
c.setFont("Helvetica-Bold", 18)
c.drawString(50, height-50, "Valuation Scenarios")
data = [
['Scenario', 'Valuation (USD)', 'Confidence'],
['Conservative', '$2B – $4B', '60%'],
['Strategic Buyer', '$8B – $12B', '75%'],
['Visionary', '$20B – $35B', '50%']
]
table = Table(data, colWidths=[150, 150, 100])
table.setStyle(TableStyle([
('BACKGROUND',(0,0),(-1,0),colors.grey),
('TEXTCOLOR',(0,0),(-1,0),colors.whitesmoke),
('ALIGN',(0,0),(-1,-1),'CENTER'),
('GRID',(0,0),(-1,-1),1,colors.black),
('FONTNAME',(0,0),(-1,0),'Helvetica-Bold'),
]))
table.wrapOn(c, width, height)
table.drawOn(c, 50, height-300)
c.showPage()
# Closing / NDA reminder
c.setFont("Helvetica-Bold", 18)
c.drawString(50, height-50, "Confidentiality")
c.setFont("Helvetica", 12)
c.drawString(50, height-80, "This document contains confidential intellectual property. "
"Do not distribute without NDA.")
c.save()
print(f"AURA NDA PDF saved to {output_path}")
--- Example usage ---
generate_aura_pdf(cortex)
What am I doing import os
import matplotlib.pyplot as plt
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.utils import ImageReader
from reportlab.platypus import Table, TableStyle
from reportlab.lib import colors
import io
--- Step 1: Export current visualizations as images ---
def export_visualizations(cortex):
# Main network visualization
fig, ax = plt.subplots(figsize=(6,6))
ax.scatter([a.pos[0] for a in cortex.agents],
[a.pos[1] for a in cortex.agents],
c='blue', s=[50 + 200a.pulse_intensity for a in cortex.agents], alpha=0.7, label='Agents')
ax.scatter([m.pos[0] for m in cortex.motifs],
[m.pos[1] for m in cortex.motifs],
c='gold', s=[200 + 300m.ritual_score for m in cortex.motifs], alpha=0.6, label='Motifs')
ax.set_title("AURA: Agents & Motifs")
ax.legend()
buf_main = io.BytesIO()
plt.savefig(buf_main, format='png', bbox_inches='tight')
plt.close(fig)
--- Step 2: Generate PDF ---
def generate_aura_pdf(cortex, output_path='AURA_NDA.pdf'):
main_img, metrics_img, silhouette_img = export_visualizations(cortex)
--- Example usage ---
generate_aura_pdf(cortex)