Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1146a94

Browse filesBrowse files
mandelbrot start
1 parent 689a015 commit 1146a94
Copy full SHA for 1146a94

File tree

2 files changed

+46
-0
lines changed
Filter options

2 files changed

+46
-0
lines changed

‎ufo/mandelbrot0.py

Copy file name to clipboard
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
5+
def main():
6+
plt.imshow(mandelbrot(400, 400))
7+
plt.show()
8+
9+
10+
def mandelbrot(w, h, maxit=200):
11+
y, x = np.ogrid[-1.4:1.4:h * 1j, -2:0.8:w * 1j]
12+
c = x + y * 1j
13+
z = c
14+
divtime = maxit + np.zeros(z.shape, dtype=int)
15+
16+
for i in range(maxit):
17+
z = z ** 2 + c
18+
diverge = z * np.conj(z) > 2 ** 2
19+
div_now = diverge & (divtime == maxit)
20+
divtime[div_now] = i
21+
z[diverge] = 2
22+
return divtime
23+
24+
25+
if __name__ == "__main__":
26+
main()

‎ufo/numpyogrid.py

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import numpy as np
2+
3+
4+
def main():
5+
first_ogid()
6+
7+
8+
def first_ogid():
9+
x, y = np.ogrid[1:4:1, 1:5:2]
10+
print(x)
11+
print(y)
12+
x, y = np.ogrid[1:4:3j, 1:5:2j]
13+
print(x)
14+
print(y)
15+
x=np.ogrid[1:5:2]
16+
print(x)
17+
18+
19+
if __name__ == "__main__":
20+
main()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.