From 560eee2a5568d0fec93f7a3350e08adb5117ab42 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Sun, 2 Aug 2020 22:58:10 +0200 Subject: [PATCH] rm old PyStandard --- Tests/Functional/Python/CMakeLists.txt | 1 - .../Python/PyStandard/CMakeLists.txt | 78 ----------------- .../Python/PyStandard/PyStandardTest.cpp | 84 ------------------- .../Python/PyStandard/PyStandardTest.h | 31 ------- Tests/Functional/Python/PyStandard/main.cpp | 23 ----- Tests/Functional/Python/Std/Check.cpp | 1 - 6 files changed, 218 deletions(-) delete mode 100644 Tests/Functional/Python/PyStandard/CMakeLists.txt delete mode 100644 Tests/Functional/Python/PyStandard/PyStandardTest.cpp delete mode 100644 Tests/Functional/Python/PyStandard/PyStandardTest.h delete mode 100644 Tests/Functional/Python/PyStandard/main.cpp diff --git a/Tests/Functional/Python/CMakeLists.txt b/Tests/Functional/Python/CMakeLists.txt index da5514acd2d..2382fd012d3 100644 --- a/Tests/Functional/Python/CMakeLists.txt +++ b/Tests/Functional/Python/CMakeLists.txt @@ -1,7 +1,6 @@ # Collection of Python related tests add_subdirectory(Std) -add_subdirectory(PyStandard) add_subdirectory(PyExamples) add_subdirectory(PyCore) add_subdirectory(PyFit) diff --git a/Tests/Functional/Python/PyStandard/CMakeLists.txt b/Tests/Functional/Python/PyStandard/CMakeLists.txt deleted file mode 100644 index 86a40daeef7..00000000000 --- a/Tests/Functional/Python/PyStandard/CMakeLists.txt +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################ -# Tests/Functional/PyCore/suite/CMakeLists.txt -############################################################################ - -set(test TestPyStandard) - -set(output_dir ${TEST_OUTPUT_DIR}/Functional/Python/PyStandard) -file(MAKE_DIRECTORY ${output_dir}) - -set(test_cases - ApproximationDA - ApproximationLMA - ApproximationSSCA - Basic2DParaCrystal - BeamDivergence - BoxCompositionRotateX - BoxCompositionRotateY - BoxCompositionRotateZ - BoxCompositionRotateZandY - BoxesWithSpecular - BoxStackComposition - CenteredSquareLattice - ConstantBackground - CoreShellBoxRotateZandY - CoreShellParticle - CosineRipple - CylindersAndPrisms - CylindersInSSCA - CylindersWithSizeDistribution - DetectorResolution - FormFactors - GISASAbsorptiveSLDLayers - HexParaCrystal - LargeCylindersMonteCarlo - Lattice1D - MagneticSpheres - MultiLayerWithRoughness - MultipleLayout - ParticleComposition - RadialParaCrystal - HardDisk - RectDetectorGeneric - RectDetectorPerpToDirectBeam - RectDetectorPerpToReflectedBeam - RectDetectorPerpToReflectedBeamDpos - RectDetectorPerpToSample - RectParaCrystal - RotatedCylinder - RotatedPyramids - RotatedSquareLattice - FiniteSquareLattice - SimulationWithMasks - SquareLattice - TransformBox - TriangularRipple - AsymRipple - TwoTypesCylindersDistribution - SphericalDetWithRoi - RectDetWithRoi - SlicedComposition - RotatedPyramidsDistribution - SpheresWithLimitsDistribution - ConesWithLimitsDistribution - LinkedBoxDistribution - OffSpecularResonator - GaussianBeamFootprint - SpecularDivergentBeam - HomogeneousTiNiSampleWithAbsorption - RelativeResolutionTOF -) - -add_executable(${test} main.cpp PyStandardTest.h PyStandardTest.cpp) -target_link_libraries(${test} BornAgainCore BornAgainTestMachinery) - -foreach(test_case ${test_cases}) - add_test(${test}/${test_case} - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test} ${test_case}) -endforeach() diff --git a/Tests/Functional/Python/PyStandard/PyStandardTest.cpp b/Tests/Functional/Python/PyStandard/PyStandardTest.cpp deleted file mode 100644 index f829b424346..00000000000 --- a/Tests/Functional/Python/PyStandard/PyStandardTest.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Python/PyStandard/PyStandardTest.cpp -//! @brief Implements class PyExportTest -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#include "Tests/Functional/Python/PyStandard/PyStandardTest.h" -#include "BABuild.h" -#include "BATesting.h" -#include "Core/Export/ExportToPython.h" -#include "Core/InputOutput/IntensityDataIOFactory.h" -#include "Core/Instrument/IntensityDataFunctions.h" -#include "Core/Simulation/Simulation.h" -#include "Core/Tools/FileSystemUtils.h" -#include <cassert> -#include <fstream> -#include <iostream> - -std::unique_ptr<OutputData<double>> domainData(const std::string& test_name, - const Simulation& direct_simulation) -{ - const std::string output_name = - FileSystemUtils::jointPath(BATesting::PyStandardOutputDir(), test_name); - const std::string output_path = output_name + ".ref.int.gz"; - std::remove(output_path.c_str()); - std::cout << "- removed old output " << output_path << "\n"; - - // Generate Python script - const std::string pyscript_filename = - FileSystemUtils::jointPath(BATesting::PyStandardOutputDir(), test_name + ".py"); - std::ofstream pythonFile(pyscript_filename); - pythonFile << ExportToPython::generatePyExportTest(direct_simulation); - pythonFile.close(); - - // Run Python script - const std::string py_command = pyscript_filename + " " + output_path; -#ifndef _WIN32 - const std::string sys_command = std::string("PYTHONPATH=") + BABuild::buildLibDir() + " " - + std::string("NOPLOT=TRUE") + " " + BABuild::pythonExecutable() - + " -B " + py_command; -#else - const std::string sys_command = std::string("set PYTHONPATH=") + BABuild::buildLibDir() + " & " - + std::string("set NOPLOT=TRUE") + " & \"" - + BABuild::pythonExecutable() + "\" -B " + py_command; -#endif - std::cout << "- system call: " << sys_command << std::endl; // note: endl = \n + flush - int ret = std::system(sys_command.c_str()); - if (ret != 0) { - std::stringstream msg; - msg << "System call returned non-zero value " << ret; - throw std::runtime_error(msg.str()); - } - - return std::unique_ptr<OutputData<double>>(IntensityDataIOFactory::readOutputData(output_path)); -} - -bool checkSimulation(const std::string& name, const Simulation& direct_simulation, - const double limit) -{ - const std::unique_ptr<OutputData<double>> domain_data = domainData(name, direct_simulation); - - const std::unique_ptr<OutputData<double>> ref_data = direct_simulation.result().data(); - - return IntensityDataFunctions::checkRelativeDifference(*domain_data, *ref_data, limit); -} - -//! Runs simulation via a Python script and directly, and returns true if the results agree. -bool PyStandardTest::runTest() -{ - assert(m_name != ""); - - std::cout << "- run direct simulation\n"; - m_reference_simulation->runSimulation(); - - return checkSimulation(m_name, *m_reference_simulation, m_threshold); -} diff --git a/Tests/Functional/Python/PyStandard/PyStandardTest.h b/Tests/Functional/Python/PyStandard/PyStandardTest.h deleted file mode 100644 index 200b847bcde..00000000000 --- a/Tests/Functional/Python/PyStandard/PyStandardTest.h +++ /dev/null @@ -1,31 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Python/PyStandard/PyStandardTest.h -//! @brief Defines class PyStandardTest -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#ifndef BORNAGAIN_TESTS_FUNCTIONAL_PYTHON_PYSTANDARD_PYSTANDARDTEST_H -#define BORNAGAIN_TESTS_FUNCTIONAL_PYTHON_PYSTANDARD_PYSTANDARDTEST_H - -#include "Tests/Functional/Std/IStandardTest.h" - -//! Tests Python scripts generation from Core objects. -//! Performs core standard simulation and checks it against simulation via generated Python script. - -class PyStandardTest : public IStandardTest -{ -public: - using IStandardTest::IStandardTest; - - bool runTest() final; -}; - -#endif // BORNAGAIN_TESTS_FUNCTIONAL_PYTHON_PYSTANDARD_PYSTANDARDTEST_H diff --git a/Tests/Functional/Python/PyStandard/main.cpp b/Tests/Functional/Python/PyStandard/main.cpp deleted file mode 100644 index fcf0295f5cb..00000000000 --- a/Tests/Functional/Python/PyStandard/main.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/Functional/Python/PyStandard/main.cpp -//! @brief Implements program PyStandardTest, to run functional tests -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************** // - -#include "Tests/Functional/Python/PyStandard/PyStandardTest.h" -#include "Tests/Functional/Std/StandardTestService.h" - -//! Runs PyStandardTest on a standard simulation indicated by argv[1]. - -int main(int argc, char** argv) -{ - return !StandardTestService<PyStandardTest>().execute(argc, argv); -} diff --git a/Tests/Functional/Python/Std/Check.cpp b/Tests/Functional/Python/Std/Check.cpp index b0c95861155..6ee8f8c3a4e 100644 --- a/Tests/Functional/Python/Std/Check.cpp +++ b/Tests/Functional/Python/Std/Check.cpp @@ -12,7 +12,6 @@ // // ************************************************************************** // -#include "Tests/Functional/Python/PyStandard/PyStandardTest.h" #include "BABuild.h" #include "BATesting.h" #include "Core/Export/ExportToPython.h" -- GitLab