Skip to content

Commit 1435b57

Browse files
committed
FIX: Different
1 parent 0b20e8b commit 1435b57

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

surfer/tests/test_viz.py

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os.path as op
44
from os.path import join as pjoin
55
import sys
6-
import warnings
76

87
import pytest
98
from mayavi import mlab
@@ -17,8 +16,6 @@
1716
from surfer.utils import (requires_fsaverage, requires_imageio, requires_fs,
1817
_get_extra)
1918

20-
warnings.simplefilter('always')
21-
2219
subject_id = 'fsaverage'
2320
std_args = [subject_id, 'lh', 'inflated']
2421
data_dir = pjoin(op.dirname(__file__), '..', '..', 'examples', 'example_data')
@@ -85,21 +82,12 @@ def test_image(tmpdir):
8582
brain = Brain(subject_id, 'both', surf=surf, size=100)
8683
brain.add_overlay(overlay_fname, hemi='lh', min=5, max=20, sign="pos")
8784
brain.save_imageset(tmp_name, ['med', 'lat'], 'jpg')
88-
brain.close()
89-
del brain
90-
91-
brain = Brain(*std_args, size=100)
92-
for b in brain.brain_matrix.ravel():
93-
assert b._f.scene is not None
9485
brain.save_image(tmp_name)
9586
brain.save_image(tmp_name, 'rgba', True)
9687
brain.screenshot()
97-
if os.getenv('TRAVIS', '') != 'true':
98-
# for some reason these fail on Travis sometimes
99-
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='v')
100-
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='h')
101-
brain.save_montage(tmp_name, [['l', 'v'], ['m', 'f']])
102-
brain.close()
88+
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='v')
89+
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='h')
90+
brain.save_montage(tmp_name, [['l', 'v'], ['m', 'f']])
10391

10492

10593
@requires_fsaverage()
@@ -108,8 +96,7 @@ def test_brains():
10896
# testing backend breaks when passing in a figure, so we use 'auto' here
10997
# (shouldn't affect usability, but it makes testing more annoying)
11098
_set_backend('auto')
111-
with warnings.catch_warnings(record=True): # traits for mlab.figure()
112-
mlab.figure(101)
99+
mlab.figure(101)
113100
surfs = ['inflated', 'white', 'white', 'white', 'white', 'white', 'white']
114101
hemis = ['lh', 'rh', 'both', 'both', 'rh', 'both', 'both']
115102
titles = [None, 'Hello', 'Good bye!', 'lut test',
@@ -122,8 +109,7 @@ def test_brains():
122109
(0.2, 0.2, 0.2), "black", "0.75"]
123110
foregrounds = ["black", "white", "0.75", "red",
124111
(0.2, 0.2, 0.2), "blue", "black"]
125-
with warnings.catch_warnings(record=True): # traits for mlab.figure()
126-
figs = [101, mlab.figure(), None, None, mlab.figure(), None, None]
112+
figs = [101, mlab.figure(), None, None, mlab.figure(), None, None]
127113
subj_dir = utils._get_subjects_dir()
128114
subj_dirs = [None, subj_dir, subj_dir, subj_dir,
129115
subj_dir, subj_dir, subj_dir]
@@ -153,7 +139,6 @@ def test_annot():
153139
annots = ['aparc', 'aparc.a2005s']
154140
borders = [True, False, 2]
155141
alphas = [1, 0.5]
156-
gc.collect()
157142
brain = Brain(*std_args)
158143
view = get_view(brain)
159144

@@ -463,9 +448,8 @@ def test_probabilistic_labels():
463448
prob_field[ids] = probs
464449
brain.add_data(prob_field, thresh=1e-5)
465450

466-
with warnings.catch_warnings(record=True):
467-
brain.data["colorbar"].number_of_colors = 10
468-
brain.data["colorbar"].number_of_labels = 11
451+
brain.data["colorbar"].number_of_colors = 10
452+
brain.data["colorbar"].number_of_labels = 11
469453
brain.close()
470454

471455

surfer/viz.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from copy import deepcopy
2-
import gc
32
import logging
43
from math import floor
54
import os
@@ -2291,9 +2290,6 @@ def hide_colorbar(self, row=-1, col=-1):
22912290

22922291
def close(self):
22932292
"""Close all figures and cleanup data structure."""
2294-
self._close()
2295-
2296-
def _close(self, force_render=True):
22972293
for ri, ff in enumerate(self._figures):
22982294
for ci, f in enumerate(ff):
22992295
if f is not None:
@@ -2303,8 +2299,7 @@ def _close(self, force_render=True):
23032299
pass
23042300
self._figures[ri][ci] = None
23052301

2306-
if force_render:
2307-
_force_render([])
2302+
_force_render([])
23082303

23092304
# should we tear down other variables?
23102305
if getattr(self, '_v', None) is not None:
@@ -2313,10 +2308,9 @@ def _close(self, force_render=True):
23132308
except Exception:
23142309
pass
23152310
self._v = None
2316-
gc.collect()
23172311

23182312
def __del__(self):
2319-
self._close(force_render=False)
2313+
self.close()
23202314

23212315
###########################################################################
23222316
# SAVING OUTPUT

0 commit comments

Comments
 (0)