From 1624317d0256b1e6a3ea6078f00480c4bd658743 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Dec 2022 17:33:17 +0100 Subject: [PATCH] Tests/Py/Fu: rename -> PyFuTestInfrastructure --- Tests/Py/Functional/CMakeLists.txt | 8 +++++--- .../{utils.py => PyFuTestInfrastructure.py} | 0 Tests/Py/Functional/sliced_compounds.py | 4 ++-- Tests/Py/Functional/sliced_spheres.py | 4 ++-- Tests/Py/Functional/slicing.py | 18 +++++++++--------- .../Py/Functional/transform_BoxComposition.py | 4 ++-- Tests/Py/Functional/transform_CoreShellBox.py | 4 ++-- Tests/Py/Functional/transform_box.py | 4 ++-- Tests/Py/Functional/transform_cube.py | 4 ++-- 9 files changed, 26 insertions(+), 24 deletions(-) rename Tests/Py/Functional/{utils.py => PyFuTestInfrastructure.py} (100%) diff --git a/Tests/Py/Functional/CMakeLists.txt b/Tests/Py/Functional/CMakeLists.txt index 0c9861a7e79..cc69f00ad51 100644 --- a/Tests/Py/Functional/CMakeLists.txt +++ b/Tests/Py/Functional/CMakeLists.txt @@ -5,10 +5,12 @@ set(OUTPUT_DIR ${TEST_OUTPUT_DIR_PY_CORE}) file(MAKE_DIRECTORY ${OUTPUT_DIR}) +set(infrastructure PyFuTestInfrastructure.py) file(GLOB tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py) -list(REMOVE_ITEM tests utils.py) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils.py ${OUTPUT_DIR}/utils.py @ONLY) +foreach(util ${infrastructure}) + list(REMOVE_ITEM tests ${util}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${util} ${OUTPUT_DIR}/${util} @ONLY) +endforeach() foreach(_test ${tests}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${_test} ${OUTPUT_DIR}/${_test} COPYONLY) diff --git a/Tests/Py/Functional/utils.py b/Tests/Py/Functional/PyFuTestInfrastructure.py similarity index 100% rename from Tests/Py/Functional/utils.py rename to Tests/Py/Functional/PyFuTestInfrastructure.py diff --git a/Tests/Py/Functional/sliced_compounds.py b/Tests/Py/Functional/sliced_compounds.py index 7a7eca9e3a2..e0889771cf0 100644 --- a/Tests/Py/Functional/sliced_compounds.py +++ b/Tests/Py/Functional/sliced_compounds.py @@ -3,7 +3,7 @@ Check slicing mechanism for compound particles crossing an interface. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct import bornagain as ba from bornagain import deg, R3 @@ -40,7 +40,7 @@ class SlicedSpheresTest(unittest.TestCase): def get_result(self, particle_to_air=None, particle_to_substrate=None): sample = self.get_sample(particle_to_air, particle_to_substrate) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def get_compound(self, top_material, bottom_material): diff --git a/Tests/Py/Functional/sliced_spheres.py b/Tests/Py/Functional/sliced_spheres.py index 2250c8673e1..aa76bda30d2 100644 --- a/Tests/Py/Functional/sliced_spheres.py +++ b/Tests/Py/Functional/sliced_spheres.py @@ -3,7 +3,7 @@ Check slicing mechanism for spherical particles crossing an interface. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct import bornagain as ba matSubstrate = ba.RefractiveMaterial("Substrate", 3.2e-6, 3.2e-8) @@ -40,7 +40,7 @@ class SlicedSpheresTest(unittest.TestCase): def get_result(self, particle_to_air=None, particle_to_substrate=None): sample = self.get_sample(particle_to_air, particle_to_substrate) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def testSphericalCupOnTopOfSubstrate(self): diff --git a/Tests/Py/Functional/slicing.py b/Tests/Py/Functional/slicing.py index afdb41754d7..597f0e31616 100644 --- a/Tests/Py/Functional/slicing.py +++ b/Tests/Py/Functional/slicing.py @@ -5,7 +5,7 @@ Check automatic slicing by comparing scattering from particle in decorated_layer """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct import bornagain as ba matVacuum = ba.RefractiveMaterial("Vacuum", 0, 0) @@ -18,13 +18,13 @@ dz = 4.0 # shift beneath interface class SlicedSpheresTest(unittest.TestCase): - def get_sample(self, ff, sliced): + def get_sample(self, particle, sliced): """ Returns a sample, with given particles attached to substrate or vacuum layer. """ layout = ba.ParticleLayout() - layout.addParticle(ba.Particle(matSubstrate, ff)) + layout.addParticle(particle) sample = ba.MultiLayer() sample.addLayer(ba.Layer(matVacuum)) @@ -42,16 +42,16 @@ class SlicedSpheresTest(unittest.TestCase): return sample - def get_result(self, ff, sliced): - sample = self.get_sample(ff, sliced) - simulation = utils.get_simulation_MiniGISAS(sample) + def get_result(self, particle, sliced): + sample = self.get_sample(particle, sliced) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def testSlicingPyramid(self): ff = ba.Pyramid3(8., 10., 80*ba.deg) - - dataA = self.get_result(ff, False) - dataB = self.get_result(ff, True) + particle = ba.Particle(matSubstrate, ff) + dataA = self.get_result(particle, False) + dataB = self.get_result(particle, True) diff = ba.meanRelativeDifference(dataA, dataB) self.assertLess(diff, 1e-13) diff --git a/Tests/Py/Functional/transform_BoxComposition.py b/Tests/Py/Functional/transform_BoxComposition.py index 93515e84d0d..2adb63f092a 100644 --- a/Tests/Py/Functional/transform_BoxComposition.py +++ b/Tests/Py/Functional/transform_BoxComposition.py @@ -9,7 +9,7 @@ middle layer of 3 layers system. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct from bornagain import * layer_thickness = 100.0 @@ -43,7 +43,7 @@ class TransformBoxCompositionTest(unittest.TestCase): def get_result(self, particle): sample = self.get_sample(particle) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def test_BoxComposition(self): diff --git a/Tests/Py/Functional/transform_CoreShellBox.py b/Tests/Py/Functional/transform_CoreShellBox.py index 50b110585a6..f684fe47ec0 100644 --- a/Tests/Py/Functional/transform_CoreShellBox.py +++ b/Tests/Py/Functional/transform_CoreShellBox.py @@ -7,7 +7,7 @@ Particles are placed in the center of middle layer. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct from bornagain import * mAmbience = RefractiveMaterial("Vacuum", 0, 0) @@ -39,7 +39,7 @@ class TransformCoreShellBoxTest(unittest.TestCase): def get_result(self, particle): sample = self.get_sample(particle) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def test_SameMaterialCoreShellBox(self): diff --git a/Tests/Py/Functional/transform_box.py b/Tests/Py/Functional/transform_box.py index 5f7bcac8645..d232005b27d 100644 --- a/Tests/Py/Functional/transform_box.py +++ b/Tests/Py/Functional/transform_box.py @@ -7,7 +7,7 @@ compared with Box(10, 50, 20) import unittest import bornagain as ba from bornagain import deg, R3 -import utils +import PyFuTestInfrastructure as infrastruct layer_thickness = 100 @@ -35,7 +35,7 @@ class BoxTransformationsTest(unittest.TestCase): def get_result(self, particle): sample = self.get_sample(particle) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def testBoxTransform(self): diff --git a/Tests/Py/Functional/transform_cube.py b/Tests/Py/Functional/transform_cube.py index bdc8c272760..734019f158c 100644 --- a/Tests/Py/Functional/transform_cube.py +++ b/Tests/Py/Functional/transform_cube.py @@ -4,7 +4,7 @@ Original particle is compared with the one obtained. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct from bornagain import * @@ -61,7 +61,7 @@ class RotationsCubeTest(unittest.TestCase): layout_pos = data[4] sample = self.get_sample(ff, rot, pos, layout_rot, layout_pos, add_to) # simulation = self.get_simulation(sample) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def get_difference(self, reference_data, test_data, add_to="Vacuum"): -- GitLab