Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 15bf85e

Browse files
committedOct 24, 2024·
apply coding style
1 parent 770d9ce commit 15bf85e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎fractals/barnsley_farn.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Barnsley Fern
33
4-
The Barnsley fern is a fractal that uses an iterated function system (IFS)
4+
The Barnsley fern is a fractal that uses an iterated function system (IFS)
55
to generate a realistic-looking fern shape.
66
77
Reference:
@@ -12,8 +12,8 @@
1212
- numpy
1313
"""
1414

15-
import numpy as np
1615
import matplotlib.pyplot as plt
16+
import numpy as np
1717

1818

1919
def barnsley_farn(n_points=100000):
@@ -23,8 +23,10 @@ def barnsley_farn(n_points=100000):
2323
x, y = 0, 0
2424
points = np.zeros((n_points, 2))
2525

26+
rng = np.random.default_rng()
27+
2628
for i in range(n_points):
27-
r = np.random.random()
29+
r = rng.random()
2830
if r < 0.01:
2931
x, y = 0, 0.16 * y
3032
elif r < 0.86:
@@ -43,7 +45,7 @@ def plot_barnsley_farn(points):
4345
Plots the Barnsley fern using matplotlib.
4446
"""
4547
x, y = points[:, 0], points[:, 1]
46-
plt.scatter(x, y, s=0.1, color='green')
48+
plt.scatter(x, y, s=0.1, color="green")
4749
plt.title("Barnsley Fern")
4850
plt.show()
4951

0 commit comments

Comments
 (0)
Please sign in to comment.