Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
7c62ff14
Commit
7c62ff14
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
ImportMultilayer: add/simplify file header
parent
9ee78637
No related branches found
No related tags found
1 merge request
!1636
PyCore: Re-implementation of embedded Python as a separate module (Major change)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
PyCore/Sample/ImportMultiLayer.cpp
+16
-4
16 additions, 4 deletions
PyCore/Sample/ImportMultiLayer.cpp
PyCore/Sample/ImportMultiLayer.h
+3
-4
3 additions, 4 deletions
PyCore/Sample/ImportMultiLayer.h
with
19 additions
and
8 deletions
PyCore/Sample/ImportMultiLayer.cpp
+
16
−
4
View file @
7c62ff14
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file PyCore/Sample/ImportMultiLayer.h
//! @brief Implements createMultiLayerFromPython.
//!
//! @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)
//
// ************************************************************************************************
#ifdef BORNAGAIN_PYTHON
#include
"ImportMultiLayer.h"
...
...
@@ -18,11 +32,10 @@ PyObjectPtr createMultiLayerFromPython(void*& multilayer_ptr, const std::string&
// locate the `get_simulation` function (it is an attribute of the module)
PyObject
*
pAddFn
=
PyObject_GetAttrString
(
tmpModule
.
get
(),
functionName
.
c_str
());
if
(
!
pAddFn
)
{
if
(
!
pAddFn
)
throw
std
::
runtime_error
(
errorDescription
(
"PyInterpreter::BornAgain: "
"Cannot locate the compiled function '"
+
functionName
+
"'"
));
}
// create a `MultiLayer` Python object via calling the function
PyObject
*
instance
=
PyObject_CallFunctionObjArgs
(
pAddFn
,
NULL
);
...
...
@@ -30,10 +43,9 @@ PyObjectPtr createMultiLayerFromPython(void*& multilayer_ptr, const std::string&
// clean up
Py_DecRef
(
pAddFn
);
if
(
!
instance
)
{
if
(
!
instance
)
throw
std
::
runtime_error
(
errorDescription
(
"PyInterpreter::BornAgain: Cannot call the function '"
+
functionName
+
"'"
));
}
// Construct a C++ object from the Python object
/* NOTE:
...
...
This diff is collapsed.
Click to expand it.
PyCore/Sample/ImportMultiLayer.h
+
3
−
4
View file @
7c62ff14
...
...
@@ -3,7 +3,7 @@
// BornAgain: simulate and fit reflection and scattering
//
//! @file PyCore/Sample/ImportMultiLayer.h
//! @brief
Forward declaration for
createMultiLayerFromPython.
//! @brief
Declares
createMultiLayerFromPython.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
...
...
@@ -12,12 +12,11 @@
//
// ************************************************************************************************
#ifndef BORNAGAIN_PYCORE_SAMPLE_IMPORTMULTILAYER_H
#define BORNAGAIN_PYCORE_SAMPLE_IMPORTMULTILAYER_H
#ifdef SWIG
#error no need to expose this header to Swig
#endif
#ifndef BORNAGAIN_PYCORE_SAMPLE_IMPORTMULTILAYER_H
#define BORNAGAIN_PYCORE_SAMPLE_IMPORTMULTILAYER_H
#include
"PyCore/Embed/PyObjectPtr.h"
#include
<string>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment