TDA Lecture 1 — Python Environment Check#
What to do#
Make sure the kernel is Python (tda-course).
Choose Run → Run All Cells (or run each cell with Shift+Enter).
If all cells run without errors and the plots appear, you are ready for the course.
import sys
print("Python version:", sys.version.split()[0])
print("Python executable:")
print(sys.executable)
print("\nIf the path above contains 'tda-course', you are using the intended environment.")
1. Check the course packages#
If this cell runs without an error, the environment is installed correctly.
import numpy as np
import matplotlib.pyplot as plt
import scipy
import pandas
import networkx
import sklearn
import gudhi
import ripser
import persim
import kmapper
print("✓ All main course packages imported successfully!")
2. Circle → ellipse#
Recall that a circle and an ellipse are homeomorphic.
We can see the basic idea computationally: sample points on a circle, then stretch the (x)-coordinate.
Start with \((x,y)=(\cos t,\sin t),\) and apply \(h(x,y)=(2x,y).\)
This changes distances and geometry, but not the underlying topological type.
t = np.linspace(0, 2*np.pi, 300)
# Circle
x = np.cos(t)
y = np.sin(t)
plt.figure(figsize=(5, 5))
plt.plot(x, y)
plt.axis("equal")
plt.title("Circle")
plt.show()
# Stretch the circle horizontally
u = 2 * x
v = y
plt.figure(figsize=(6, 4))
plt.plot(u, v)
plt.axis("equal")
plt.title("Ellipse obtained by stretching the circle")
plt.show()