Skip to content

Commit

Permalink
Interactive replotting in hopfield without plt.ion(), which caused er…
Browse files Browse the repository at this point in the history
…rors;
  • Loading branch information
seeholza committed Feb 29, 2016
1 parent 35c8972 commit 7856ae1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions conda_build/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ test:
- neurodynex.test

commands:
- nosetests neurodynex.test.test_LIF
- nosetests neurodynex.test.test_HH
- nosetests neurodynex.test.test_hopfield
- nosetests neurodynex.test.test_nagumo
- nosetests neurodynex.test.test_neuron_type
- nosetests --verbosity=2 neurodynex.test.test_LIF
- nosetests --verbosity=2 neurodynex.test.test_HH
- nosetests --verbosity=2 neurodynex.test.test_hopfield
- nosetests --verbosity=2 neurodynex.test.test_nagumo
- nosetests --verbosity=2 neurodynex.test.test_neuron_type

requires:
- nose
Expand Down
8 changes: 3 additions & 5 deletions neurodynex/hopfield_network/hopfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
import matplotlib.pyplot as plt
import numpy as np
from copy import copy
from time import sleep
import pickle
import gzip
from pkg_resources import resource_filename
import sys

plot_dic = {'cmap': plt.cm.gray, 'interpolation': 'nearest'}
plt.ion()


class HopfieldNetwork:
Expand Down Expand Up @@ -166,7 +164,7 @@ def run(self, t_max=20, mu=0, flip_ratio=0, do_plot=True):
overlap = [self.overlap(mu)]

# prepare the figure
plt.figure()
fig = plt.figure()

# plot the current network state
plt.subplot(221)
Expand All @@ -191,7 +189,7 @@ def run(self, t_max=20, mu=0, flip_ratio=0, do_plot=True):
plt.ylabel('overlap')

# this forces pylab to update and show the fig.
plt.draw()
fig.show()
x_old = copy(self.x)

for i in range(t_max):
Expand All @@ -215,7 +213,7 @@ def run(self, t_max=20, mu=0, flip_ratio=0, do_plot=True):
x_old = copy(self.x)

# sleep for replotting
sleep(0.5)
plt.pause(0.5)

print("Pattern recovered in %i time steps." % i_fin +
" Final overlap %.3f" % overlap[-1])
Expand Down

0 comments on commit 7856ae1

Please sign in to comment.