From a4b627a9e9fa1733a847971b37c2065e3b26697d Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 4 Oct 2018 10:37:53 -0500 Subject: [PATCH 01/17] Removing silo option from the voxel to vtk script. --- scripts/openmc-voxel-to-silovtk | 79 +++++++++++---------------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/scripts/openmc-voxel-to-silovtk b/scripts/openmc-voxel-to-silovtk index e0cfc0a5b..6e3e525e8 100755 --- a/scripts/openmc-voxel-to-silovtk +++ b/scripts/openmc-voxel-to-silovtk @@ -6,6 +6,7 @@ from argparse import ArgumentParser import numpy as np import h5py +import vtk def main(): @@ -14,8 +15,6 @@ def main(): parser.add_argument('voxel_file', help='Path to voxel file') parser.add_argument('-o', '--output', action='store', default='plot', help='Path to output SILO or VTK file.') - parser.add_argument('-s', '--silo', action='store_true', - default=False, help='Flag to convert to SILO instead of VTK.') args = parser.parse_args() # Read data from voxel file @@ -27,59 +26,33 @@ def main(): nx, ny, nz = dimension upper_right = lower_left + width*dimension + + grid = vtk.vtkImageData() + grid.SetDimensions(nx+1, ny+1, nz+1) + grid.SetOrigin(*lower_left) + grid.SetSpacing(*width) + + data = vtk.vtkDoubleArray() + data.SetName("id") + data.SetNumberOfTuples(nx*ny*nz) + for x in range(nx): + sys.stdout.write(" {}%\r".format(int(x/nx*100))) + sys.stdout.flush() + for y in range(ny): + for z in range(nz): + i = z*nx*ny + y*nx + x + data.SetValue(i, voxel_data[x, y, z]) + grid.GetCellData().AddArray(data) - if not args.silo: - import vtk - - grid = vtk.vtkImageData() - grid.SetDimensions(nx+1, ny+1, nz+1) - grid.SetOrigin(*lower_left) - grid.SetSpacing(*width) - - data = vtk.vtkDoubleArray() - data.SetName("id") - data.SetNumberOfTuples(nx*ny*nz) - for x in range(nx): - sys.stdout.write(" {}%\r".format(int(x/nx*100))) - sys.stdout.flush() - for y in range(ny): - for z in range(nz): - i = z*nx*ny + y*nx + x - data.SetValue(i, voxel_data[x, y, z]) - grid.GetCellData().AddArray(data) - - writer = vtk.vtkXMLImageDataWriter() - if vtk.vtkVersion.GetVTKMajorVersion() > 5: - writer.SetInputData(grid) - else: - writer.SetInput(grid) - if not args.output.endswith(".vti"): - args.output += ".vti" - writer.SetFileName(args.output) - writer.Write() - + writer = vtk.vtkXMLImageDataWriter() + if vtk.vtkVersion.GetVTKMajorVersion() > 5: + writer.SetInputData(grid) else: - import silomesh - - if not args.output.endswith(".silo"): - args.output += ".silo" - silomesh.init_silo(args.output) - meshparams = list(map(int, dimension)) + list(map(float, lower_left)) + \ - list(map(float, upper_right)) - silomesh.init_mesh('plot', *meshparams) - silomesh.init_var("id") - for x in range(nx): - sys.stdout.write(" {}%\r".format(int(x/nx*100))) - sys.stdout.flush() - for y in range(ny): - for z in range(nz): - silomesh.set_value(float(voxel_data[x, y, z]), - x + 1, y + 1, z + 1) - print() - silomesh.finalize_var() - silomesh.finalize_mesh() - silomesh.finalize_silo() - + writer.SetInput(grid) + if not args.output.endswith(".vti"): + args.output += ".vti" + writer.SetFileName(args.output) + writer.Write() if __name__ == '__main__': main() From a6d70cf88b9466db89169c9b41e878f449053848 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 4 Oct 2018 10:38:19 -0500 Subject: [PATCH 02/17] Renaming voxel conversion script. --- scripts/{openmc-voxel-to-silovtk => openmc-voxel-to-vtk} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{openmc-voxel-to-silovtk => openmc-voxel-to-vtk} (100%) diff --git a/scripts/openmc-voxel-to-silovtk b/scripts/openmc-voxel-to-vtk similarity index 100% rename from scripts/openmc-voxel-to-silovtk rename to scripts/openmc-voxel-to-vtk From c67d1e3d5950b3c3ca8639c037e4f0d3444e9637 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 4 Oct 2018 12:25:06 -0500 Subject: [PATCH 03/17] Adding VTK image format to ignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7eb8f286a..383232296 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ scripts/G4EMLOW*/ # Images *.ppm *.voxel +*.vti # PyCharm project configuration files .idea From e9672ca1dd7dd6694849817afcd4bec93534684e Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 4 Oct 2018 12:25:23 -0500 Subject: [PATCH 04/17] Adding call to to the voxel conversion script. --- tests/regression_tests/plot/test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/regression_tests/plot/test.py b/tests/regression_tests/plot/test.py index bfaef019c..2fec279d2 100644 --- a/tests/regression_tests/plot/test.py +++ b/tests/regression_tests/plot/test.py @@ -1,7 +1,7 @@ import glob import hashlib import os - +from subprocess import call import h5py import openmc @@ -52,6 +52,10 @@ class PlotTestHarness(TestHarness): sha512.update(outstr) outstr = sha512.hexdigest() + # test the voxel to vtk conversion script + call(['../../../scripts/openmc-voxel-to-vtk'] + + glob.glob('plot_4.h5')) + return outstr From 271bd799b2c5ef9dd72ac77cf0dcd948d82b6bf1 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 4 Oct 2018 12:25:44 -0500 Subject: [PATCH 05/17] Decreasing pixel size of the voxel image plot. --- tests/regression_tests/plot/plots.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression_tests/plot/plots.xml b/tests/regression_tests/plot/plots.xml index ecfe69125..2cec871ea 100644 --- a/tests/regression_tests/plot/plots.xml +++ b/tests/regression_tests/plot/plots.xml @@ -24,7 +24,7 @@ - 100 100 10 + 50 50 10 0. 0. 0. 20 20 10 From 4c6798b3e06ab61a7a45cd9f98a487edc2ef48ef Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 4 Oct 2018 12:25:59 -0500 Subject: [PATCH 06/17] Updating results. --- tests/regression_tests/plot/results_true.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression_tests/plot/results_true.dat b/tests/regression_tests/plot/results_true.dat index ba8a49226..f72a4ecd7 100644 --- a/tests/regression_tests/plot/results_true.dat +++ b/tests/regression_tests/plot/results_true.dat @@ -1 +1 @@ -01ecda0f3820a49c8a41d8dc47d1e5c58767a04301621c2437231fcc04401ddea47b67d0529ca56a32d4d97b4f1416a2e0b6120d3bdc87d74a7e9889758a8808 \ No newline at end of file +3337721f8f6d3777dd36c404ed117fe5bc07b1d9691a0c91131d48e7e73e21191e72401cf9bb621e3250ca51345514f90ea612e0fb6236bec33ce78655988dec \ No newline at end of file From 755d0a5a5fa1a4e11564b495e159acf7b6dd474b Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 4 Oct 2018 12:43:32 -0500 Subject: [PATCH 07/17] Adding vtk install to tests. --- tests/regression_tests/plot/test.py | 8 ++++++-- tools/ci/travis-install.sh | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/regression_tests/plot/test.py b/tests/regression_tests/plot/test.py index 2fec279d2..e568fe86a 100644 --- a/tests/regression_tests/plot/test.py +++ b/tests/regression_tests/plot/test.py @@ -53,8 +53,12 @@ class PlotTestHarness(TestHarness): outstr = sha512.hexdigest() # test the voxel to vtk conversion script - call(['../../../scripts/openmc-voxel-to-vtk'] + - glob.glob('plot_4.h5')) + try: + import vtk + call(['../../../scripts/openmc-voxel-to-vtk'] + + glob.glob('plot_4.h5')) + except: + pass return outstr diff --git a/tools/ci/travis-install.sh b/tools/ci/travis-install.sh index c10c22279..db8d1ca5a 100755 --- a/tools/ci/travis-install.sh +++ b/tools/ci/travis-install.sh @@ -26,5 +26,10 @@ python tools/ci/travis-install.py # Install Python API in editable mode pip install -e .[test] +a=$(dpkg --compare-versions $(python --version | cut -d" " -f 2) lt 3.7.0) +if [ $a -eq 0 ]; then + pip install -e .[vtk] +fi + # For uploading to coveralls pip install coveralls From b8a845073bd164ea245e632643431ccef90a5ed6 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Sun, 7 Oct 2018 17:21:48 -0500 Subject: [PATCH 08/17] Using travis environment variable to check Python version. --- tools/ci/travis-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/ci/travis-install.sh b/tools/ci/travis-install.sh index db8d1ca5a..cc707d861 100755 --- a/tools/ci/travis-install.sh +++ b/tools/ci/travis-install.sh @@ -26,8 +26,8 @@ python tools/ci/travis-install.py # Install Python API in editable mode pip install -e .[test] -a=$(dpkg --compare-versions $(python --version | cut -d" " -f 2) lt 3.7.0) -if [ $a -eq 0 ]; then +# conditionally install vtk +if [ $TRAVIS_PYTHON_VERSION -ne 3.7 ]; then pip install -e .[vtk] fi From a5b179525ccbdece30f80910bf15c8d521daa037 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Sun, 7 Oct 2018 18:35:40 -0500 Subject: [PATCH 09/17] Removing optional silo dependency. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cbf564480..c0168d880 100755 --- a/setup.py +++ b/setup.py @@ -64,7 +64,7 @@ kwargs = { # Optional dependencies 'extras_require': { 'test': ['pytest', 'pytest-cov'], - 'vtk': ['vtk', 'silomesh'], + 'vtk': ['vtk'], }, } From ad3f4ccf0c49f670f3256f8316c4648a3c1e3e94 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Sun, 7 Oct 2018 19:04:07 -0500 Subject: [PATCH 10/17] Adding plot.vti to list of expected files if vtk is present. --- tests/regression_tests/plot/test.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/regression_tests/plot/test.py b/tests/regression_tests/plot/test.py index e568fe86a..9a6fb3baf 100644 --- a/tests/regression_tests/plot/test.py +++ b/tests/regression_tests/plot/test.py @@ -18,6 +18,13 @@ class PlotTestHarness(TestHarness): def _run_openmc(self): openmc.plot_geometry(openmc_exec=config['exe']) + try: + import vtk + call(['../../../scripts/openmc-voxel-to-vtk'] + + glob.glob('plot_4.h5')) + except: + pass + def _test_output_created(self): """Make sure *.ppm has been created.""" for fname in self._plot_names: @@ -52,18 +59,16 @@ class PlotTestHarness(TestHarness): sha512.update(outstr) outstr = sha512.hexdigest() - # test the voxel to vtk conversion script - try: - import vtk - call(['../../../scripts/openmc-voxel-to-vtk'] + - glob.glob('plot_4.h5')) - except: - pass - return outstr - def test_plot(): - harness = PlotTestHarness(('plot_1.ppm', 'plot_2.ppm', 'plot_3.ppm', - 'plot_4.h5')) + expected_plots = ['plot_1.ppm', 'plot_2.ppm', + 'plot_3.ppm', 'plot_4.h5'] + try: + import vtk + expected_plots.append('plot.vti') + except: + pass + + harness = PlotTestHarness(expected_plots) harness.main() From 76aa15c6e14246a3fa30eef012e0110a9c128bf6 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 8 Oct 2018 10:00:53 -0500 Subject: [PATCH 11/17] Adding comments to plot test for clarity. --- tests/regression_tests/plot/test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/regression_tests/plot/test.py b/tests/regression_tests/plot/test.py index 9a6fb3baf..a16b3c43c 100644 --- a/tests/regression_tests/plot/test.py +++ b/tests/regression_tests/plot/test.py @@ -18,6 +18,8 @@ class PlotTestHarness(TestHarness): def _run_openmc(self): openmc.plot_geometry(openmc_exec=config['exe']) + # TEMP: this should always be checked once vtk is added + # to Python3.7 try: import vtk call(['../../../scripts/openmc-voxel-to-vtk'] + @@ -64,6 +66,8 @@ class PlotTestHarness(TestHarness): def test_plot(): expected_plots = ['plot_1.ppm', 'plot_2.ppm', 'plot_3.ppm', 'plot_4.h5'] + # TEMP: this should always be checked once vtk is added + # to Python3.7 try: import vtk expected_plots.append('plot.vti') From 2ef7ea8fe06816e92ee10eb893d1e5c93379f06a Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 8 Oct 2018 14:09:14 -0500 Subject: [PATCH 12/17] PEP8 updates. --- tests/regression_tests/plot/test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/regression_tests/plot/test.py b/tests/regression_tests/plot/test.py index a16b3c43c..90e04f913 100644 --- a/tests/regression_tests/plot/test.py +++ b/tests/regression_tests/plot/test.py @@ -2,6 +2,7 @@ import glob import hashlib import os from subprocess import call + import h5py import openmc @@ -63,9 +64,9 @@ class PlotTestHarness(TestHarness): return outstr + def test_plot(): - expected_plots = ['plot_1.ppm', 'plot_2.ppm', - 'plot_3.ppm', 'plot_4.h5'] + expected_plots = ['plot_1.ppm', 'plot_2.ppm', 'plot_3.ppm', 'plot_4.h5'] # TEMP: this should always be checked once vtk is added # to Python3.7 try: From cba6c5ad63b16303915cf4acb17de14ebfb589ed Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 8 Oct 2018 14:45:15 -0500 Subject: [PATCH 13/17] Creating a separate test for the voxel script. --- tests/regression_tests/plot/plots.xml | 2 +- tests/regression_tests/plot/results_true.dat | 2 +- tests/regression_tests/plot/test.py | 22 +------ tests/regression_tests/plot_voxel/__init__.py | 0 .../regression_tests/plot_voxel/geometry.xml | 13 ++++ .../regression_tests/plot_voxel/materials.xml | 19 ++++++ tests/regression_tests/plot_voxel/plots.xml | 10 +++ .../plot_voxel/results_true.dat | 1 + .../regression_tests/plot_voxel/settings.xml | 13 ++++ tests/regression_tests/plot_voxel/test.py | 64 +++++++++++++++++++ 10 files changed, 124 insertions(+), 22 deletions(-) create mode 100644 tests/regression_tests/plot_voxel/__init__.py create mode 100644 tests/regression_tests/plot_voxel/geometry.xml create mode 100644 tests/regression_tests/plot_voxel/materials.xml create mode 100644 tests/regression_tests/plot_voxel/plots.xml create mode 100644 tests/regression_tests/plot_voxel/results_true.dat create mode 100644 tests/regression_tests/plot_voxel/settings.xml create mode 100644 tests/regression_tests/plot_voxel/test.py diff --git a/tests/regression_tests/plot/plots.xml b/tests/regression_tests/plot/plots.xml index 2cec871ea..ecfe69125 100644 --- a/tests/regression_tests/plot/plots.xml +++ b/tests/regression_tests/plot/plots.xml @@ -24,7 +24,7 @@ - 50 50 10 + 100 100 10 0. 0. 0. 20 20 10 diff --git a/tests/regression_tests/plot/results_true.dat b/tests/regression_tests/plot/results_true.dat index f72a4ecd7..ba8a49226 100644 --- a/tests/regression_tests/plot/results_true.dat +++ b/tests/regression_tests/plot/results_true.dat @@ -1 +1 @@ -3337721f8f6d3777dd36c404ed117fe5bc07b1d9691a0c91131d48e7e73e21191e72401cf9bb621e3250ca51345514f90ea612e0fb6236bec33ce78655988dec \ No newline at end of file +01ecda0f3820a49c8a41d8dc47d1e5c58767a04301621c2437231fcc04401ddea47b67d0529ca56a32d4d97b4f1416a2e0b6120d3bdc87d74a7e9889758a8808 \ No newline at end of file diff --git a/tests/regression_tests/plot/test.py b/tests/regression_tests/plot/test.py index 90e04f913..bfaef019c 100644 --- a/tests/regression_tests/plot/test.py +++ b/tests/regression_tests/plot/test.py @@ -1,7 +1,6 @@ import glob import hashlib import os -from subprocess import call import h5py import openmc @@ -19,15 +18,6 @@ class PlotTestHarness(TestHarness): def _run_openmc(self): openmc.plot_geometry(openmc_exec=config['exe']) - # TEMP: this should always be checked once vtk is added - # to Python3.7 - try: - import vtk - call(['../../../scripts/openmc-voxel-to-vtk'] + - glob.glob('plot_4.h5')) - except: - pass - def _test_output_created(self): """Make sure *.ppm has been created.""" for fname in self._plot_names: @@ -66,14 +56,6 @@ class PlotTestHarness(TestHarness): def test_plot(): - expected_plots = ['plot_1.ppm', 'plot_2.ppm', 'plot_3.ppm', 'plot_4.h5'] - # TEMP: this should always be checked once vtk is added - # to Python3.7 - try: - import vtk - expected_plots.append('plot.vti') - except: - pass - - harness = PlotTestHarness(expected_plots) + harness = PlotTestHarness(('plot_1.ppm', 'plot_2.ppm', 'plot_3.ppm', + 'plot_4.h5')) harness.main() diff --git a/tests/regression_tests/plot_voxel/__init__.py b/tests/regression_tests/plot_voxel/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/regression_tests/plot_voxel/geometry.xml b/tests/regression_tests/plot_voxel/geometry.xml new file mode 100644 index 000000000..83619d9f7 --- /dev/null +++ b/tests/regression_tests/plot_voxel/geometry.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/regression_tests/plot_voxel/materials.xml b/tests/regression_tests/plot_voxel/materials.xml new file mode 100644 index 000000000..90b354267 --- /dev/null +++ b/tests/regression_tests/plot_voxel/materials.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/regression_tests/plot_voxel/plots.xml b/tests/regression_tests/plot_voxel/plots.xml new file mode 100644 index 000000000..833329b42 --- /dev/null +++ b/tests/regression_tests/plot_voxel/plots.xml @@ -0,0 +1,10 @@ + + + + + 50 50 10 + 0. 0. 0. + 20 20 10 + + + diff --git a/tests/regression_tests/plot_voxel/results_true.dat b/tests/regression_tests/plot_voxel/results_true.dat new file mode 100644 index 000000000..41193c9bc --- /dev/null +++ b/tests/regression_tests/plot_voxel/results_true.dat @@ -0,0 +1 @@ +20a0c3598bb698efa4bba65c5e55d71f4385e5b1bcf0067964e45001c12f5c0a729935a96409c760dbd3ec439ae6c676fce77d6e578b41f8f3e0ac68c9277acb \ No newline at end of file diff --git a/tests/regression_tests/plot_voxel/settings.xml b/tests/regression_tests/plot_voxel/settings.xml new file mode 100644 index 000000000..adf256d2d --- /dev/null +++ b/tests/regression_tests/plot_voxel/settings.xml @@ -0,0 +1,13 @@ + + + + plot + + + 5 4 3 + -10 -10 -10 + 10 10 10 + + 1 + + diff --git a/tests/regression_tests/plot_voxel/test.py b/tests/regression_tests/plot_voxel/test.py new file mode 100644 index 000000000..1e57e557d --- /dev/null +++ b/tests/regression_tests/plot_voxel/test.py @@ -0,0 +1,64 @@ +import glob +import hashlib +import os +from subprocess import run +import importlib +import h5py +import openmc +import pytest + +from tests.testing_harness import TestHarness +from tests.regression_tests import config + + +pytestmark = pytest.mark.skipif( + importlib.util.find_spec('vtk') is None, + reason="vtk module is not installed.") +class PlotVoxelTestHarness(TestHarness): + """Specialized TestHarness for running OpenMC voxel plot tests.""" + def __init__(self, plot_names): + super().__init__(None) + self._plot_names = plot_names + + def _run_openmc(self): + openmc.plot_geometry(openmc_exec=config['exe']) + + run(['../../../scripts/openmc-voxel-to-vtk'] + + glob.glob('plot_4.h5'), check=True) + + def _test_output_created(self): + """Make sure *.ppm has been created.""" + for fname in self._plot_names: + assert os.path.exists(fname), 'Plot output file does not exist.' + + def _cleanup(self): + super()._cleanup() + for fname in self._plot_names: + if os.path.exists(fname): + os.remove(fname) + + def _get_results(self): + """Return a string hash of the plot files.""" + outstr = bytes() + + for fname in self._plot_names: + if fname.endswith('.h5'): + # Add voxel data to results + with h5py.File(fname, 'r') as fh: + outstr += fh.attrs['filetype'] + outstr += fh.attrs['num_voxels'].tostring() + outstr += fh.attrs['lower_left'].tostring() + outstr += fh.attrs['voxel_width'].tostring() + outstr += fh['data'].value.tostring() + + # Hash the information and return. + sha512 = hashlib.sha512() + sha512.update(outstr) + outstr = sha512.hexdigest() + + return outstr + + +def test_plot(): + harness = PlotVoxelTestHarness(('plot_4.h5', 'plot.vti')) + harness.main() From fd92aac49c54b1014426c15883234fbc27321e97 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 8 Oct 2018 15:23:14 -0500 Subject: [PATCH 14/17] Removing mention of SILO in help string. --- scripts/openmc-voxel-to-vtk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/openmc-voxel-to-vtk b/scripts/openmc-voxel-to-vtk index 6e3e525e8..c0d8e9a14 100755 --- a/scripts/openmc-voxel-to-vtk +++ b/scripts/openmc-voxel-to-vtk @@ -14,7 +14,7 @@ def main(): parser = ArgumentParser() parser.add_argument('voxel_file', help='Path to voxel file') parser.add_argument('-o', '--output', action='store', - default='plot', help='Path to output SILO or VTK file.') + default='plot', help='Path to output VTK file.') args = parser.parse_args() # Read data from voxel file From 291aa61f12ba79e9eb3f2a905ee15f5f2041c314 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 8 Oct 2018 15:33:36 -0500 Subject: [PATCH 15/17] Changing to check_call to support Python < 3.5 --- tests/regression_tests/plot_voxel/test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/regression_tests/plot_voxel/test.py b/tests/regression_tests/plot_voxel/test.py index 1e57e557d..f6af8fa11 100644 --- a/tests/regression_tests/plot_voxel/test.py +++ b/tests/regression_tests/plot_voxel/test.py @@ -1,8 +1,9 @@ import glob import hashlib import os -from subprocess import run +from subprocess import check_call import importlib + import h5py import openmc import pytest @@ -23,8 +24,8 @@ class PlotVoxelTestHarness(TestHarness): def _run_openmc(self): openmc.plot_geometry(openmc_exec=config['exe']) - run(['../../../scripts/openmc-voxel-to-vtk'] + - glob.glob('plot_4.h5'), check=True) + check_call(['../../../scripts/openmc-voxel-to-vtk'] + + glob.glob('plot_4.h5')) def _test_output_created(self): """Make sure *.ppm has been created.""" From a10c357b013067ed56cac6692b008c406dc2fb49 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 9 Oct 2018 08:36:05 -0500 Subject: [PATCH 16/17] Updating test function name. Updating skip condition for vtk import. --- tests/regression_tests/plot_voxel/test.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/regression_tests/plot_voxel/test.py b/tests/regression_tests/plot_voxel/test.py index f6af8fa11..d2767e2f1 100644 --- a/tests/regression_tests/plot_voxel/test.py +++ b/tests/regression_tests/plot_voxel/test.py @@ -2,7 +2,6 @@ import glob import hashlib import os from subprocess import check_call -import importlib import h5py import openmc @@ -12,9 +11,7 @@ from tests.testing_harness import TestHarness from tests.regression_tests import config -pytestmark = pytest.mark.skipif( - importlib.util.find_spec('vtk') is None, - reason="vtk module is not installed.") +vtk = pytest.importorskip('vtk') class PlotVoxelTestHarness(TestHarness): """Specialized TestHarness for running OpenMC voxel plot tests.""" def __init__(self, plot_names): @@ -60,6 +57,6 @@ class PlotVoxelTestHarness(TestHarness): return outstr -def test_plot(): +def test_plot_voxel(): harness = PlotVoxelTestHarness(('plot_4.h5', 'plot.vti')) harness.main() From 8be83ff9df8b9c209db5733a91698af9baf91dd6 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 10 Oct 2018 10:24:19 -0500 Subject: [PATCH 17/17] Correcting vtk install condition. --- tools/ci/travis-install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/ci/travis-install.sh b/tools/ci/travis-install.sh index cc707d861..670f28f33 100755 --- a/tools/ci/travis-install.sh +++ b/tools/ci/travis-install.sh @@ -23,12 +23,12 @@ fi # Build and install OpenMC executable python tools/ci/travis-install.py -# Install Python API in editable mode -pip install -e .[test] - -# conditionally install vtk -if [ $TRAVIS_PYTHON_VERSION -ne 3.7 ]; then - pip install -e .[vtk] +if [[ $TRAVIS_PYTHON_VERSION == "3.7" ]]; then + # Install Python API in editable mode + pip install -e .[test] +else + # Conditionally install vtk + pip install -e .[test,vtk] fi # For uploading to coveralls