22#include <c2py/converters/basic_types.hpp>
23#include <c2py/converters/stl/array.hpp>
24#include <c2py/converters/wrapped.hpp>
25#include <c2py/py_converter.hpp>
26#include <c2py/pyref.hpp>
39 template <>
struct py_converter<triqs::lattice::bravais_lattice::point_t> {
40 using c_t = triqs::lattice::bravais_lattice::point_t;
42 static constexpr const char *tp_name =
"LatticePoint";
44 static PyObject *c2py(c_t
const &x) {
45 pyref cls = pyref::get_class(
"triqs.lattice",
"LatticePoint",
true);
46 if (cls.is_null())
return NULL;
48 pyref kw = PyDict_New();
50 pyref index = cxx2py(x.index());
51 if (index.is_null())
return NULL;
52 pyref lattice = cxx2py(x.lattice());
53 if (lattice.is_null())
return NULL;
54 PyDict_SetItemString(kw,
"index", index);
55 PyDict_SetItemString(kw,
"lattice", lattice);
57 pyref empty_tuple = PyTuple_New(0);
58 return PyObject_Call(cls, empty_tuple, kw);
61 static bool is_convertible(PyObject *ob,
bool raise_exception) {
62 pyref cls = pyref::get_class(
"triqs.lattice",
"LatticePoint",
true);
63 if (not pyref::check_is_instance(ob, cls, raise_exception))
return false;
69 using lattice_py_type =
struct {
71 triqs::lattice::bravais_lattice *_c;
74 static c_t py2c(PyObject *ob) {
76 pyref x = pyref::borrowed(ob);
77 pyref index = x.attr(
"index");
78 pyref lattice = x.attr(
"lattice");
79 auto *lattice_c_ptr =
reinterpret_cast<lattice_py_type *
>(
static_cast<PyObject *
>(lattice))->_c;
80 if (lattice_c_ptr == NULL) {
81 std::cerr <<
"Severe internal error : lattice_ptr is null in py2c\n";
85 return c_t{py2cxx<std::array<long, 3>>(index), lattice_c_ptr};
Provides a Bravais lattice class.
Additional converters for gf.