From ba659b3f0cd1634e54362fc2c672d410ea239d31 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Mon, 14 Sep 2015 20:45:21 -0400 Subject: [PATCH 1/3] Fix PyAPI filter for numpy isinstance bug --- openmc/filter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openmc/filter.py b/openmc/filter.py index 5a81906762..b9b6df36b5 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -7,7 +7,7 @@ import numpy as np from openmc import Mesh from openmc.constants import * from openmc.checkvalue import check_type, check_iterable_type, \ - check_greater_than + check_greater_than, _isinstance class Filter(object): """A filter used to constrain a tally to a specific criterion, e.g. only tally @@ -126,7 +126,7 @@ class Filter(object): raise ValueError(msg) # If the bin edge is a single value, it is a Cell, Material, etc. ID - if not isinstance(bins, Iterable): + if not _isinstance(bins, Iterable): bins = [bins] # If the bins are in a collection, convert it to a list @@ -141,7 +141,7 @@ class Filter(object): elif self._type in ['energy', 'energyout']: for edge in bins: - if not isinstance(edge, Real): + if not _isinstance(edge, Real): msg = 'Unable to add bin edge "{0}" to a "{1}" Filter ' \ 'since it is a non-integer or floating point ' \ 'value'.format(edge, self.type) @@ -165,7 +165,7 @@ class Filter(object): msg = 'Unable to add bins "{0}" to a mesh Filter since ' \ 'only a single mesh can be used per tally'.format(bins) raise ValueError(msg) - elif not isinstance(bins[0], Integral): + elif not _isinstance(bins[0], Integral): msg = 'Unable to add bin "{0}" to mesh Filter since it ' \ 'is a non-integer'.format(bins[0]) raise ValueError(msg) From b9379e3c8667d062ec6511ad07f2525ea0b2f5ef Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Mon, 14 Sep 2015 21:05:58 -0400 Subject: [PATCH 2/3] Make test cleanup source file --- .../test_statepoint_sourcesep/test_statepoint_sourcesep.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py index acbb0180bf..157210de6f 100644 --- a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py +++ b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py @@ -15,6 +15,13 @@ class SourcepointTestHarness(TestHarness): assert source[0].endswith('h5'), \ 'Source file is not a HDF5 file.' + def _cleanup(self): + TestHarness._cleanup(self) + output = glob.glob(os.path.join(os.getcwd(), 'source.*')) + for f in output: + if os.path.exists(f): + os.remove(f) + if __name__ == '__main__': harness = SourcepointTestHarness('statepoint.10.*') From fb518a4d7ce663f371723a1d470908ad98b7cd03 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Mon, 14 Sep 2015 21:42:25 -0400 Subject: [PATCH 3/3] Make os and glob imports explicit --- tests/test_entropy/test_entropy.py | 3 +++ tests/test_filter_distribcell/test_filter_distribcell.py | 2 ++ tests/test_fixed_source/test_fixed_source.py | 3 +++ tests/test_output/test_output.py | 3 +++ tests/test_source_file/test_source_file.py | 3 +++ tests/test_sourcepoint_batch/test_sourcepoint_batch.py | 3 +++ tests/test_sourcepoint_interval/test_sourcepoint_interval.py | 3 +++ tests/test_sourcepoint_latest/test_sourcepoint_latest.py | 3 +++ tests/test_statepoint_restart/test_statepoint_restart.py | 3 +++ tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py | 3 +++ tests/test_track_output/test_track_output.py | 2 ++ 11 files changed, 31 insertions(+) diff --git a/tests/test_entropy/test_entropy.py b/tests/test_entropy/test_entropy.py index 4657101ad6..9b13fd3dd2 100644 --- a/tests/test_entropy/test_entropy.py +++ b/tests/test_entropy/test_entropy.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_filter_distribcell/test_filter_distribcell.py b/tests/test_filter_distribcell/test_filter_distribcell.py index 8370e40e7f..541d6b6af1 100644 --- a/tests/test_filter_distribcell/test_filter_distribcell.py +++ b/tests/test_filter_distribcell/test_filter_distribcell.py @@ -1,6 +1,8 @@ #!/usr/bin/env python +import glob import hashlib +import os import sys sys.path.insert(0, '..') diff --git a/tests/test_fixed_source/test_fixed_source.py b/tests/test_fixed_source/test_fixed_source.py index e96a3ad8fe..1f154a4657 100644 --- a/tests/test_fixed_source/test_fixed_source.py +++ b/tests/test_fixed_source/test_fixed_source.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_output/test_output.py b/tests/test_output/test_output.py index 0225d9fed0..b37b7d07b2 100644 --- a/tests/test_output/test_output.py +++ b/tests/test_output/test_output.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_source_file/test_source_file.py b/tests/test_source_file/test_source_file.py index d7ed8b80af..fae6b2a72f 100644 --- a/tests/test_source_file/test_source_file.py +++ b/tests/test_source_file/test_source_file.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_sourcepoint_batch/test_sourcepoint_batch.py b/tests/test_sourcepoint_batch/test_sourcepoint_batch.py index a902236599..521e3bb4b2 100644 --- a/tests/test_sourcepoint_batch/test_sourcepoint_batch.py +++ b/tests/test_sourcepoint_batch/test_sourcepoint_batch.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_sourcepoint_interval/test_sourcepoint_interval.py b/tests/test_sourcepoint_interval/test_sourcepoint_interval.py index a902236599..521e3bb4b2 100644 --- a/tests/test_sourcepoint_interval/test_sourcepoint_interval.py +++ b/tests/test_sourcepoint_interval/test_sourcepoint_interval.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_sourcepoint_latest/test_sourcepoint_latest.py b/tests/test_sourcepoint_latest/test_sourcepoint_latest.py index 8c04641b7b..7d0af89b97 100644 --- a/tests/test_sourcepoint_latest/test_sourcepoint_latest.py +++ b/tests/test_sourcepoint_latest/test_sourcepoint_latest.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_statepoint_restart/test_statepoint_restart.py b/tests/test_statepoint_restart/test_statepoint_restart.py index 0420dbddfa..dd42dc8ff5 100644 --- a/tests/test_statepoint_restart/test_statepoint_restart.py +++ b/tests/test_statepoint_restart/test_statepoint_restart.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py index 157210de6f..c7221c90c2 100644 --- a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py +++ b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +import glob +import os import sys + sys.path.insert(0, '..') from testing_harness import * diff --git a/tests/test_track_output/test_track_output.py b/tests/test_track_output/test_track_output.py index 1192d1b3a3..dc0eb1a69d 100644 --- a/tests/test_track_output/test_track_output.py +++ b/tests/test_track_output/test_track_output.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +import glob +import os import shutil import sys