From 3e7bca49a8d02ec96bbff7c38e78ef8b77472a50 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 7 Apr 2017 17:26:58 -0500 Subject: [PATCH] Fix openmc-track-to-vtk and track test --- scripts/openmc-track-to-vtk | 4 ++-- tests/test_track_output/test_track_output.py | 18 ++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/scripts/openmc-track-to-vtk b/scripts/openmc-track-to-vtk index d190ac662..1dd632f9d 100755 --- a/scripts/openmc-track-to-vtk +++ b/scripts/openmc-track-to-vtk @@ -42,8 +42,8 @@ def main(): for fname in args.input: # Write coordinate values to points array. track = h5py.File(fname) - n_particles = track['n_particles'].value - n_coords = track['n_coords'] + n_particles = track.attrs['n_particles'] + n_coords = track.attrs['n_coords'] coords = [] for i in range(n_particles): coords.append(track['coordinates_' + str(i + 1)].value) diff --git a/tests/test_track_output/test_track_output.py b/tests/test_track_output/test_track_output.py index 231f25a0d..0357aae19 100644 --- a/tests/test_track_output/test_track_output.py +++ b/tests/test_track_output/test_track_output.py @@ -14,32 +14,26 @@ class TrackTestHarness(TestHarness): """Make sure statepoint.* and track* have been created.""" TestHarness._test_output_created(self) - outputs = [glob.glob(''.join((os.getcwd(), '/track_1_1_1.*')))] - outputs.append(glob.glob(''.join((os.getcwd(), '/track_1_1_2.*')))) - for files in outputs: - assert len(files) == 1, 'Multiple or no track files detected.' - assert files[0].endswith('h5'),\ - 'Track files are not HDF5 files' + outputs = glob.glob('track_1_1_*.h5') + assert len(outputs) == 2, 'Expected two track files.' def _get_results(self): """Digest info in the statepoint and return as a string.""" # Run the track-to-vtk conversion script. call(['../../scripts/openmc-track-to-vtk', '-o', 'poly'] + - glob.glob(''.join((os.getcwd(), '/track*')))) + glob.glob('track_1_1_*.h5')) # Make sure the vtk file was created then return it's contents. - poly = os.path.join(os.getcwd(), 'poly.pvtp') - assert os.path.isfile(poly), 'poly.pvtp file not found.' + assert os.path.isfile('poly.pvtp'), 'poly.pvtp file not found.' - with open(poly) as fin: + with open('poly.pvtp', 'r') as fin: outstr = fin.read() return outstr def _cleanup(self): TestHarness._cleanup(self) - output = glob.glob(os.path.join(os.getcwd(), 'track*')) - output += glob.glob(os.path.join(os.getcwd(), 'poly*')) + output = glob.glob('track*') + glob.glob('poly*') for f in output: if os.path.exists(f): os.remove(f)