From e9feab3c5d1c5d92f414af7641daba8c21c49981 Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Mon, 4 Nov 2013 15:34:21 +0100 Subject: [PATCH] AxisDouble, getIntensityData are exposed into Python --- App/src/TestDetectorResolution.cpp | 2 +- App/src/TestFourier.cpp | 2 +- App/src/TestIsGISAXS14.cpp | 2 +- App/src/TestMesoCrystal1.cpp | 2 +- App/src/TestRootTree.cpp | 4 +- Core/Algorithms/inc/Simulation.h | 2 +- .../inc/{ndimdata_t.pypp.h => AxisBin.pypp.h} | 8 +- Core/PythonAPI/inc/AxisDouble.pypp.h | 11 + Core/PythonAPI/inc/IntensityData.pypp.h | 11 + Core/PythonAPI/inc/PythonCoreExposer.h | 3 +- Core/PythonAPI/inc/PythonCoreList.h | 3 + Core/PythonAPI/src/AxisBin.pypp.cpp | 260 ++++++++++++++ Core/PythonAPI/src/AxisDouble.pypp.cpp | 240 +++++++++++++ ...data_t.pypp.cpp => IntensityData.pypp.cpp} | 72 ++-- Core/PythonAPI/src/PythonModule.cpp | 10 +- Core/PythonAPI/src/Simulation.pypp.cpp | 20 +- Core/Tools/inc/AxisDouble.h | 3 +- Core/python_module.pri | 8 +- Tests/FunctionalTests/CMakeLists.txt | 3 + .../TestCore/IsGISAXS01/IsGISAXS01.cpp | 2 +- .../TestCore/IsGISAXS02/IsGISAXS02.cpp | 2 +- .../TestCore/IsGISAXS03/IsGISAXS03.cpp | 6 +- .../TestCore/IsGISAXS04/IsGISAXS04.cpp | 4 +- .../TestCore/IsGISAXS06/IsGISAXS06.cpp | 10 +- .../TestCore/IsGISAXS07/IsGISAXS07.cpp | 2 +- .../TestCore/IsGISAXS08/IsGISAXS08.cpp | 4 +- .../TestCore/IsGISAXS09/IsGISAXS09.cpp | 4 +- .../TestCore/IsGISAXS10/IsGISAXS10.cpp | 2 +- .../TestCore/IsGISAXS11/IsGISAXS11.cpp | 2 +- .../TestCore/IsGISAXS15/IsGISAXS15.cpp | 2 +- .../TestFit/TestFit01/TestFit01.cpp | 2 +- .../TestFit/TestFit02/TestFit02.cpp | 2 +- Tests/FunctionalTests/TestPyFit/testfit01.py | 2 +- Tests/FunctionalTests/TestPyFit/testfit02.py | 2 +- dev-tools/python-bindings/MakePyCore.py | 327 +++++++++--------- dev-tools/python-bindings/builder_utils.py | 10 +- 36 files changed, 795 insertions(+), 256 deletions(-) rename Core/PythonAPI/inc/{ndimdata_t.pypp.h => AxisBin.pypp.h} (52%) create mode 100644 Core/PythonAPI/inc/AxisDouble.pypp.h create mode 100644 Core/PythonAPI/inc/IntensityData.pypp.h create mode 100644 Core/PythonAPI/src/AxisBin.pypp.cpp create mode 100644 Core/PythonAPI/src/AxisDouble.pypp.cpp rename Core/PythonAPI/src/{ndimdata_t.pypp.cpp => IntensityData.pypp.cpp} (87%) diff --git a/App/src/TestDetectorResolution.cpp b/App/src/TestDetectorResolution.cpp index 005dde304e4..93678a0f7f2 100644 --- a/App/src/TestDetectorResolution.cpp +++ b/App/src/TestDetectorResolution.cpp @@ -40,7 +40,7 @@ void TestDetectorResolution::execute() simulation.setBeamParameters (1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree); simulation.runSimulation(); - mp_intensity_output = simulation.getOutputDataClone(); + mp_intensity_output = simulation.getIntensityData(); IsGISAXSTools::drawLogOutputData (*mp_intensity_output, "c1_test_detector_resolution", diff --git a/App/src/TestFourier.cpp b/App/src/TestFourier.cpp index 4aec3e2bf3b..946d38029ae 100644 --- a/App/src/TestFourier.cpp +++ b/App/src/TestFourier.cpp @@ -50,7 +50,7 @@ void TestFourier::execute() simulation.runSimulation(); simulation.normalize(); - mp_intensity_output = simulation.getOutputDataClone(); + mp_intensity_output = simulation.getIntensityData(); OutputData<complex_t> fft_map; OutputDataFunctions::FourierTransform(*mp_intensity_output, &fft_map); OutputData<double> *p_real_fft_map = OutputDataFunctions::getModulusPart(fft_map); diff --git a/App/src/TestIsGISAXS14.cpp b/App/src/TestIsGISAXS14.cpp index e9e74e04c86..b491e19ff3b 100644 --- a/App/src/TestIsGISAXS14.cpp +++ b/App/src/TestIsGISAXS14.cpp @@ -41,7 +41,7 @@ void TestIsGISAXS14::execute() simulation.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true); simulation.setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree); simulation.runSimulation(); - OutputDataIOFactory::writeOutputData(*simulation.getOutputDataClone(), "this_multilayer_sphere.ima"); + OutputDataIOFactory::writeOutputData(*simulation.getIntensityData(), "this_multilayer_sphere.ima"); } diff --git a/App/src/TestMesoCrystal1.cpp b/App/src/TestMesoCrystal1.cpp index f847c71937c..f02dd6016aa 100644 --- a/App/src/TestMesoCrystal1.cpp +++ b/App/src/TestMesoCrystal1.cpp @@ -76,7 +76,7 @@ void TestMesoCrystal1::execute() simulation.runSimulation(); simulation.normalize(); - mp_intensity_output = simulation.getOutputDataClone(); + mp_intensity_output = simulation.getIntensityData(); TCanvas *c1 = DrawHelper::createAndRegisterCanvas("sim_meso_crystal", "mesocrystal", 1024, 768); diff --git a/App/src/TestRootTree.cpp b/App/src/TestRootTree.cpp index b0b957f458c..3b8d823c768 100644 --- a/App/src/TestRootTree.cpp +++ b/App/src/TestRootTree.cpp @@ -134,7 +134,7 @@ void TestRootTree::complex_write() event->malpha = Units::rad2deg(meso_alpha); // copying output data into event frame delete mp_data; - mp_data = simulation.getOutputDataClone(); + mp_data = simulation.getIntensityData(); IsGISAXSTools::exportOutputDataInVectors2D( *mp_data, event->vi, event->vphi_f, event->valpha_f); @@ -267,7 +267,7 @@ void TestRootTree::simple_write() 1.0*Units::angstrom, alpha_i*Units::degree, phi_i); mp_simulation->runSimulation(); - mp_data = mp_simulation->getOutputDataClone(); + mp_data = mp_simulation->getIntensityData(); // accessing to scattering data const IAxis *axis0 = mp_data->getAxis(0); const IAxis *axis1 = mp_data->getAxis(1); diff --git a/Core/Algorithms/inc/Simulation.h b/Core/Algorithms/inc/Simulation.h index e274a7f8f99..f8a9e9c40b8 100644 --- a/Core/Algorithms/inc/Simulation.h +++ b/Core/Algorithms/inc/Simulation.h @@ -63,7 +63,7 @@ public: const OutputData<double>* getOutputData() const { return &m_intensity_map; } //! Clone detector intensity map for all scan parameters. - OutputData<double>* getOutputDataClone() const + OutputData<double>* getIntensityData() const { return m_intensity_map.clone(); } #ifndef GCCXML_SKIP_THIS diff --git a/Core/PythonAPI/inc/ndimdata_t.pypp.h b/Core/PythonAPI/inc/AxisBin.pypp.h similarity index 52% rename from Core/PythonAPI/inc/ndimdata_t.pypp.h rename to Core/PythonAPI/inc/AxisBin.pypp.h index 372e33540ff..20dd1a8e34d 100644 --- a/Core/PythonAPI/inc/ndimdata_t.pypp.h +++ b/Core/PythonAPI/inc/AxisBin.pypp.h @@ -3,9 +3,9 @@ // BornAgain: simulate and fit scattering at grazing incidence //! @brief automatically generated boost::python code for PythonCoreAPI -#ifndef ndimdata_t_hpp__pyplusplus_wrapper -#define ndimdata_t_hpp__pyplusplus_wrapper +#ifndef AxisBin_hpp__pyplusplus_wrapper +#define AxisBin_hpp__pyplusplus_wrapper -void register_ndimdata_t_class(); +void register_AxisBin_class(); -#endif//ndimdata_t_hpp__pyplusplus_wrapper +#endif//AxisBin_hpp__pyplusplus_wrapper diff --git a/Core/PythonAPI/inc/AxisDouble.pypp.h b/Core/PythonAPI/inc/AxisDouble.pypp.h new file mode 100644 index 00000000000..667afd5ff18 --- /dev/null +++ b/Core/PythonAPI/inc/AxisDouble.pypp.h @@ -0,0 +1,11 @@ +// This file has been generated by Py++. + +// BornAgain: simulate and fit scattering at grazing incidence +//! @brief automatically generated boost::python code for PythonCoreAPI + +#ifndef AxisDouble_hpp__pyplusplus_wrapper +#define AxisDouble_hpp__pyplusplus_wrapper + +void register_AxisDouble_class(); + +#endif//AxisDouble_hpp__pyplusplus_wrapper diff --git a/Core/PythonAPI/inc/IntensityData.pypp.h b/Core/PythonAPI/inc/IntensityData.pypp.h new file mode 100644 index 00000000000..81597a7d058 --- /dev/null +++ b/Core/PythonAPI/inc/IntensityData.pypp.h @@ -0,0 +1,11 @@ +// This file has been generated by Py++. + +// BornAgain: simulate and fit scattering at grazing incidence +//! @brief automatically generated boost::python code for PythonCoreAPI + +#ifndef IntensityData_hpp__pyplusplus_wrapper +#define IntensityData_hpp__pyplusplus_wrapper + +void register_IntensityData_class(); + +#endif//IntensityData_hpp__pyplusplus_wrapper diff --git a/Core/PythonAPI/inc/PythonCoreExposer.h b/Core/PythonAPI/inc/PythonCoreExposer.h index 87295abebf9..64165a34221 100644 --- a/Core/PythonAPI/inc/PythonCoreExposer.h +++ b/Core/PythonAPI/inc/PythonCoreExposer.h @@ -37,7 +37,7 @@ namespace pyplusplus { typedef std::vector<IFormFactor *> vector_IFormFactorPtr_t; typedef ISingleton<MaterialManager> MaterialManagerSingleton_t; typedef StochasticParameter<double> StochasticParameter_t; - typedef OutputData<double > ndimdata_t; + typedef OutputData<double > IntensityData; typedef std::vector<int > vector_integer_t; typedef std::vector<unsigned long int > vector_longinteger_t; } @@ -60,6 +60,7 @@ namespace pyplusplus { inline size_t pyplusplus_boost_stochastic_parameter() { return sizeof(pyplusplus::aliases::StochasticParameter_t); } inline size_t pyplusplus_boost_vector_integer() { return sizeof(pyplusplus::aliases::vector_integer_t); } inline size_t pyplusplus_boost_vector_longinteger() { return sizeof(pyplusplus::aliases::vector_longinteger_t); } + inline size_t pyplusplus_boost_intensity_data() { return sizeof(pyplusplus::aliases::IntensityData); } } #endif // PYTHONCOREEXPOSER_H diff --git a/Core/PythonAPI/inc/PythonCoreList.h b/Core/PythonAPI/inc/PythonCoreList.h index ccd0e8c5dc6..3d5cb03cdf7 100644 --- a/Core/PythonAPI/inc/PythonCoreList.h +++ b/Core/PythonAPI/inc/PythonCoreList.h @@ -3,6 +3,9 @@ //! list of files to process with Py++ +#include "IAxis.h" +#include "AxisBin.h" +#include "AxisDouble.h" #include "BasicVector3D.h" #include "BAVersion.h" #include "Bin.h" diff --git a/Core/PythonAPI/src/AxisBin.pypp.cpp b/Core/PythonAPI/src/AxisBin.pypp.cpp new file mode 100644 index 00000000000..c0c871047c1 --- /dev/null +++ b/Core/PythonAPI/src/AxisBin.pypp.cpp @@ -0,0 +1,260 @@ +// This file has been generated by Py++. + +// BornAgain: simulate and fit scattering at grazing incidence +//! @brief automatically generated boost::python code for PythonCoreAPI + +#include "Macros.h" +GCC_DIAG_OFF(unused-parameter); +GCC_DIAG_OFF(missing-field-initializers); +#include "boost/python.hpp" +GCC_DIAG_ON(unused-parameter); +GCC_DIAG_ON(missing-field-initializers); +#include "PythonCoreList.h" +#include "AxisBin.pypp.h" + +namespace bp = boost::python; + +struct AxisBin_wrapper : AxisBin, bp::wrapper< AxisBin > { + + AxisBin_wrapper(AxisBin const & arg ) + : AxisBin( arg ) + , bp::wrapper< AxisBin >(){ + // copy constructor + + } + + AxisBin_wrapper(::std::string name ) + : AxisBin( name ) + , bp::wrapper< AxisBin >(){ + // constructor + + } + + AxisBin_wrapper(::std::string name, ::std::size_t nbr_bins, double start, double end ) + : AxisBin( name, nbr_bins, start, end ) + , bp::wrapper< AxisBin >(){ + // constructor + + } + + virtual ::AxisBin * clone( ) const { + if( bp::override func_clone = this->get_override( "clone" ) ) + return func_clone( ); + else + return this->AxisBin::clone( ); + } + + + ::AxisBin * default_clone( ) const { + return AxisBin::clone( ); + } + + virtual ::AxisBin * createDoubleBinSize( ) const { + if( bp::override func_createDoubleBinSize = this->get_override( "createDoubleBinSize" ) ) + return func_createDoubleBinSize( ); + else + return this->AxisBin::createDoubleBinSize( ); + } + + + ::AxisBin * default_createDoubleBinSize( ) const { + return AxisBin::createDoubleBinSize( ); + } + + virtual ::std::size_t findClosestIndex( double value ) const { + if( bp::override func_findClosestIndex = this->get_override( "findClosestIndex" ) ) + return func_findClosestIndex( value ); + else + return this->AxisBin::findClosestIndex( value ); + } + + + ::std::size_t default_findClosestIndex( double value ) const { + return AxisBin::findClosestIndex( value ); + } + + virtual ::Bin1D getBin( ::std::size_t index ) const { + if( bp::override func_getBin = this->get_override( "getBin" ) ) + return func_getBin( index ); + else + return this->AxisBin::getBin( index ); + } + + + ::Bin1D default_getBin( ::std::size_t index ) const { + return AxisBin::getBin( index ); + } + + virtual double getMax( ) const { + if( bp::override func_getMax = this->get_override( "getMax" ) ) + return func_getMax( ); + else + return this->AxisBin::getMax( ); + } + + + double default_getMax( ) const { + return AxisBin::getMax( ); + } + + virtual double getMin( ) const { + if( bp::override func_getMin = this->get_override( "getMin" ) ) + return func_getMin( ); + else + return this->AxisBin::getMin( ); + } + + + double default_getMin( ) const { + return AxisBin::getMin( ); + } + + virtual ::std::size_t getSize( ) const { + if( bp::override func_getSize = this->get_override( "getSize" ) ) + return func_getSize( ); + else + return this->AxisBin::getSize( ); + } + + + ::std::size_t default_getSize( ) const { + return AxisBin::getSize( ); + } + + virtual double operator[]( ::std::size_t index ) const { + if( bp::override func___getitem__ = this->get_override( "__getitem__" ) ) + return func___getitem__( index ); + else + return this->AxisBin::operator[]( index ); + } + + + double default___getitem__( ::std::size_t index ) const { + return AxisBin::operator[]( index ); + } + +}; + +void register_AxisBin_class(){ + + { //::AxisBin + typedef bp::class_< AxisBin_wrapper, bp::bases< IAxis > > AxisBin_exposer_t; + AxisBin_exposer_t AxisBin_exposer = AxisBin_exposer_t( "AxisBin", bp::init< std::string >(( bp::arg("name") )) ); + bp::scope AxisBin_scope( AxisBin_exposer ); + AxisBin_exposer.def( bp::init< std::string, std::size_t, double, double >(( bp::arg("name"), bp::arg("nbr_bins"), bp::arg("start"), bp::arg("end") )) ); + { //::AxisBin::clone + + typedef ::AxisBin * ( ::AxisBin::*clone_function_type )( ) const; + typedef ::AxisBin * ( AxisBin_wrapper::*default_clone_function_type )( ) const; + + AxisBin_exposer.def( + "clone" + , clone_function_type(&::AxisBin::clone) + , default_clone_function_type(&AxisBin_wrapper::default_clone) + , bp::return_value_policy< bp::manage_new_object >() ); + + } + { //::AxisBin::createDoubleBinSize + + typedef ::AxisBin * ( ::AxisBin::*createDoubleBinSize_function_type )( ) const; + typedef ::AxisBin * ( AxisBin_wrapper::*default_createDoubleBinSize_function_type )( ) const; + + AxisBin_exposer.def( + "createDoubleBinSize" + , createDoubleBinSize_function_type(&::AxisBin::createDoubleBinSize) + , default_createDoubleBinSize_function_type(&AxisBin_wrapper::default_createDoubleBinSize) + , bp::return_value_policy< bp::manage_new_object >() ); + + } + { //::AxisBin::findClosestIndex + + typedef ::std::size_t ( ::AxisBin::*findClosestIndex_function_type )( double ) const; + typedef ::std::size_t ( AxisBin_wrapper::*default_findClosestIndex_function_type )( double ) const; + + AxisBin_exposer.def( + "findClosestIndex" + , findClosestIndex_function_type(&::AxisBin::findClosestIndex) + , default_findClosestIndex_function_type(&AxisBin_wrapper::default_findClosestIndex) + , ( bp::arg("value") ) ); + + } + { //::AxisBin::getBin + + typedef ::Bin1D ( ::AxisBin::*getBin_function_type )( ::std::size_t ) const; + typedef ::Bin1D ( AxisBin_wrapper::*default_getBin_function_type )( ::std::size_t ) const; + + AxisBin_exposer.def( + "getBin" + , getBin_function_type(&::AxisBin::getBin) + , default_getBin_function_type(&AxisBin_wrapper::default_getBin) + , ( bp::arg("index") ) ); + + } + { //::AxisBin::getMax + + typedef double ( ::AxisBin::*getMax_function_type )( ) const; + typedef double ( AxisBin_wrapper::*default_getMax_function_type )( ) const; + + AxisBin_exposer.def( + "getMax" + , getMax_function_type(&::AxisBin::getMax) + , default_getMax_function_type(&AxisBin_wrapper::default_getMax) ); + + } + { //::AxisBin::getMin + + typedef double ( ::AxisBin::*getMin_function_type )( ) const; + typedef double ( AxisBin_wrapper::*default_getMin_function_type )( ) const; + + AxisBin_exposer.def( + "getMin" + , getMin_function_type(&::AxisBin::getMin) + , default_getMin_function_type(&AxisBin_wrapper::default_getMin) ); + + } + { //::AxisBin::getSize + + typedef ::std::size_t ( ::AxisBin::*getSize_function_type )( ) const; + typedef ::std::size_t ( AxisBin_wrapper::*default_getSize_function_type )( ) const; + + AxisBin_exposer.def( + "getSize" + , getSize_function_type(&::AxisBin::getSize) + , default_getSize_function_type(&AxisBin_wrapper::default_getSize) ); + + } + { //::AxisBin::initBins + + typedef void ( ::AxisBin::*initBins_function_type )( ::std::size_t,double,double ) ; + + AxisBin_exposer.def( + "initBins" + , initBins_function_type( &::AxisBin::initBins ) + , ( bp::arg("nbr_bins"), bp::arg("start"), bp::arg("end") ) ); + + } + { //::AxisBin::operator[] + + typedef double ( ::AxisBin::*__getitem___function_type )( ::std::size_t ) const; + typedef double ( AxisBin_wrapper::*default___getitem___function_type )( ::std::size_t ) const; + + AxisBin_exposer.def( + "__getitem__" + , __getitem___function_type(&::AxisBin::operator[]) + , default___getitem___function_type(&AxisBin_wrapper::default___getitem__) + , ( bp::arg("index") ) ); + + } + { //::AxisBin::push_back + + typedef void ( ::AxisBin::*push_back_function_type )( double ) ; + + AxisBin_exposer.def( + "push_back" + , push_back_function_type( &::AxisBin::push_back ) + , ( bp::arg("limit") ) ); + + } + } + +} diff --git a/Core/PythonAPI/src/AxisDouble.pypp.cpp b/Core/PythonAPI/src/AxisDouble.pypp.cpp new file mode 100644 index 00000000000..1bc6bde106a --- /dev/null +++ b/Core/PythonAPI/src/AxisDouble.pypp.cpp @@ -0,0 +1,240 @@ +// This file has been generated by Py++. + +// BornAgain: simulate and fit scattering at grazing incidence +//! @brief automatically generated boost::python code for PythonCoreAPI + +#include "Macros.h" +GCC_DIAG_OFF(unused-parameter); +GCC_DIAG_OFF(missing-field-initializers); +#include "boost/python.hpp" +GCC_DIAG_ON(unused-parameter); +GCC_DIAG_ON(missing-field-initializers); +#include "PythonCoreList.h" +#include "AxisDouble.pypp.h" + +namespace bp = boost::python; + +struct AxisDouble_wrapper : AxisDouble, bp::wrapper< AxisDouble > { + + AxisDouble_wrapper(AxisDouble const & arg ) + : AxisDouble( arg ) + , bp::wrapper< AxisDouble >(){ + // copy constructor + + } + + AxisDouble_wrapper(::std::string name ) + : AxisDouble( name ) + , bp::wrapper< AxisDouble >(){ + // constructor + + } + + AxisDouble_wrapper(::std::string name, ::std::size_t size, double start, double end ) + : AxisDouble( name, size, start, end ) + , bp::wrapper< AxisDouble >(){ + // constructor + + } + + AxisDouble_wrapper(::AxisBin const & source ) + : AxisDouble( boost::ref(source) ) + , bp::wrapper< AxisDouble >(){ + // constructor + + } + + virtual ::std::size_t findClosestIndex( double value ) const { + if( bp::override func_findClosestIndex = this->get_override( "findClosestIndex" ) ) + return func_findClosestIndex( value ); + else + return this->AxisDouble::findClosestIndex( value ); + } + + + ::std::size_t default_findClosestIndex( double value ) const { + return AxisDouble::findClosestIndex( value ); + } + + virtual ::Bin1D getBin( ::std::size_t index ) const { + if( bp::override func_getBin = this->get_override( "getBin" ) ) + return func_getBin( index ); + else + return this->AxisDouble::getBin( index ); + } + + + ::Bin1D default_getBin( ::std::size_t index ) const { + return AxisDouble::getBin( index ); + } + + virtual double getMax( ) const { + if( bp::override func_getMax = this->get_override( "getMax" ) ) + return func_getMax( ); + else + return this->AxisDouble::getMax( ); + } + + + double default_getMax( ) const { + return AxisDouble::getMax( ); + } + + virtual double getMin( ) const { + if( bp::override func_getMin = this->get_override( "getMin" ) ) + return func_getMin( ); + else + return this->AxisDouble::getMin( ); + } + + + double default_getMin( ) const { + return AxisDouble::getMin( ); + } + + virtual ::std::size_t getSize( ) const { + if( bp::override func_getSize = this->get_override( "getSize" ) ) + return func_getSize( ); + else + return this->AxisDouble::getSize( ); + } + + + ::std::size_t default_getSize( ) const { + return AxisDouble::getSize( ); + } + + virtual double operator[]( ::std::size_t index ) const { + if( bp::override func___getitem__ = this->get_override( "__getitem__" ) ) + return func___getitem__( index ); + else + return this->AxisDouble::operator[]( index ); + } + + + double default___getitem__( ::std::size_t index ) const { + return AxisDouble::operator[]( index ); + } + +}; + +void register_AxisDouble_class(){ + + { //::AxisDouble + typedef bp::class_< AxisDouble_wrapper, bp::bases< IAxis > > AxisDouble_exposer_t; + AxisDouble_exposer_t AxisDouble_exposer = AxisDouble_exposer_t( "AxisDouble", bp::init< std::string >(( bp::arg("name") )) ); + bp::scope AxisDouble_scope( AxisDouble_exposer ); + AxisDouble_exposer.def( bp::init< std::string, std::size_t, double, double >(( bp::arg("name"), bp::arg("size"), bp::arg("start"), bp::arg("end") )) ); + AxisDouble_exposer.def( bp::init< AxisBin const & >(( bp::arg("source") )) ); + { //::AxisDouble::findClosestIndex + + typedef ::std::size_t ( ::AxisDouble::*findClosestIndex_function_type )( double ) const; + typedef ::std::size_t ( AxisDouble_wrapper::*default_findClosestIndex_function_type )( double ) const; + + AxisDouble_exposer.def( + "findClosestIndex" + , findClosestIndex_function_type(&::AxisDouble::findClosestIndex) + , default_findClosestIndex_function_type(&AxisDouble_wrapper::default_findClosestIndex) + , ( bp::arg("value") ) ); + + } + { //::AxisDouble::getBin + + typedef ::Bin1D ( ::AxisDouble::*getBin_function_type )( ::std::size_t ) const; + typedef ::Bin1D ( AxisDouble_wrapper::*default_getBin_function_type )( ::std::size_t ) const; + + AxisDouble_exposer.def( + "getBin" + , getBin_function_type(&::AxisDouble::getBin) + , default_getBin_function_type(&AxisDouble_wrapper::default_getBin) + , ( bp::arg("index") ) ); + + } + { //::AxisDouble::getLowerBoundIndex + + typedef ::std::size_t ( ::AxisDouble::*getLowerBoundIndex_function_type )( double ) const; + + AxisDouble_exposer.def( + "getLowerBoundIndex" + , getLowerBoundIndex_function_type( &::AxisDouble::getLowerBoundIndex ) + , ( bp::arg("value") ) ); + + } + { //::AxisDouble::getMax + + typedef double ( ::AxisDouble::*getMax_function_type )( ) const; + typedef double ( AxisDouble_wrapper::*default_getMax_function_type )( ) const; + + AxisDouble_exposer.def( + "getMax" + , getMax_function_type(&::AxisDouble::getMax) + , default_getMax_function_type(&AxisDouble_wrapper::default_getMax) ); + + } + { //::AxisDouble::getMin + + typedef double ( ::AxisDouble::*getMin_function_type )( ) const; + typedef double ( AxisDouble_wrapper::*default_getMin_function_type )( ) const; + + AxisDouble_exposer.def( + "getMin" + , getMin_function_type(&::AxisDouble::getMin) + , default_getMin_function_type(&AxisDouble_wrapper::default_getMin) ); + + } + { //::AxisDouble::getSize + + typedef ::std::size_t ( ::AxisDouble::*getSize_function_type )( ) const; + typedef ::std::size_t ( AxisDouble_wrapper::*default_getSize_function_type )( ) const; + + AxisDouble_exposer.def( + "getSize" + , getSize_function_type(&::AxisDouble::getSize) + , default_getSize_function_type(&AxisDouble_wrapper::default_getSize) ); + + } + { //::AxisDouble::getUpperBoundIndex + + typedef ::std::size_t ( ::AxisDouble::*getUpperBoundIndex_function_type )( double ) const; + + AxisDouble_exposer.def( + "getUpperBoundIndex" + , getUpperBoundIndex_function_type( &::AxisDouble::getUpperBoundIndex ) + , ( bp::arg("value") ) ); + + } + { //::AxisDouble::initElements + + typedef void ( ::AxisDouble::*initElements_function_type )( ::std::size_t,double,double ) ; + + AxisDouble_exposer.def( + "initElements" + , initElements_function_type( &::AxisDouble::initElements ) + , ( bp::arg("size"), bp::arg("start"), bp::arg("end") ) ); + + } + { //::AxisDouble::operator[] + + typedef double ( ::AxisDouble::*__getitem___function_type )( ::std::size_t ) const; + typedef double ( AxisDouble_wrapper::*default___getitem___function_type )( ::std::size_t ) const; + + AxisDouble_exposer.def( + "__getitem__" + , __getitem___function_type(&::AxisDouble::operator[]) + , default___getitem___function_type(&AxisDouble_wrapper::default___getitem__) + , ( bp::arg("index") ) ); + + } + { //::AxisDouble::push_back + + typedef void ( ::AxisDouble::*push_back_function_type )( double ) ; + + AxisDouble_exposer.def( + "push_back" + , push_back_function_type( &::AxisDouble::push_back ) + , ( bp::arg("element") ) ); + + } + } + +} diff --git a/Core/PythonAPI/src/ndimdata_t.pypp.cpp b/Core/PythonAPI/src/IntensityData.pypp.cpp similarity index 87% rename from Core/PythonAPI/src/ndimdata_t.pypp.cpp rename to Core/PythonAPI/src/IntensityData.pypp.cpp index 15fcfc77c13..476bce5a3d4 100644 --- a/Core/PythonAPI/src/ndimdata_t.pypp.cpp +++ b/Core/PythonAPI/src/IntensityData.pypp.cpp @@ -10,22 +10,22 @@ GCC_DIAG_OFF(missing-field-initializers); GCC_DIAG_ON(unused-parameter); GCC_DIAG_ON(missing-field-initializers); #include "PythonCoreList.h" -#include "ndimdata_t.pypp.h" +#include "IntensityData.pypp.h" namespace bp = boost::python; -void register_ndimdata_t_class(){ +void register_IntensityData_class(){ { //::OutputData< double > - typedef bp::class_< OutputData< double >, boost::noncopyable > ndimdata_t_exposer_t; - ndimdata_t_exposer_t ndimdata_t_exposer = ndimdata_t_exposer_t( "ndimdata_t", bp::init< >() ); - bp::scope ndimdata_t_scope( ndimdata_t_exposer ); + typedef bp::class_< OutputData< double >, boost::noncopyable > IntensityData_exposer_t; + IntensityData_exposer_t IntensityData_exposer = IntensityData_exposer_t( "IntensityData", bp::init< >() ); + bp::scope IntensityData_scope( IntensityData_exposer ); { //::OutputData< double >::addAxis typedef OutputData< double > exported_class_t; typedef void ( exported_class_t::*addAxis_function_type )( ::IAxis const & ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "addAxis" , addAxis_function_type( &::OutputData< double >::addAxis ) , ( bp::arg("new_axis") ) ); @@ -36,7 +36,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef void ( exported_class_t::*addAxis_function_type )( ::std::string const &,::std::size_t,double,double ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "addAxis" , addAxis_function_type( &::OutputData< double >::addAxis ) , ( bp::arg("name"), bp::arg("size"), bp::arg("start"), bp::arg("end") ) ); @@ -47,7 +47,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef void ( exported_class_t::*clear_function_type )( ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "clear" , clear_function_type( &::OutputData< double >::clear ) ); @@ -57,7 +57,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::OutputData< double > * ( exported_class_t::*clone_function_type )( ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "clone" , clone_function_type( &::OutputData< double >::clone ) , bp::return_value_policy< bp::manage_new_object >() ); @@ -68,7 +68,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef void ( exported_class_t::*copyFrom_function_type )( ::OutputData< double > const & ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "copyFrom" , copyFrom_function_type( &::OutputData< double >::copyFrom ) , ( bp::arg("other") ) ); @@ -79,7 +79,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::std::vector< unsigned long > ( exported_class_t::*getAllSizes_function_type )( ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getAllSizes" , getAllSizes_function_type( &::OutputData< double >::getAllSizes ) ); @@ -89,7 +89,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::std::size_t ( exported_class_t::*getAllocatedSize_function_type )( ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getAllocatedSize" , getAllocatedSize_function_type( &::OutputData< double >::getAllocatedSize ) ); @@ -99,7 +99,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::IAxis const * ( exported_class_t::*getAxis_function_type )( ::std::size_t ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getAxis" , getAxis_function_type( &::OutputData< double >::getAxis ) , ( bp::arg("index") ) @@ -111,7 +111,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::IAxis const * ( exported_class_t::*getAxis_function_type )( ::std::string const & ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getAxis" , getAxis_function_type( &::OutputData< double >::getAxis ) , ( bp::arg("label") ) @@ -123,7 +123,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::std::size_t ( exported_class_t::*getAxisIndex_function_type )( ::std::string const & ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getAxisIndex" , getAxisIndex_function_type( &::OutputData< double >::getAxisIndex ) , ( bp::arg("label") ) ); @@ -134,7 +134,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::std::size_t ( exported_class_t::*getIndexOfAxis_function_type )( ::std::string const &,::std::size_t ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getIndexOfAxis" , getIndexOfAxis_function_type( &::OutputData< double >::getIndexOfAxis ) , ( bp::arg("axis_name"), bp::arg("total_index") ) ); @@ -145,7 +145,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::std::size_t ( exported_class_t::*getRank_function_type )( ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getRank" , getRank_function_type( &::OutputData< double >::getRank ) ); @@ -155,7 +155,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::std::vector< double > ( exported_class_t::*getRawDataVector_function_type )( ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getRawDataVector" , getRawDataVector_function_type( &::OutputData< double >::getRawDataVector ) ); @@ -165,7 +165,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef double ( exported_class_t::*getValueOfAxis_function_type )( ::std::string const &,::std::size_t ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "getValueOfAxis" , getValueOfAxis_function_type( &::OutputData< double >::getValueOfAxis ) , ( bp::arg("axis_name"), bp::arg("index") ) ); @@ -176,7 +176,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef bool ( exported_class_t::*hasSameDimensions_function_type )( ::OutputData< double > const & ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "hasSameDimensions" , hasSameDimensions_function_type( &::OutputData< double >::hasSameDimensions ) , ( bp::arg("right") ) ); @@ -187,22 +187,22 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef bool ( exported_class_t::*hasSameShape_function_type )( ::OutputData< double > const & ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "hasSameShape" , hasSameShape_function_type( &::OutputData< double >::hasSameShape ) , ( bp::arg("right") ) ); } - ndimdata_t_exposer.def( bp::self *= bp::self ); - ndimdata_t_exposer.def( bp::self += bp::self ); - ndimdata_t_exposer.def( bp::self -= bp::self ); - ndimdata_t_exposer.def( bp::self /= bp::self ); + IntensityData_exposer.def( bp::self *= bp::self ); + IntensityData_exposer.def( bp::self += bp::self ); + IntensityData_exposer.def( bp::self -= bp::self ); + IntensityData_exposer.def( bp::self /= bp::self ); { //::OutputData< double >::operator[] typedef OutputData< double > exported_class_t; typedef double & ( exported_class_t::*__getitem___function_type )( ::std::size_t ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "__getitem__" , __getitem___function_type( &::OutputData< double >::operator[] ) , ( bp::arg("index") ) @@ -214,7 +214,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef double const & ( exported_class_t::*__getitem___function_type )( ::std::size_t ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "__getitem__" , __getitem___function_type( &::OutputData< double >::operator[] ) , ( bp::arg("index") ) @@ -226,7 +226,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef void ( exported_class_t::*removeAllMasks_function_type )( ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "removeAllMasks" , removeAllMasks_function_type( &::OutputData< double >::removeAllMasks ) ); @@ -236,7 +236,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef void ( exported_class_t::*scaleAll_function_type )( double const & ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "scaleAll" , scaleAll_function_type( &::OutputData< double >::scaleAll ) , ( bp::arg("factor") ) ); @@ -247,7 +247,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef void ( exported_class_t::*setAllTo_function_type )( double const & ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "setAllTo" , setAllTo_function_type( &::OutputData< double >::setAllTo ) , ( bp::arg("value") ) ); @@ -258,7 +258,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef void ( exported_class_t::*setRawDataVector_function_type )( ::std::vector< double > const & ) ; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "setRawDataVector" , setRawDataVector_function_type( &::OutputData< double >::setRawDataVector ) , ( bp::arg("data_vector") ) ); @@ -269,7 +269,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef int ( exported_class_t::*toCoordinate_function_type )( ::std::size_t,::std::size_t ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "toCoordinate" , toCoordinate_function_type( &::OutputData< double >::toCoordinate ) , ( bp::arg("index"), bp::arg("i_selected_axis") ) ); @@ -280,7 +280,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::std::vector< int > ( exported_class_t::*toCoordinates_function_type )( ::std::size_t ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "toCoordinates" , toCoordinates_function_type( &::OutputData< double >::toCoordinates ) , ( bp::arg("index") ) ); @@ -291,7 +291,7 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef ::std::size_t ( exported_class_t::*toIndex_function_type )( ::std::vector< int > ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "toIndex" , toIndex_function_type( &::OutputData< double >::toIndex ) , ( bp::arg("coordinates") ) ); @@ -302,12 +302,12 @@ void register_ndimdata_t_class(){ typedef OutputData< double > exported_class_t; typedef double ( exported_class_t::*totalSum_function_type )( ) const; - ndimdata_t_exposer.def( + IntensityData_exposer.def( "totalSum" , totalSum_function_type( &::OutputData< double >::totalSum ) ); } - ndimdata_t_exposer.def("__setitem__", &pyplusplus_setitem<OutputData<double >,int,double> ); + IntensityData_exposer.def("__setitem__", &pyplusplus_setitem<OutputData<double >,int,double> ); } } diff --git a/Core/PythonAPI/src/PythonModule.cpp b/Core/PythonAPI/src/PythonModule.cpp index 4fcc2fff62a..b6294efcd99 100644 --- a/Core/PythonAPI/src/PythonModule.cpp +++ b/Core/PythonAPI/src/PythonModule.cpp @@ -15,6 +15,7 @@ #include "StochasticSampledParameter.pypp.h" #include "HomogeneousMaterial.pypp.h" #include "vector_integer_t.pypp.h" +#include "AxisDouble.pypp.h" #include "IAxis.pypp.h" #include "Layer.pypp.h" #include "IFormFactor.pypp.h" @@ -23,6 +24,7 @@ #include "MaterialManager.pypp.h" #include "ResolutionFunction2DSimple.pypp.h" #include "SimulationParameters.pypp.h" +#include "AxisBin.pypp.h" #include "FormFactorGauss.pypp.h" #include "FormFactorFullSpheroid.pypp.h" #include "PythonInterface_global_variables.pypp.h" @@ -66,13 +68,13 @@ #include "PositionParticleInfo.pypp.h" #include "LayerRoughness.pypp.h" #include "FormFactorCrystal.pypp.h" +#include "IntensityData.pypp.h" #include "IParameterized.pypp.h" #include "Bin1DCVector.pypp.h" #include "StochasticDoubleGate.pypp.h" #include "IClusteredParticles.pypp.h" #include "IInterferenceFunction.pypp.h" #include "SimpleSelectionRule.pypp.h" -#include "ndimdata_t.pypp.h" #include "FormFactorLorentz.pypp.h" #include "OutputDataIOFactory.pypp.h" #include "vector_kvector_t.pypp.h" @@ -100,6 +102,9 @@ BOOST_PYTHON_MODULE(libBornAgainCore){ register_vdouble1d_t_class(); register_vector_IFormFactorPtr_t_class(); register_vector_kvector_t_class(); + register_IAxis_class(); + register_AxisBin_class(); + register_AxisDouble_class(); register_IParameterized_class(); register_Beam_class(); register_Bin1D_class(); @@ -139,7 +144,6 @@ BOOST_PYTHON_MODULE(libBornAgainCore){ register_RotateZ_3D_class(); register_IMaterial_class(); register_HomogeneousMaterial_class(); - register_IAxis_class(); register_IDecoration_class(); register_IDetectorResolution_class(); register_IInterferenceFunction_class(); @@ -161,7 +165,7 @@ BOOST_PYTHON_MODULE(libBornAgainCore){ register_MaterialManager_class(); register_MesoCrystal_class(); register_MultiLayer_class(); - register_ndimdata_t_class(); + register_IntensityData_class(); register_OutputDataIOFactory_class(); register_ParameterPool_class(); register_ParticleBuilder_class(); diff --git a/Core/PythonAPI/src/Simulation.pypp.cpp b/Core/PythonAPI/src/Simulation.pypp.cpp index 90fc635aa48..f2b4586401e 100644 --- a/Core/PythonAPI/src/Simulation.pypp.cpp +++ b/Core/PythonAPI/src/Simulation.pypp.cpp @@ -170,24 +170,14 @@ void register_Simulation_class(){ , bp::return_value_policy< bp::copy_const_reference >() ); } - { //::Simulation::getOutputData + { //::Simulation::getIntensityData - typedef ::OutputData< double > const * ( ::Simulation::*getOutputData_function_type )( ) const; + typedef ::OutputData< double > * ( ::Simulation::*getIntensityData_function_type )( ) const; Simulation_exposer.def( - "getOutputData" - , getOutputData_function_type( &::Simulation::getOutputData ) - , bp::return_value_policy< bp::reference_existing_object >() ); - - } - { //::Simulation::getOutputDataClone - - typedef ::OutputData< double > * ( ::Simulation::*getOutputDataClone_function_type )( ) const; - - Simulation_exposer.def( - "getOutputDataClone" - , getOutputDataClone_function_type( &::Simulation::getOutputDataClone ) - , bp::return_value_policy< bp::reference_existing_object >() ); + "getIntensityData" + , getIntensityData_function_type( &::Simulation::getIntensityData ) + , bp::return_value_policy< bp::manage_new_object >() ); } { //::Simulation::getSample diff --git a/Core/Tools/inc/AxisDouble.h b/Core/Tools/inc/AxisDouble.h index d72a4042f0c..d3832d66b6f 100644 --- a/Core/Tools/inc/AxisDouble.h +++ b/Core/Tools/inc/AxisDouble.h @@ -19,7 +19,8 @@ #include "WinDllMacros.h" #include "IAxis.h" -class AxisBin; // forward declaration needed for conversion constructor +//class AxisBin; // forward declaration needed for conversion constructor +#include "AxisBin.h" //! The points of an axis diff --git a/Core/python_module.pri b/Core/python_module.pri index b7e8f7cb9f7..f0bc0343a20 100644 --- a/Core/python_module.pri +++ b/Core/python_module.pri @@ -16,6 +16,7 @@ HEADERS += \ PythonAPI/inc/StochasticSampledParameter.pypp.h \ PythonAPI/inc/HomogeneousMaterial.pypp.h \ PythonAPI/inc/vector_integer_t.pypp.h \ + PythonAPI/inc/AxisDouble.pypp.h \ PythonAPI/inc/IAxis.pypp.h \ PythonAPI/inc/Layer.pypp.h \ PythonAPI/inc/IFormFactor.pypp.h \ @@ -24,6 +25,7 @@ HEADERS += \ PythonAPI/inc/MaterialManager.pypp.h \ PythonAPI/inc/ResolutionFunction2DSimple.pypp.h \ PythonAPI/inc/SimulationParameters.pypp.h \ + PythonAPI/inc/AxisBin.pypp.h \ PythonAPI/inc/FormFactorGauss.pypp.h \ PythonAPI/inc/FormFactorFullSpheroid.pypp.h \ PythonAPI/inc/PythonInterface_global_variables.pypp.h \ @@ -67,13 +69,13 @@ HEADERS += \ PythonAPI/inc/PositionParticleInfo.pypp.h \ PythonAPI/inc/LayerRoughness.pypp.h \ PythonAPI/inc/FormFactorCrystal.pypp.h \ + PythonAPI/inc/IntensityData.pypp.h \ PythonAPI/inc/IParameterized.pypp.h \ PythonAPI/inc/Bin1DCVector.pypp.h \ PythonAPI/inc/StochasticDoubleGate.pypp.h \ PythonAPI/inc/IClusteredParticles.pypp.h \ PythonAPI/inc/IInterferenceFunction.pypp.h \ PythonAPI/inc/SimpleSelectionRule.pypp.h \ - PythonAPI/inc/ndimdata_t.pypp.h \ PythonAPI/inc/FormFactorLorentz.pypp.h \ PythonAPI/inc/OutputDataIOFactory.pypp.h \ PythonAPI/inc/vector_kvector_t.pypp.h \ @@ -128,6 +130,7 @@ SOURCES += \ PythonAPI/src/StochasticSampledParameter.pypp.cpp \ PythonAPI/src/FormFactorFullSphere.pypp.cpp \ PythonAPI/src/StochasticParameter_t.pypp.cpp \ + PythonAPI/src/AxisBin.pypp.cpp \ PythonAPI/src/SimpleSelectionRule.pypp.cpp \ PythonAPI/src/IDecoration.pypp.cpp \ PythonAPI/src/FTDistribution2DCauchy.pypp.cpp \ @@ -153,6 +156,8 @@ SOURCES += \ PythonAPI/src/InterferenceFunction2DParaCrystal.pypp.cpp \ PythonAPI/src/FormFactorCone.pypp.cpp \ PythonAPI/src/Simulation.pypp.cpp \ + PythonAPI/src/IntensityData.pypp.cpp \ + PythonAPI/src/AxisDouble.pypp.cpp \ PythonAPI/src/FormFactorFullSpheroid.pypp.cpp \ PythonAPI/src/MaterialManager.pypp.cpp \ PythonAPI/src/ParticleBuilder.pypp.cpp \ @@ -161,7 +166,6 @@ SOURCES += \ PythonAPI/src/FormFactorPrism3.pypp.cpp \ PythonAPI/src/PositionParticleInfo.pypp.cpp \ PythonAPI/src/ICompositeSample.pypp.cpp \ - PythonAPI/src/ndimdata_t.pypp.cpp \ PythonAPI/src/Beam.pypp.cpp \ PythonAPI/src/FormFactorDecoratorDebyeWaller.pypp.cpp \ PythonAPI/src/IFormFactor.pypp.cpp \ diff --git a/Tests/FunctionalTests/CMakeLists.txt b/Tests/FunctionalTests/CMakeLists.txt index 17b66e31b19..bddd692c4e2 100644 --- a/Tests/FunctionalTests/CMakeLists.txt +++ b/Tests/FunctionalTests/CMakeLists.txt @@ -15,6 +15,9 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/T execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyCore ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyCore) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyFit ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyFit) +#file(COPY ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyFit DESTINATION ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyFit) +#COPY_IF_DIFFERENT( ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyFit ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyFit ${SRC_FILES} IncludeTargets "Includes") + add_subdirectory(TestCore) add_subdirectory(TestFit) if(BORNAGAIN_PYTHON) diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS01/IsGISAXS01.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS01/IsGISAXS01.cpp index 94b517be801..45e316c71d1 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS01/IsGISAXS01.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS01/IsGISAXS01.cpp @@ -33,7 +33,7 @@ void FunctionalTests::IsGISAXS01::run() simulation.runSimulation(); // Copy results - m_result = simulation.getOutputDataClone(); + m_result = simulation.getIntensityData(); delete sample; } diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS02/IsGISAXS02.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS02/IsGISAXS02.cpp index 6b4e9762eb1..231e48cd484 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS02/IsGISAXS02.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS02/IsGISAXS02.cpp @@ -30,7 +30,7 @@ void FunctionalTests::IsGISAXS02::run() simulation.setSample(*sample); simulation.runSimulation(); - m_result = simulation.getOutputDataClone(); + m_result = simulation.getIntensityData(); delete sample; } diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS03/IsGISAXS03.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS03/IsGISAXS03.cpp index c7e1aa67c5b..c3f4a2c08e2 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS03/IsGISAXS03.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS03/IsGISAXS03.cpp @@ -39,7 +39,7 @@ void FunctionalTests::IsGISAXS03::runDWBA() // running simulation and copying data simulation.setSample(*sample); simulation.runSimulation(); - m_results[kTest_DWBA] = simulation.getOutputDataClone(); + m_results[kTest_DWBA] = simulation.getIntensityData(); delete sample; } @@ -62,7 +62,7 @@ void FunctionalTests::IsGISAXS03::runBA() // running simulation and copying data simulation.setSample(*sample); simulation.runSimulation(); - m_results[kTest_BA] = simulation.getOutputDataClone(); + m_results[kTest_BA] = simulation.getIntensityData(); delete sample; } @@ -85,7 +85,7 @@ void FunctionalTests::IsGISAXS03::runBA_Size() // running simulation and copying data simulation.setSample(*sample); simulation.runSimulation(); - m_results[kTest_BASize] = simulation.getOutputDataClone(); + m_results[kTest_BASize] = simulation.getIntensityData(); delete sample; } diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS04/IsGISAXS04.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS04/IsGISAXS04.cpp index a69d5cb50db..ca9898c0917 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS04/IsGISAXS04.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS04/IsGISAXS04.cpp @@ -40,7 +40,7 @@ void FunctionalTests::IsGISAXS04::run1DDL() 0.0*Units::degree); simulation.setSample(*sample); simulation.runSimulation(); - m_results[kTest_1DDL] = simulation.getOutputDataClone(); + m_results[kTest_1DDL] = simulation.getIntensityData(); delete sample; } @@ -60,7 +60,7 @@ void FunctionalTests::IsGISAXS04::run2DDL() 0.0*Units::degree); simulation.setSample(*sample); simulation.runSimulation(); - m_results[kTest_2DDL] = simulation.getOutputDataClone(); + m_results[kTest_2DDL] = simulation.getIntensityData(); delete sample; } diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS06/IsGISAXS06.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS06/IsGISAXS06.cpp index 8e16911df30..0169f86e606 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS06/IsGISAXS06.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS06/IsGISAXS06.cpp @@ -56,7 +56,7 @@ void FunctionalTests::IsGISAXS06::runlattice() // running simulation and copying data m_simulation.setSample(*sample); m_simulation.runSimulation(); - m_results[kTest_Lattice] = m_simulation.getOutputDataClone(); + m_results[kTest_Lattice] = m_simulation.getIntensityData(); delete sample; } @@ -71,7 +71,7 @@ void FunctionalTests::IsGISAXS06::runcentered() // running simulation and copying data m_simulation.setSample(*sample); m_simulation.runSimulation(); - m_results[kTest_Centered] = m_simulation.getOutputDataClone(); + m_results[kTest_Centered] = m_simulation.getIntensityData(); delete sample; } @@ -86,7 +86,7 @@ void FunctionalTests::IsGISAXS06::runrotated() // running simulation and copying data m_simulation.setSample(*sample); m_simulation.runSimulation(); - m_results[kTest_Rotated] = m_simulation.getOutputDataClone(); + m_results[kTest_Rotated] = m_simulation.getIntensityData(); } @@ -96,7 +96,7 @@ void FunctionalTests::IsGISAXS06::runvariants() IsGISAXS06Lattice4Builder builder; // running simulation and copying data - OutputData<double> *p_total = m_simulation.getOutputDataClone(); + OutputData<double> *p_total = m_simulation.getIntensityData(); p_total->setAllTo(0.0); int nbins = 3; double xi_min = 0.0*Units::degree; @@ -111,7 +111,7 @@ void FunctionalTests::IsGISAXS06::runvariants() m_simulation.setSample(*p_sample); m_simulation.runSimulation(); delete p_sample; - OutputData<double> *p_single_output = m_simulation.getOutputDataClone(); + OutputData<double> *p_single_output = m_simulation.getIntensityData(); p_single_output->scaleAll(probability); *p_total += *p_single_output; delete p_single_output; diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS07/IsGISAXS07.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS07/IsGISAXS07.cpp index 7e3a4b9306e..0228270a23c 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS07/IsGISAXS07.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS07/IsGISAXS07.cpp @@ -139,7 +139,7 @@ void FunctionalTests::IsGISAXS07::run() // --------------------- // copying data // --------------------- - m_result = simulation.getOutputDataClone(); + m_result = simulation.getIntensityData(); } int FunctionalTests::IsGISAXS07::analyseResults(const std::string &path_to_data) diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS08/IsGISAXS08.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS08/IsGISAXS08.cpp index e333802a201..771ba9099b5 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS08/IsGISAXS08.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS08/IsGISAXS08.cpp @@ -73,7 +73,7 @@ void FunctionalTests::IsGISAXS08::run2DDL() // running simulation and copying data simulation.runSimulation(); - m_results[kTest_2DDL] = simulation.getOutputDataClone(); + m_results[kTest_2DDL] = simulation.getIntensityData(); } @@ -122,7 +122,7 @@ void FunctionalTests::IsGISAXS08::run2DDL2() // running simulation and copying data simulation.setSample(multi_layer); simulation.runSimulation(); - m_results[kTest_2DDL2] = simulation.getOutputDataClone(); + m_results[kTest_2DDL2] = simulation.getIntensityData(); } diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS09/IsGISAXS09.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS09/IsGISAXS09.cpp index 5675b15a323..a2ef3ef074b 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS09/IsGISAXS09.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS09/IsGISAXS09.cpp @@ -41,7 +41,7 @@ void FunctionalTests::IsGISAXS09::runpyramidZ0() // running simulation simulation.runSimulation(); - m_results[kTest_Z0] = simulation.getOutputDataClone(); + m_results[kTest_Z0] = simulation.getIntensityData(); delete sample; } @@ -64,7 +64,7 @@ void FunctionalTests::IsGISAXS09::runpyramidZ45() // running simulation simulation.runSimulation(); - m_results[kTest_Z45] = simulation.getOutputDataClone(); + m_results[kTest_Z45] = simulation.getIntensityData(); delete sample; } diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS10/IsGISAXS10.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS10/IsGISAXS10.cpp index a8709adc280..8e1ce8a1ea3 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS10/IsGISAXS10.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS10/IsGISAXS10.cpp @@ -58,7 +58,7 @@ void FunctionalTests::IsGISAXS10::run() // running simulation and copying data simulation.runSimulation(); - m_result = simulation.getOutputDataClone(); + m_result = simulation.getIntensityData(); } diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS11/IsGISAXS11.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS11/IsGISAXS11.cpp index 8ebb9ad02a3..d5df7d5776c 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS11/IsGISAXS11.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS11/IsGISAXS11.cpp @@ -65,7 +65,7 @@ void FunctionalTests::IsGISAXS11::run() // running simulation and copying data simulation.runSimulation(); - m_result = simulation.getOutputDataClone(); + m_result = simulation.getIntensityData(); } diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS15/IsGISAXS15.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS15/IsGISAXS15.cpp index c52ca0559d6..3fec26f80d2 100644 --- a/Tests/FunctionalTests/TestCore/IsGISAXS15/IsGISAXS15.cpp +++ b/Tests/FunctionalTests/TestCore/IsGISAXS15/IsGISAXS15.cpp @@ -73,7 +73,7 @@ void FunctionalTests::IsGISAXS15::run() // running simulation and copying the data simulation.runSimulation(); - m_result = simulation.getOutputDataClone(); + m_result = simulation.getIntensityData(); } diff --git a/Tests/FunctionalTests/TestFit/TestFit01/TestFit01.cpp b/Tests/FunctionalTests/TestFit/TestFit01/TestFit01.cpp index e58cc9c8db0..b37b2563ab0 100644 --- a/Tests/FunctionalTests/TestFit/TestFit01/TestFit01.cpp +++ b/Tests/FunctionalTests/TestFit/TestFit01/TestFit01.cpp @@ -71,7 +71,7 @@ bool TestFit01::run_fitting(const std::string &minimizer_name, const std::string // Creating real data, which is simply results of our simulation with default values simulation->runSimulation(); - OutputData<double> *real_data = simulation->getOutputDataClone(); + OutputData<double> *real_data = simulation->getIntensityData(); // setting fitting FitSuite *fitSuite = new FitSuite(); diff --git a/Tests/FunctionalTests/TestFit/TestFit02/TestFit02.cpp b/Tests/FunctionalTests/TestFit/TestFit02/TestFit02.cpp index 5ffcedff056..73420c3477e 100644 --- a/Tests/FunctionalTests/TestFit/TestFit02/TestFit02.cpp +++ b/Tests/FunctionalTests/TestFit/TestFit02/TestFit02.cpp @@ -118,7 +118,7 @@ OutputData<double> *TestFit02::createRealData(Simulation *simulation) { const double noise_factor = 0.1; simulation->runSimulation(); - OutputData<double> *result = simulation->getOutputDataClone(); + OutputData<double> *result = simulation->getIntensityData(); OutputData<double>::iterator it = result->begin(); int index(0); while (it != result->end()) { diff --git a/Tests/FunctionalTests/TestPyFit/testfit01.py b/Tests/FunctionalTests/TestPyFit/testfit01.py index 3d339393b4f..284c9eeb14a 100644 --- a/Tests/FunctionalTests/TestPyFit/testfit01.py +++ b/Tests/FunctionalTests/TestPyFit/testfit01.py @@ -65,7 +65,7 @@ def run_fitting(minimizer_name, minimizer_algorithm): # creating real data, which is simply results of our simulation with default values simulation.runSimulation() - real_data = simulation.getOutputDataClone() + real_data = simulation.getIntensityData() # setting fit suite fitSuite = FitSuite() diff --git a/Tests/FunctionalTests/TestPyFit/testfit02.py b/Tests/FunctionalTests/TestPyFit/testfit02.py index 17649041dfc..0ca195cbe84 100644 --- a/Tests/FunctionalTests/TestPyFit/testfit02.py +++ b/Tests/FunctionalTests/TestPyFit/testfit02.py @@ -86,7 +86,7 @@ def createSimulation(): # generating "real" data by adding noise to the simulated data def createRealData(simulation): simulation.runSimulation(); - real_data = simulation.getOutputDataClone() + real_data = simulation.getIntensityData() noise_factor = 0.1 for i in range(0,real_data.getAllocatedSize()): amplitude = real_data[i] diff --git a/dev-tools/python-bindings/MakePyCore.py b/dev-tools/python-bindings/MakePyCore.py index ddd1a9459c8..fa843f79a0f 100644 --- a/dev-tools/python-bindings/MakePyCore.py +++ b/dev-tools/python-bindings/MakePyCore.py @@ -27,92 +27,93 @@ include_dirs = [ '../../Core/Tools/inc', '../../Core/PythonAPI/inc', '../../Core/Geometry/inc', -# '../../ThirdParty/eigen3' ] include_classes = [ -"BasicVector3D<double>", -"BasicVector3D<std::complex<double> >", -"Beam", -"Bin1D", -"Bin1DCVector", -"Crystal", -"Detector", -"FTDistribution2DCauchy", -"FormFactorBox", -"FormFactorCone", -"FormFactorCylinder", -"FormFactorCrystal", -"FormFactorDecoratorDebyeWaller", -"FormFactorEllipsoid", -"FormFactorFullSphere", -"FormFactorFullSpheroid", -"FormFactorGauss", -"FormFactorHemiSpheroid", -"FormFactorLorentz", -"FormFactorParallelepiped", -"FormFactorPrism3", -"FormFactorPrism6", -"FormFactorPyramid", -"FormFactorSphere", -"FormFactorSphereGaussianRadius", -"HomogeneousMaterial", -"IAxis", -"ICloneable", -"IClusteredParticles", -"ICompositeSample", -"IDecoration", -"IDetectorResolution", -"IFTDistribution2D", -"IFormFactor", -"IFormFactorBorn", -"IFormFactorDecorator", -"IInterferenceFunction", -"IMaterial", -"IParameterized", -"IResolutionFunction2D", -"ISample", -"ISampleBuilder", -#"ISampleVisitor", -"ISelectionRule", -"ITransform3D", -"Instrument", -"InterferenceFunction1DParaCrystal", -"InterferenceFunction2DLattice", -"InterferenceFunction2DParaCrystal", -"InterferenceFunctionNone", -"Lattice", -"Lattice2DIFParameters", -"LatticeBasis", -"Layer", -#"LayerDecorator", -"LayerInterface", -"LayerRoughness", -"MaterialManager", -"MesoCrystal", -"MultiLayer", -"OutputData<double>", -"OutputDataIOFactory", -"ParameterPool", -"Particle", -"ParticleCoreShell", -"ParticleBuilder", -"ParticleDecoration", -"ParticleInfo", -"PositionParticleInfo", -"RealParameterWrapper", -"ResolutionFunction2DSimple", -"RotateY_3D", -"RotateZ_3D", -"Simulation", -"SimulationParameters", -"SimpleSelectionRule", -"StochasticDoubleGate", -"StochasticDoubleGaussian", -"StochasticParameter<double>", -"StochasticSampledParameter", -"cvector_t", -"kvector_t", + "AxisDouble", + "AxisBin", + "BasicVector3D<double>", + "BasicVector3D<std::complex<double> >", + "Beam", + "Bin1D", + "Bin1DCVector", + "Crystal", + "Detector", + "FTDistribution2DCauchy", + "FormFactorBox", + "FormFactorCone", + "FormFactorCylinder", + "FormFactorCrystal", + "FormFactorDecoratorDebyeWaller", + "FormFactorEllipsoid", + "FormFactorFullSphere", + "FormFactorFullSpheroid", + "FormFactorGauss", + "FormFactorHemiSpheroid", + "FormFactorLorentz", + "FormFactorParallelepiped", + "FormFactorPrism3", + "FormFactorPrism6", + "FormFactorPyramid", + "FormFactorSphere", + "FormFactorSphereGaussianRadius", + "HomogeneousMaterial", + "IAxis", + "ICloneable", + "IClusteredParticles", + "ICompositeSample", + "IDecoration", + "IDetectorResolution", + "IFTDistribution2D", + "IFormFactor", + "IFormFactorBorn", + "IFormFactorDecorator", + "IInterferenceFunction", + "IMaterial", + "IParameterized", + "IResolutionFunction2D", + "ISample", + "ISampleBuilder", + #"ISampleVisitor", + "ISelectionRule", + "ITransform3D", + "Instrument", + "InterferenceFunction1DParaCrystal", + "InterferenceFunction2DLattice", + "InterferenceFunction2DParaCrystal", + "InterferenceFunctionNone", + "Lattice", + "Lattice2DIFParameters", + "LatticeBasis", + "Layer", + #"LayerDecorator", + "LayerInterface", + "LayerRoughness", + "MaterialManager", + "MesoCrystal", + "MultiLayer", + "OutputData<double>", + "OutputDataIOFactory", + "ParameterPool", + "Particle", + "ParticleCoreShell", + "ParticleBuilder", + "ParticleDecoration", + "ParticleInfo", + "PositionParticleInfo", + "RealParameterWrapper", + "ResolutionFunction2DSimple", + "RotateY_3D", + "RotateZ_3D", + "Simulation", + "SimulationParameters", + "SimpleSelectionRule", + "StochasticDoubleGate", + "StochasticDoubleGaussian", + "StochasticParameter<double>", + "StochasticSampledParameter", + "cvector_t", + "kvector_t", ] @@ -120,14 +121,17 @@ include_classes = [ # AdditionalRules # ----------------------------------------------------------------------------- def ManualClassTunings(mb): + mb.class_("AxisDouble").member_function("clone").exclude() + mb.class_("AxisDouble").member_functions("createDoubleBinSize").exclude() + mb.class_("Detector").member_functions("addAxis").exclude() # - shared_ptrs = mb.decls( lambda decl: decl.name.startswith( 'shared_ptr<' ) ) - shared_ptrs.disable_warnings( messages.W1040 ) + shared_ptrs = mb.decls(lambda decl: decl.name.startswith('shared_ptr<' )) + shared_ptrs.disable_warnings(messages.W1040) # ISample cl = mb.class_('ISample') - cl.member_function("accept").include(); - cl.member_function("printSampleTree").include(); + cl.member_function("accept").include() + cl.member_function("printSampleTree").include() # ICompositeSample cl = mb.class_('ICompositeSample') @@ -137,20 +141,20 @@ def ManualClassTunings(mb): methods_to_exclude=[ "phi", "theta", "cosTheta", "getPhi", "getTheta", "setPhi", "setTheta", "setR", "setMag", "perp", "perp2", "setPerp", "angle", "unit", "orthogonal", - "rotated","rotatedX","rotatedY","rotatedZ","cross","dot" + "rotated", "rotatedX", "rotatedY", "rotatedZ", "cross", "dot" ] - classes_to_exclude = ["BasicVector3D<std::complex<double> >","BasicVector3D<double>","BasicVector3D<int>"] + classes_to_exclude = ["BasicVector3D<std::complex<double> >", "BasicVector3D<double>", "BasicVector3D<int>"] builder_utils.ExcludeMemberFunctionsForClasses(mb, methods_to_exclude, classes_to_exclude) # Pure virtual should always be included mb.class_("IDetectorResolution").member_function("applyDetectorResolution").include() # - cl = mb.class_( "Lattice" ) + cl = mb.class_("Lattice") cl.member_functions().exclude() cl.member_function("getBasisVectorA").include() cl.member_function("getBasisVectorB").include() cl.member_function("getBasisVectorC").include() cl.member_function("createTrigonalLattice").include() - cl.member_function("createTrigonalLattice").call_policies = call_policies.return_value_policy(call_policies.return_by_value ) + cl.member_function("createTrigonalLattice").call_policies = call_policies.return_value_policy(call_policies.return_by_value) cl.member_function("setSelectionRule").include() # cl = mb.class_("LatticeBasis") @@ -182,76 +186,82 @@ def ManualClassTunings(mb): cl.add_code("def( bp::self / bp::other< double >() )") cl.add_code("def( bp::self_ns::str( bp::self ) )") # - cl = mb.class_( "IParameterized" ) + cl = mb.class_("IParameterized") cl.member_function("registerParameter").include() cl.member_function("registerParameter").add_transformation( builder_utils.from_address_custom( 1 ) ) # - cl = mb.class_( "ISampleBuilder" ) + cl = mb.class_("ISampleBuilder") cl.member_functions().exclude() - cl.member_function( "buildSample" ).include() - cl.member_function( "buildSample" ).call_policies = call_policies.return_value_policy( call_policies.manage_new_object ) + cl.member_function("buildSample").include() + cl.member_function("buildSample").call_policies = call_policies.return_value_policy(call_policies.manage_new_object) # - cl = mb.class_( "IClusteredParticles" ) - cl.member_function( "setAmbientMaterial" ).include() + cl = mb.class_("IClusteredParticles") + cl.member_function("setAmbientMaterial").include() # - cl = mb.class_( "MaterialManager" ) + cl = mb.class_("MaterialManager") cl.constructors().exclude() # cl = mb.class_("OutputData<double>") - cl.add_code('def("__setitem__", &pyplusplus_setitem<OutputData<double >,int,double> )') # [] operator for OutputData + cl.add_code('def("__setitem__", &pyplusplus_setitem<OutputData<double >,int,double> )') # [] operator for OutputData # - cl = mb.class_( "Particle" ) - cl.member_function( "createDiffuseParticleInfo" ).exclude() - cl.member_function( "createDistributedParticles" ).exclude() + cl = mb.class_("Particle") + cl.member_function("createDiffuseParticleInfo").exclude() + cl.member_function("createDistributedParticles").exclude() for cls in cl.constructors(): - if ("( ::Particle::* )( ::IMaterial const *,::IFormFactor const & )" in cls.decl_string): + if "( ::Particle::* )( ::IMaterial const *,::IFormFactor const & )" in cls.decl_string: cls.include() - if ("( ::Particle::* )( ::IMaterial const *,::IFormFactor const &,::Geometry::PTransform3D const & )" in cls.decl_string): + if "( ::Particle::* )( ::IMaterial const *,::IFormFactor const &,::Geometry::PTransform3D const & )" in cls.decl_string: cls.include() # - cl = mb.class_( "ParticleDecoration" ) - cl.constructors( lambda decl: bool( decl.arguments ) ).exclude() # exclude non-default constructors + cl = mb.class_("ParticleDecoration") + cl.constructors(lambda decl: bool(decl.arguments)).exclude() # exclude non-default constructors # - cl = mb.class_( "ParameterPool" ) - cl.member_function("registerParameter").add_transformation( builder_utils.from_address_custom( 1 ) ) + cl = mb.class_("ParameterPool") + cl.member_function("registerParameter").add_transformation(builder_utils.from_address_custom(1)) cl.member_function("getMatchedParameters").exclude() # - mb.namespace( "Units" ).include() + mb.namespace("Units").include() # - cl = mb.class_( "Layer" ) + cl = mb.class_("Layer") # including back methods which have been excluded by our pointer policy for fun in cl.member_functions(): - if fun.name == "setMaterial":fun.include() + if fun.name == "setMaterial": + fun.include() for fun in cl.member_functions(): - if("void ( ::Layer::* )( ::IDecoration * )" in fun.decl_string): fun.exclude() - cl.constructors().include() # including back constructors with pointers + if "void ( ::Layer::* )( ::IDecoration * )" in fun.decl_string: + fun.exclude() + cl.constructors().include() # including back constructors with pointers # cl = mb.class_("Simulation") cl.member_function("setSampleBuilder").include() + cl.member_function("getOutputData").exclude() + cl.member_function("getIntensityData").call_policies = \ + call_policies.return_value_policy(call_policies.manage_new_object) + # - cl = mb.class_( "ParticleCoreShell" ) + cl = mb.class_("ParticleCoreShell") cl.member_functions().exclude() # - cl = mb.class_( "MesoCrystal" ) - cl.member_functions( ).exclude() + cl = mb.class_("MesoCrystal") + cl.member_functions().exclude() # - mb.namespace( "MathFunctions" ).free_function("GenerateNormalRandom").include() + mb.namespace("MathFunctions").free_function("GenerateNormalRandom").include() # - mb.namespace( "AppVersion" ).free_function("GetMajorVersionNumber").include() - mb.namespace( "AppVersion" ).free_function("GetMinorVersionNumber").include() - mb.namespace( "AppVersion" ).free_function("GetPatchVersionNumber").include() - mb.namespace( "AppVersion" ).free_function("GetVersionNumber").include() + mb.namespace("AppVersion").free_function("GetMajorVersionNumber").include() + mb.namespace("AppVersion").free_function("GetMinorVersionNumber").include() + mb.namespace("AppVersion").free_function("GetPatchVersionNumber").include() + mb.namespace("AppVersion").free_function("GetVersionNumber").include() # excluding specific member functions def ManualExcludeMemberFunctions(mb): # with given name in function name - to_exclude=['Iterator','iterator','DWBASimulation'] - to_exclude_exact=['createDiffuseParticleInfo','createDistributedParticles', - 'inverse','transformed','getNearestLatticeVectorCoordinates','getNearestReciprocalLatticeVectorCoordinates', - 'collectBraggAngles','getKVectorContainer', - 'begin','end','getBinOfAxis','addMask','getMask','setMask', + to_exclude=['Iterator', 'iterator', 'DWBASimulation'] + to_exclude_exact=['createDiffuseParticleInfo', 'createDistributedParticles', + 'inverse', 'transformed', 'getNearestLatticeVectorCoordinates', 'getNearestReciprocalLatticeVectorCoordinates', + 'collectBraggAngles', 'getKVectorContainer', + 'begin', 'end', 'getBinOfAxis', 'addMask', 'getMask', 'setMask', ] for f in mb.member_functions(): for x in to_exclude: @@ -272,11 +282,15 @@ def MakePythonAPI(OutputTempDir): mygccxml = builder_utils.get_gccxml_path() #If the cache file cache_core.xml doesn't exist it gets created, otherwise it just gets loaded - print "NOTE: If you update the source library code you need to manually delete the cache_core.xml file, or run 'python codegenerator.py clean'" - xml_cached_fc = parser.create_cached_source_fc( "PythonCoreList.h", "cache_core.xml" ) + print """ + NOTE: If you update the source library code you need to manually delete the cache_core.xml file, + or run 'python codegenerator.py clean' + """ + xml_cached_fc = parser.create_cached_source_fc("PythonCoreList.h", "cache_core.xml") #xml_cached_fc = parser.create_cached_source_fc( ["PythonCoreList.h","PythonCoreExposer.h"], "cache_core.xml" ) #mb = module_builder.module_builder_t( [xml_cached_fc], include_paths=include_dirs, gccxml_path=mygccxml, cflags="-m64 -msse -msse2 -fno-strict-aliasing -msse3") - mb = module_builder.module_builder_t( [xml_cached_fc], include_paths=include_dirs, gccxml_path=mygccxml, cflags="-m64 -DGCCXML_SKIP_THIS") + mb = module_builder.module_builder_t([xml_cached_fc], include_paths=include_dirs, gccxml_path=mygccxml, + cflags="-m64 -DGCCXML_SKIP_THIS") # ----------------- # general rules @@ -301,7 +315,7 @@ def MakePythonAPI(OutputTempDir): ManualClassTunings(mb) # ----------------- - # default policies for what remained unchainged + # default policies for what remained unchanged # ----------------- #builder_utils.IncludePureVirtualMethods(mb, include_classes) @@ -310,28 +324,28 @@ def MakePythonAPI(OutputTempDir): # disabling some warnings messages.disable( - messages.W1020 # Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X - , messages.W1021 - , messages.W1022 - , messages.W1023 - , messages.W1024 - , messages.W1025 - , messages.W1026 - , messages.W1027 - , messages.W1028 - , messages.W1029 - , messages.W1030 - , messages.W1031 - #, messages.W1035 - #, messages.W1040 - #, messages.W1038 - #, messages.W1041 - , messages.W1036 # pointer to Python immutable member - #, messages.W1033 # unnamed variables - #, messages.W1018 # expose unnamed classes - #, messages.W1049 # returns reference to local variable - #, messages.W1014 # unsupported '=' operator - ) + messages.W1020, # Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X + messages.W1021, + messages.W1022, + messages.W1023, + messages.W1024, + messages.W1025, + messages.W1026, + messages.W1027, + messages.W1028, + messages.W1029, + messages.W1030, + messages.W1031, + #messages.W1035, + #messages.W1040, + #messages.W1038, + #messages.W1041, + messages.W1036, # pointer to Python immutable member + #messages.W1033, # unnamed variables + #messages.W1018, # expose unnamed classes + #messages.W1049, # returns reference to local variable + #messages.W1014, # unsupported '=' operator + ) # --------------------------------------------------------- # generating output @@ -339,19 +353,16 @@ def MakePythonAPI(OutputTempDir): mb.build_code_creator( module_name=builder_utils.ModuleName) mb.code_creator.license = builder_utils.license - mb.code_creator.user_defined_directories.append( os.path.abspath('./') ) + mb.code_creator.user_defined_directories.append(os.path.abspath('./')) mb.split_module(OutputTempDir) -#------------------------------------------------------------------------------ -# main() -#------------------------------------------------------------------------------ if __name__ == '__main__': - tempDir='output/PyCore' + tempDir = 'output/PyCore' if not os.path.exists(tempDir): os.makedirs(tempDir) start_time = time.clock() MakePythonAPI(tempDir) - print '\nPythonCoreAPI source code was generated ( %f seconds ).' % ( ( time.clock() - start_time ) ) + print '\nPythonCoreAPI source code was generated ( %f seconds ).' % ((time.clock() - start_time)) print 'Run InstallPyCore.py to install generated code into BornAgain source tree' print 'Done' diff --git a/dev-tools/python-bindings/builder_utils.py b/dev-tools/python-bindings/builder_utils.py index 8e1509f44ae..9831789d20c 100644 --- a/dev-tools/python-bindings/builder_utils.py +++ b/dev-tools/python-bindings/builder_utils.py @@ -17,15 +17,15 @@ from pyplusplus.file_writers.balanced_files import balanced_files_t from pyplusplus.file_writers.multiple_files import multiple_files_t -license = "// BornAgain: simulate and fit scattering at grazing incidence \n" \ +license = "// BornAgain: simulate and fit scattering at grazing incidence \n" \ "//! @brief automatically generated boost::python code for PythonCoreAPI \n" ModuleName = 'PythonInterface' -balanced_files_t.HEADER_EXT='.h' -balanced_files_t.SOURCE_EXT='.cpp' -multiple_files_t.HEADER_EXT='.pypp.h' -multiple_files_t.SOURCE_EXT='.pypp.cpp' +balanced_files_t.HEADER_EXT = '.h' +balanced_files_t.SOURCE_EXT = '.cpp' +multiple_files_t.HEADER_EXT = '.pypp.h' +multiple_files_t.SOURCE_EXT = '.pypp.cpp' #------------------------------------------------------------------------------ -- GitLab