diff --git a/Tests/Py/Functional/PyFuTestInfrastructure.py b/Tests/Py/Functional/PyFuTestInfrastructure.py index 3ff7b7a14a29c2b34c95a5c3155ff4332ba70c5a..3eb8226b533b088932cc34ee9e6034a47b8ffdcf 100644 --- a/Tests/Py/Functional/PyFuTestInfrastructure.py +++ b/Tests/Py/Functional/PyFuTestInfrastructure.py @@ -5,9 +5,22 @@ Collection of utils for testing import bornagain as ba from bornagain import deg, angstrom -# same as test::makeSimulation::MiniGISAS + def get_simulation_MiniGISAS(sample): n = 25 detector = ba.SphericalDetector(n, -2 * deg, 2 * deg, n, 0, 2 * deg) beam = ba.Beam(1., 1 * angstrom, ba.Direction(0.2 * deg, 0)) return ba.ScatteringSimulation(beam, sample, detector) + +def diff_MiniGISAS(sample1, sample2): + """ + Run standard GISAS simulation for two sample models, and return diff of results. + """ + n = 11 + detector = ba.SphericalDetector(n, 0, 5 * deg, n, 0, 4 * deg) + beam = ba.Beam(1., 1 * angstrom, ba.Direction(0.2 * deg, 0)) + + data1 = ba.ScatteringSimulation(beam, sample1, detector).simulate() + data2 = ba.ScatteringSimulation(beam, sample2, detector).simulate() + + return ba.meanRelativeDifference(data1, data2) diff --git a/Tests/Py/Functional/slicing.py b/Tests/Py/Functional/slicing.py index 597f0e316162465213bde2850362bc349ebb1235..d7771717927f2a5cce0718d27769a4264eacfc78 100644 --- a/Tests/Py/Functional/slicing.py +++ b/Tests/Py/Functional/slicing.py @@ -42,18 +42,12 @@ class SlicedSpheresTest(unittest.TestCase): return 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) particle = ba.Particle(matSubstrate, ff) - dataA = self.get_result(particle, False) - dataB = self.get_result(particle, True) - diff = ba.meanRelativeDifference(dataA, dataB) + diff = infrastruct.diff_MiniGISAS(self.get_sample(particle, False), + self.get_sample(particle, True)) self.assertLess(diff, 1e-13)