Skip to content

Commit

Permalink
add build to plot and tes
Browse files Browse the repository at this point in the history
  • Loading branch information
jgranley committed Oct 23, 2023
1 parent 47c9407 commit fc889dd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pulse2percept/models/cortex/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 86,9 @@ def plot(self, use_dva=False, style=None, autoscale=True, ax=None,
"""
if style is None:
style = 'hull' if use_dva else 'scatter'
# Model must be built to access cortical coordinates
if not self.is_built:
self.build()
ax = self.grid.plot(style=style, use_dva=use_dva, autoscale=autoscale,
ax=ax, figsize=figsize, fc=fc,
zorder=ZORDER['background'],
Expand Down
3 changes: 3 additions & 0 deletions pulse2percept/models/cortex/dynaphos.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 384,9 @@ def plot(self, use_dva=False, style=None, autoscale=True, ax=None,
"""
if style is None:
style = 'hull' if use_dva else 'scatter'
# Model must be built to access cortical coordinates
if not self.is_built:
self.build()
ax = self.grid.plot(style=style, use_dva=use_dva, autoscale=autoscale,
ax=ax, figsize=figsize, fc=fc,
zorder=ZORDER['background'],
Expand Down
8 changes: 8 additions & 0 deletions pulse2percept/models/cortex/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 146,11 @@ def test_deepcopy_Scoreboard(ModelClass):
original = None
npt.assert_equal(copied is not None, True)


@pytest.mark.parametrize('ModelClass', [ScoreboardModel, ScoreboardSpatial])
def test_plot(ModelClass):
# make sure that plotting works before and after building
m = ModelClass()
m.plot()
m.build()
m.plot()
9 changes: 8 additions & 1 deletion pulse2percept/models/cortex/tests/test_dynaphos.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 100,11 @@ def test_deepcopy_Dynaphos():

# Assert destroying the original doesn't affect the copied
original = None
npt.assert_equal(copied is not None, True)
npt.assert_equal(copied is not None, True)

def test_dynaphos_plot():
# make sure that plotting works before and after building
m = DynaphosModel()
m.plot()
m.build()
m.plot()

0 comments on commit fc889dd

Please sign in to comment.