Skip to content

Commit

Permalink
Add python module for reflectometry constansts
Browse files Browse the repository at this point in the history
  • Loading branch information
adriazalvarez committed Dec 9, 2024
1 parent 97ae101 commit 568667b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions Framework/PythonInterface/mantid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ add_subdirectory(geometry)
add_subdirectory(api)
add_subdirectory(dataobjects)
add_subdirectory(_plugins)
add_subdirectory(utils/reflectometry)

# Defines the target the will cause the Python bundle to be copied
set(PYBUNDLE_POST_TARGET PythonModule)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# _polarization_helpers Python module

set(MODULE_TEMPLATE src/polarization_helpers.cpp.in)

# Files containing export definitions, these are automatically processed -- Do NOT sort this list. The order defines the
# order in which the export definitions occur and some depend on their base classes being exported first --
set(EXPORT_FILES src/Exports/PolarizationCorrectionHelpers.cpp)

set(MODULE_DEFINITION ${CMAKE_CURRENT_BINARY_DIR}/polarization_helpers.cpp)
create_module(${MODULE_TEMPLATE} ${MODULE_DEFINITION} ${EXPORT_FILES})

# Create the target for this directory
add_library(PythonReflHelpersModule ${MODULE_DEFINITION} ${EXPORT_FILES} ${PYTHON_INSTALL_FILES})
add_library(PythonReflectometryHelpersModule ALIAS PythonReflHelpersModule)

set_python_properties(PythonReflHelpersModule _polarization_helpers)

# Add the required dependencies
target_link_libraries(PythonReflHelpersModule PRIVATE Mantid::Algorithms Mantid::PythonInterfaceCore)

# Installation settings
set_target_properties(PythonReflHelpersModule PROPERTIES INSTALL_RPATH "${EXT_INSTALL_RPATH}")
mtd_install_shared_library(
TARGETS PythonReflHelpersModule DESTINATION ${Python_SITELIB_RELPATH}/mantid/polarization_helpers.cpp
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2023 ISIS Rutherford Appleton Laboratory UKRI,
# Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +

###############################################################################
# Load the C++ library and register the C++ class exports
###############################################################################
from mantid.utils import import_mantid_cext

import_mantid_cext("._polarization_helpers", "mantid.utils.reflectometry", globals())
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +

#include "MantidAlgorithms/PolarizationCorrections/PolarizationCorrectionsHelpers.h"
#include <boost/python/class.hpp>

namespace {
class SpinStatesORSO {};
} // namespace

void export_SpinStatesORSO() {
using namespace boost::python;

class_<SpinStatesORSO>("SpinStatesORSO")
.def_readonly("PP", &Mantid::Algorithms::SpinStatesORSO::PP)
.def_readonly("PM", &Mantid::Algorithms::SpinStatesORSO::PM)
.def_readonly("MP", &Mantid::Algorithms::SpinStatesORSO::MP)
.def_readonly("MM", &Mantid::Algorithms::SpinStatesORSO::MM)
.def_readonly("PO", &Mantid::Algorithms::SpinStatesORSO::PO)
.def_readonly("MO", &Mantid::Algorithms::SpinStatesORSO::MO)
.def_readonly("LOG_NAME", &Mantid::Algorithms::SpinStatesORSO::LOG_NAME);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 2024 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +

@AUTO_GENERATE_WARNING@
/********** Source = polarization_helpers.cpp.in **********************************************************/

#include <boost/python/def.hpp>
#include <boost/python/module.hpp>

// Forward declare
@EXPORT_DECLARE@

BOOST_PYTHON_MODULE(_polarization_helpers)
{
@EXPORT_FUNCTIONS@
}

0 comments on commit 568667b

Please sign in to comment.