Preamble setup¶
Introduction¶
The hcn.preamble module is a one-line shortcut to a ready-to-use scientific Python environment.
Usage¶
By calling from hcn.preamble import *, you get:
| Category | Imported Names |
|---|---|
| Scientific | np (numpy), plt (matplotlib.pyplot) |
| Math | pi, e |
| Utilities | os, sleep (time.sleep), tqdm |
| Styling | Pre-configured MATLAB-style plotting |
Examples¶
InĀ [1]:
Copied!
from hcn.preamble import *
from hcn.preamble import *
InĀ [2]:
Copied!
print(f"pi: {pi}")
print(f"e: {e}")
print(f"pi: {pi}")
print(f"e: {e}")
pi: 3.141592653589793 e: 2.718281828459045
InĀ [3]:
Copied!
x = np.linspace(0, 2*pi, 128)
plt.plot(x, np.sin(x))
plt.show()
x = np.linspace(0, 2*pi, 128)
plt.plot(x, np.sin(x))
plt.show()
InĀ [4]:
Copied!
x, y = np.meshgrid(np.linspace(-3, 3, 128), np.linspace(-3, 3, 128))
rho = np.sqrt(x**2 + y**2)
plt.imshow(np.exp(-rho**2))
plt.show()
x, y = np.meshgrid(np.linspace(-3, 3, 128), np.linspace(-3, 3, 128))
rho = np.sqrt(x**2 + y**2)
plt.imshow(np.exp(-rho**2))
plt.show()