Commit
·
0358ba5
1
Parent(s):
6ce18df
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,7 +60,7 @@ def generate_random_walk(iters, step_size = 1, random_seed=42):
|
|
| 60 |
info_text = 'Start point=' + str(start_point) + '\n' +'End point=' + str([x[-1],y[-1]]) + '\n' +'Displacement =' + str(distance_from_start([x[-1], y[-1]], start_point)) + '\n' +'Max x = ' + str(max(x)) + '\n' + 'Min x = ' + str(min(x)) + '\n' + 'Max y = ' + str(max(y)) + '\n' + 'Min y = ' + str(min(y))
|
| 61 |
ax.legend([info_text], loc='best', handlelength=0, handletextpad=0, fancybox=True, fontsize=8)
|
| 62 |
|
| 63 |
-
plt.title('2D Random Walk\nsteps=' + str(iters)+', step size='+ str(step_size)+ ', seed = '+str(int(random_seed)))
|
| 64 |
plt.grid()
|
| 65 |
|
| 66 |
fig.canvas.draw()
|
|
@@ -74,7 +74,7 @@ try:
|
|
| 74 |
except:
|
| 75 |
random_seed = random.randint(1, 1000)
|
| 76 |
|
| 77 |
-
if random_seed
|
| 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")
|
|
|
|
| 60 |
info_text = 'Start point=' + str(start_point) + '\n' +'End point=' + str([x[-1],y[-1]]) + '\n' +'Displacement =' + str(distance_from_start([x[-1], y[-1]], start_point)) + '\n' +'Max x = ' + str(max(x)) + '\n' + 'Min x = ' + str(min(x)) + '\n' + 'Max y = ' + str(max(y)) + '\n' + 'Min y = ' + str(min(y))
|
| 61 |
ax.legend([info_text], loc='best', handlelength=0, handletextpad=0, fancybox=True, fontsize=8)
|
| 62 |
|
| 63 |
+
plt.title( '2D Random Walk\nsteps=' + str(iters)+', step size='+ str(step_size)+ ', seed = '+str(int(random_seed)) )
|
| 64 |
plt.grid()
|
| 65 |
|
| 66 |
fig.canvas.draw()
|
|
|
|
| 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")
|