Skip to content

Commit 07dc04b

Browse files
authored
Merge pull request #289 from larsoner/force
MRG, FIX: Remove force render
2 parents 7952423 + ce7ac2d commit 07dc04b

File tree

3 files changed

+75
-20
lines changed

3 files changed

+75
-20
lines changed

azure-pipelines.yml

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,57 @@
1-
# Starter pipeline
2-
# Start with a minimal pipeline that you can customize to build and deploy your code.
3-
# Add steps that build, run tests, deploy, and more:
4-
# https://aka.ms/yaml
5-
61
trigger:
7-
- master
8-
9-
pool:
10-
vmImage: 'ubuntu-latest'
11-
12-
steps:
13-
- script: echo Hello, world!
14-
displayName: 'Run a one-line script'
2+
# start a new build for every push
3+
batch: False
4+
branches:
5+
include:
6+
- master
157

16-
- script: |
17-
echo Add other tasks to build, test, and deploy your project.
18-
echo See https://aka.ms/yaml
19-
displayName: 'Run a multi-line script'
8+
jobs:
9+
- job: Windows
10+
variables:
11+
PIP_CACHE_FOLDER: $(Pipeline.Workspace)/.cache/pip
12+
pool:
13+
vmIMage: 'VS2017-Win2016'
14+
strategy:
15+
maxParallel: 4
16+
matrix:
17+
Python37-64bit:
18+
PYTHON_VERSION: '3.7'
19+
PYTHON_ARCH: 'x64'
20+
steps:
21+
- task: UsePythonVersion@0
22+
inputs:
23+
versionSpec: $(PYTHON_VERSION)
24+
architecture: $(PYTHON_ARCH)
25+
addToPath: true
26+
- task: Cache@2
27+
inputs:
28+
key: 'pip'
29+
path: $(PIP_CACHE_FOLDER)
30+
displayName: Cache pip packages
31+
- powershell: |
32+
pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio imageio-ffmpeg codecov pyqt5==5.9 --cache-dir $(PIP_CACHE_FOLDER)
33+
pip install traits traitsui pyface vtk mayavi nibabel --cache-dir $(PIP_CACHE_FOLDER)
34+
displayName: 'Install pip dependencies'
35+
- powershell: |
36+
powershell make/get_fsaverage.ps1
37+
$env:SUBJECTS_DIR = '$(System.DefaultWorkingDirectory)' + '\subjects'
38+
Write-Host ("##vso[task.setvariable variable=SUBJECTS_DIR]" + $env:SUBJECTS_DIR)
39+
displayName: 'Get fsaverage'
40+
- powershell: |
41+
git clone --depth 1 git://github.com/pyvista/gl-ci-helpers.git
42+
powershell gl-ci-helpers/appveyor/install_opengl.ps1
43+
displayName: 'Get OpenGL'
44+
- script: python setup.py develop
45+
displayName: 'Install'
46+
- script: pytest surfer --cov=surfer -v
47+
displayName: 'Run tests'
48+
- script: codecov --root %BUILD_REPOSITORY_LOCALPATH% -t %CODECOV_TOKEN%
49+
displayName: 'Codecov'
50+
env:
51+
CODECOV_TOKEN: $(CODECOV_TOKEN)
52+
condition: always()
53+
- task: PublishTestResults@2
54+
inputs:
55+
testResultsFiles: 'junit-*.xml'
56+
testRunTitle: 'Publish test results for Python $(python.version)'
57+
condition: always()

surfer/tests/test_viz.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gc
12
import os
23
import os.path as op
34
from os.path import join as pjoin
@@ -210,6 +211,17 @@ def test_data():
210211
brain.close()
211212

212213

214+
@requires_fsaverage()
215+
def test_close():
216+
"""Test that close and del actually work."""
217+
_set_backend()
218+
brain = Brain('fsaverage', 'both', 'inflated')
219+
brain.close()
220+
brain.__del__()
221+
del brain
222+
gc.collect()
223+
224+
213225
@requires_fsaverage()
214226
def test_data_limits():
215227
"""Test handling of data limits."""

surfer/viz.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,10 @@ def hide_colorbar(self, row=-1, col=-1):
22962296

22972297
def close(self):
22982298
"""Close all figures and cleanup data structure."""
2299-
for ri, ff in enumerate(self._figures):
2299+
self._close()
2300+
2301+
def _close(self, force_render=True):
2302+
for ri, ff in enumerate(getattr(self, '_figures', [])):
23002303
for ci, f in enumerate(ff):
23012304
if f is not None:
23022305
try:
@@ -2305,7 +2308,8 @@ def close(self):
23052308
pass
23062309
self._figures[ri][ci] = None
23072310

2308-
_force_render([])
2311+
if force_render:
2312+
_force_render([])
23092313

23102314
# should we tear down other variables?
23112315
if getattr(self, '_v', None) is not None:
@@ -2316,7 +2320,8 @@ def close(self):
23162320
self._v = None
23172321

23182322
def __del__(self):
2319-
self.close()
2323+
# Forcing the GUI updates during GC seems to be problematic
2324+
self._close(force_render=False)
23202325

23212326
###########################################################################
23222327
# SAVING OUTPUT

0 commit comments

Comments
 (0)