This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mandelbrot_set(width, height, iterations=256): | |
w,h = width, height | |
pixels = np.arange(w*h, dtype=np.uint16).reshape(h, w) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for row in range(w): | |
for col in range(h): | |
cx = 1.5*(row - 3*w/4)/(0.5*w) | |
cy = 1.0*(col - h/2)/(0.5*h) | |
c = complex(cx, cy) | |
x = complex(0, 0) | |
for i in range(iterations): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return pixels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def display(width=3000, height=1800,cmap='magma',iterations=256): | |
pixels = mandelbrot_set(width, height, iterations=iterations) | |
plt.figure(figsize=(20,10)) | |
plt.axis('off') | |
plt.imshow(pixels, cmap='magma') | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
display() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dateutil import parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parser.parse('7/3/40') | |
parser.parse('7–3–2040') | |
parser.parse('7.3.40') | |
parser.parse('July 3rd, 2040') | |
parser.parse('July 3 2040') | |
parser.parse('2040 July 3') | |
parser.parse('3 July 2040') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
datetime.datetime.now() | |
# returns datetime.datetime(2020, 5, 23, 15, 46, 7, 802024) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delta = datetime.datetime(2020, 5, 30) - datetime.datetime(1938, 6, 3) |
OlderNewer