Skip to content

Commit

Permalink
Fixing get_neighbors for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcelebi committed Sep 17, 2024
1 parent 4f1969c commit ef747fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions app/ml_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@ def home(view = False):
def get_tests():
return ["test1", "test2", "test3", "test4"]


'''
Where is this input coming from? Where are we saving data?
Where are we processing?
'''
@app.route('/plot')
def plot_png():
fig = create_figure()
def plot_png(xs, ys):
fig = create_figure(xs, ys)
output = io.BytesIO()
FigureCanvas(fig).print_png(output)
return Response(output.getvalue(), mimetype='image/png')

def create_figure():
def create_figure(xs, ys):
fig = Figure()
axis = fig.add_subplot(1, 1, 1)
axis.plot(range(10), [10, 5, -10, 4, 5, 6, 7, 2, 2, 11])
#axis.plot(range(10), [10, 5, -10, 4, 5, 6, 7, 2, 2, 11])
axis.plot(xs, ys)
return fig


Expand Down
2 changes: 1 addition & 1 deletion src/sim/automata.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_neighbors(i, j, shape):
# does i-10, j-10 as coord to remove in next step
neighbors = np.reshape(
[[[i + u, j + v] if in_range(i + u, j + v, shape = shape) else [i - 10, j - 10] for u in [-1, 0, 1]] for v in [-1, 0, 1]],
size = (-1, 2)
(-1, 2) # shape
)
return neighbors[~np.all(np.logical_or(neighbors == [i, j], neighbors == [i - 10, j - 10]), axis = 1)] # make sure to exlude center and not in-range values

Expand Down

0 comments on commit ef747fc

Please sign in to comment.