-
Notifications
You must be signed in to change notification settings - Fork 19
/
ExportAdcc.cc
72 lines (64 loc) · 2.35 KB
/
ExportAdcc.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// Copyright (C) 2018 by the adcc authors
//
// This file is part of adcc.
//
// adcc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// adcc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with adcc. If not, see <http://www.gnu.org/licenses/>.
//
#include "../backend.hh"
#include "../exceptions.hh"
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
namespace py = pybind11;
namespace libadcc {
void export_AdcMemory(py::module& m);
void export_adc_pp(py::module& m);
void export_HartreeFockProvider(py::module& m);
void export_MoIndexTranslation(py::module& m);
void export_MoSpaces(py::module& m);
void export_ReferenceState(py::module& m);
void export_Symmetry(py::module& m);
void export_Tensor(py::module& m);
void export_threading(py::module& m);
} // namespace libadcc
PYBIND11_MODULE(libadcc, m) {
libadcc::export_AdcMemory(m);
libadcc::export_adc_pp(m);
libadcc::export_HartreeFockProvider(m);
libadcc::export_MoIndexTranslation(m);
libadcc::export_MoSpaces(m);
libadcc::export_ReferenceState(m);
libadcc::export_Symmetry(m);
libadcc::export_Tensor(m);
libadcc::export_threading(m);
// Set metadata about libtensor
py::dict tensor_backend;
const libadcc::TensorBackend& back = libadcc::tensor_backend();
tensor_backend["name"] = back.name;
tensor_backend["version"] = back.version;
tensor_backend["authors"] = back.authors;
tensor_backend["features"] = back.features;
tensor_backend["blas"] = back.blas;
m.attr("__backend__") = tensor_backend;
// Exception translation
py::register_exception_translator([](std::exception_ptr p) {
try {
if (p) std::rethrow_exception(p);
} catch (const libadcc::not_implemented_error& ex) {
PyErr_SetString(PyExc_NotImplementedError, ex.what());
} catch (const libadcc::invalid_argument& ex) {
PyErr_SetString(PyExc_ValueError, ex.what());
}
});
}