-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_notebook.py
More file actions
33 lines (27 loc) · 966 Bytes
/
fix_notebook.py
File metadata and controls
33 lines (27 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import json
# Load the notebook
with open('Fibonacci_Hashing_Demo.ipynb', 'r') as f:
nb = json.load(f)
# Find and fix the imports cell
for cell in nb['cells']:
if cell['cell_type'] == 'code':
source = ''.join(cell['source'])
if 'import subprocess' in source:
# This is the imports cell - remove unused imports
new_source = """import json
import time
import numpy as np
import matplotlib.pyplot as plt
from collections import Counter
from pathlib import Path
# Fibonacci hashing constant
FIB_HASH_64_MAGIC = 11400714819323198485
print("✓ Imports successful")
print(f"✓ Fibonacci magic constant: {FIB_HASH_64_MAGIC}")"""
cell['source'] = [new_source]
print("✓ Removed unused imports: subprocess, os, tempfile")
break
# Save the updated notebook
with open('Fibonacci_Hashing_Demo.ipynb', 'w') as f:
json.dump(nb, f, indent=1)
print("✓ Notebook updated successfully")