DebasishDhal99
commited on
Commit
·
64eeeed
1
Parent(s):
63e2400
Removing random seed bug
Browse files
app.py
CHANGED
@@ -6,12 +6,15 @@ import numpy as np
|
|
6 |
# seed = random.randint(1, 1000)
|
7 |
# random.seed(seed)
|
8 |
|
9 |
-
def generate_random_walk(iters, step_size = 1, random_seed
|
10 |
-
random.seed(random_seed)
|
11 |
iters = int(iters)
|
12 |
directions = ['east', 'north', 'west', 'south']
|
13 |
start_point = [0, 0]
|
14 |
-
|
|
|
|
|
|
|
15 |
def distance_from_start(final_coord, start_coord, round_to=2):
|
16 |
return round(np.sqrt((final_coord[0] - start_coord[0])**2 + (final_coord[1] - start_coord[1])**2), round_to)
|
17 |
|
@@ -69,13 +72,7 @@ def generate_random_walk(iters, step_size = 1, random_seed=42):
|
|
69 |
|
70 |
iters = gr.Number(value=1e5,label="How many random steps?")
|
71 |
step_size = gr.Number(value=1,label="Step size")
|
72 |
-
|
73 |
-
random_seed = gr.Number(value=42,label="Random seed")
|
74 |
-
except:
|
75 |
-
random_seed = random.randint(1, 1000)
|
76 |
-
|
77 |
-
if random_seed == None:
|
78 |
-
random_seed = random.randint(1, 1000)
|
79 |
|
80 |
iface = gr.Interface(fn=generate_random_walk, inputs=[iters, step_size, random_seed], outputs="image", title="2-D Random Walk Plot", description="Steps along NEWS directions only")
|
81 |
iface.launch()
|
|
|
6 |
# seed = random.randint(1, 1000)
|
7 |
# random.seed(seed)
|
8 |
|
9 |
+
def generate_random_walk(iters, step_size = 1, random_seed):
|
10 |
+
# random.seed(random_seed)
|
11 |
iters = int(iters)
|
12 |
directions = ['east', 'north', 'west', 'south']
|
13 |
start_point = [0, 0]
|
14 |
+
|
15 |
+
if random_seed is None:
|
16 |
+
random_seed = random.randint(1, 1000)
|
17 |
+
|
18 |
def distance_from_start(final_coord, start_coord, round_to=2):
|
19 |
return round(np.sqrt((final_coord[0] - start_coord[0])**2 + (final_coord[1] - start_coord[1])**2), round_to)
|
20 |
|
|
|
72 |
|
73 |
iters = gr.Number(value=1e5,label="How many random steps?")
|
74 |
step_size = gr.Number(value=1,label="Step size")
|
75 |
+
random_seed = gr.Number(value=None,label="Random seed")
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
iface = gr.Interface(fn=generate_random_walk, inputs=[iters, step_size, random_seed], outputs="image", title="2-D Random Walk Plot", description="Steps along NEWS directions only")
|
78 |
iface.launch()
|