diff --git a/paramak/parametric_neutronics/neutronics_model.py b/paramak/parametric_neutronics/neutronics_model.py index b6b4bb44c..def689647 100644 --- a/paramak/parametric_neutronics/neutronics_model.py +++ b/paramak/parametric_neutronics/neutronics_model.py @@ -9,13 +9,13 @@ try: import openmc -except BaseException: +except ImportError: warnings.warn('OpenMC not found, NeutronicsModelFromReactor.simulate \ method not available', UserWarning) try: import neutronics_material_maker as nmm -except BaseException: +except ImportError: warnings.warn("neutronics_material_maker not found, \ NeutronicsModelFromReactor.materials can't accept strings or \ neutronics_material_maker objects", UserWarning) @@ -305,7 +305,8 @@ def create_neutronics_geometry(self, method=None): self.geometry.export_neutronics_description() if not Path("make_faceteted_neutronics_model.py").is_file(): - raise ValueError("The make_faceteted_neutronics_model.py was \ + raise FileNotFoundError( + "The make_faceteted_neutronics_model.py was \ not found in the directory") os.system("trelis -batch -nographics make_faceteted_neutronics_model.py \"faceting_tolerance='" + str(self.faceting_tolerance) + "'\" \"merge_tolerance='" + str(self.merge_tolerance) + "'\"") @@ -541,7 +542,7 @@ def get_results(self): results = defaultdict(dict) # access the tallies - for key, tally in sp.tallies.items(): + for tally in sp.tallies.values(): if tally.name == 'TBR': diff --git a/paramak/shape.py b/paramak/shape.py index 39fac1e21..dc0c3e949 100644 --- a/paramak/shape.py +++ b/paramak/shape.py @@ -593,9 +593,7 @@ def create_solid(self): if list(entry.keys())[0] == "straight": solid = solid.polyline(list(entry.values())[0]) if list(entry.keys())[0] == "circle": - p0 = list(entry.values())[0][0] - p1 = list(entry.values())[0][1] - p2 = list(entry.values())[0][2] + p0, p1, p2 = list(entry.values())[0][:3] solid = solid.moveTo( p0[0], p0[1]).threePointArc( p1, p2) diff --git a/tests/test_Reactor.py b/tests/test_Reactor.py index 2c99cce1f..0f1335f72 100644 --- a/tests/test_Reactor.py +++ b/tests/test_Reactor.py @@ -91,26 +91,6 @@ def test_stp_filename_duplication(): self.assertRaises(ValueError, test_stp_filename_duplication) - def test_adding_shape_with_duplicate_stl_filename_to_reactor(self): - """Adds shapes to a Reactor object to checks errors are raised - correctly""" - - def test_stl_filename_duplication(): - """Checks ValueError is raised when shapes with the same stl - filenames are added to a reactor object""" - - test_shape_1 = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl" - ) - test_shape_2 = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl" - ) - test_shape_1.rotation_angle = 90 - my_reactor = paramak.Reactor([test_shape_1, test_shape_2]) - my_reactor.export_stl() - - sefl.assertRaises(ValueError, test_stl_filename_duplication) - def test_adding_shape_with_None_stp_filename_to_reactor(self): """adds shapes to a Reactor object to check errors are raised correctly""" @@ -131,19 +111,37 @@ def test_stp_filename_None(): self.assertRaises(ValueError, test_stp_filename_None) def test_adding_shape_with_duplicate_stl_filename_to_reactor(self): + """Adds shapes to a Reactor object to checks errors are raised + correctly""" + + def test_stl_filename_duplication(): + """Checks ValueError is raised when shapes with the same stl + filenames are added to a reactor object""" + + test_shape_1 = paramak.RotateStraightShape( + points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl" + ) + test_shape_2 = paramak.RotateSplineShape( + points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl" + ) + test_shape_1.rotation_angle = 90 + my_reactor = paramak.Reactor([test_shape_1, test_shape_2]) + my_reactor.export_stl() + + self.assertRaises(ValueError, test_stl_filename_duplication) + + def test_adding_shape_with_the_same_default_stl_filename_to_reactor(self): """Adds shapes to a Reactor object to check errors are raised correctly.""" def test_stl_filename_duplication_rotate_straight(): """checks ValueError is raised when RotateStraightShapes with - duplicate stl filenames are added""" + duplicate stl filenames (defaults) are added""" test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl" - ) + points=[(0, 0), (0, 20), (20, 20)]) test_shape2 = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl" - ) + points=[(0, 0), (0, 20), (20, 20)]) test_shape.rotation_angle = 360 test_shape.create_solid() my_reactor = paramak.Reactor([test_shape, test_shape2]) diff --git a/tests/test_parametric_neutronics/test_NeutronicModel.py b/tests/test_parametric_neutronics/test_NeutronicModel.py index 7eaac82ab..c719f39ba 100644 --- a/tests/test_parametric_neutronics/test_NeutronicModel.py +++ b/tests/test_parametric_neutronics/test_NeutronicModel.py @@ -89,7 +89,7 @@ def incorrect_faceting_tolerance(): ) self.assertRaises( - ValueError, + TypeError, incorrect_faceting_tolerance ) @@ -117,7 +117,7 @@ def incorrect_merge_tolerance(): ) self.assertRaises( - ValueError, + TypeError, incorrect_merge_tolerance ) @@ -172,7 +172,7 @@ def incorrect_materials(): ) self.assertRaises( - ValueError, + TypeError, incorrect_materials ) diff --git a/tests/test_parametric_shapes/test_SweepStraightShape.py b/tests/test_parametric_shapes/test_SweepStraightShape.py index 64e7a5de4..b36d11385 100644 --- a/tests/test_parametric_shapes/test_SweepStraightShape.py +++ b/tests/test_parametric_shapes/test_SweepStraightShape.py @@ -41,7 +41,7 @@ def test_relative_shape_volume(self): self.test_shape.points = [(-20, 20), (20, 20), (20, -20), (-20, -20)] assert self.test_shape.volume == pytest.approx(test_volume * 4) - def test_relative_shape_volume(self): + def test_relative_shape_volume_again(self): """Creates two SweepStraightShapes and checks that their relative volumes are correct."""