-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Restore file that was mysteriously overwritten with a different one
- Loading branch information
Showing
1 changed file
with
75 additions
and
10 deletions.
There are no files selected for viewing
85 changes: 75 additions & 10 deletions
85
bindings/mnt/pyfiction/include/pyfiction/utils/layout_utils.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,90 @@ | ||
// | ||
// Created by Jan Drewniok on 11.11.24. | ||
// Created by marcel on 21.11.23. | ||
// | ||
|
||
#ifndef PYFICTION_VERSION_INFO_HPP | ||
#define PYFICTION_VERSION_INFO_HPP | ||
#ifndef PYFICTION_LAYOUT_UTILS_HPP | ||
#define PYFICTION_LAYOUT_UTILS_HPP | ||
|
||
#include <fiction/utils/version_info.hpp.in> | ||
#include "pyfiction/documentation.hpp" | ||
#include "pyfiction/types.hpp" | ||
|
||
#include <fiction/traits.hpp> | ||
#include <fiction/utils/layout_utils.hpp> | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace pyfiction | ||
{ | ||
|
||
inline void version_info(pybind11::module& m) | ||
namespace detail | ||
{ | ||
|
||
template <typename Lyt> | ||
void num_adjacent_coordinates(pybind11::module& m) | ||
{ | ||
namespace py = pybind11; | ||
|
||
m.def("num_adjacent_coordinates", &fiction::num_adjacent_coordinates<Lyt>, py::arg("lyt"), py::arg("c"), | ||
DOC(fiction_num_adjacent_coordinates)); | ||
} | ||
|
||
template <typename Lyt> | ||
void normalize_layout_coordinates(pybind11::module& m) | ||
{ | ||
namespace py = pybind11; | ||
|
||
m.def("normalize_layout_coordinates", &fiction::normalize_layout_coordinates<Lyt>, py::arg("lyt"), | ||
DOC(fiction_normalize_layout_coordinates)); | ||
} | ||
|
||
template <typename Lyt> | ||
void convert_to_siqad_coordinates(pybind11::module& m) | ||
{ | ||
namespace py = pybind11; | ||
|
||
m.def("convert_layout_to_siqad_coordinates", &fiction::convert_layout_to_siqad_coordinates<Lyt>, py::arg("lyt"), | ||
DOC(fiction_convert_layout_to_siqad_coordinates)); | ||
} | ||
|
||
template <typename Lyt> | ||
void random_coordinate(pybind11::module& m) | ||
{ | ||
namespace py = pybind11; | ||
|
||
m.def("random_coordinate", &fiction::random_coordinate<fiction::coordinate<Lyt>>, py::arg("coordinate1"), | ||
py::arg("coordinate_2"), DOC(fiction_random_coordinate)); | ||
} | ||
|
||
} // namespace detail | ||
|
||
inline void layout_utils(pybind11::module& m) | ||
{ | ||
m.attr("__version__") = fiction::FICTION_VERSION; | ||
m.attr("__repo__") = fiction::FICTION_REPO; | ||
m.attr("__compiled_date__") = fiction::COMPILED_DATE; | ||
m.attr("__compiled_time__") = fiction::COMPILED_TIME; | ||
// NOTE be careful with the order of the following calls! Python will resolve the first matching overload! | ||
|
||
detail::num_adjacent_coordinates<py_cartesian_obstruction_layout>(m); | ||
detail::num_adjacent_coordinates<py_cartesian_gate_layout>(m); | ||
detail::num_adjacent_coordinates<py_shifted_cartesian_obstruction_layout>(m); | ||
detail::num_adjacent_coordinates<py_shifted_cartesian_gate_layout>(m); | ||
detail::num_adjacent_coordinates<py_hexagonal_obstruction_layout>(m); | ||
detail::num_adjacent_coordinates<py_hexagonal_gate_layout>(m); | ||
|
||
detail::normalize_layout_coordinates<py_qca_layout>(m); | ||
detail::normalize_layout_coordinates<py_inml_layout>(m); | ||
detail::normalize_layout_coordinates<py_sidb_layout>(m); | ||
|
||
detail::convert_to_siqad_coordinates<py_sidb_layout>(m); | ||
|
||
detail::random_coordinate<py_cartesian_obstruction_layout>(m); | ||
detail::random_coordinate<py_cartesian_gate_layout>(m); | ||
detail::random_coordinate<py_shifted_cartesian_obstruction_layout>(m); | ||
detail::random_coordinate<py_shifted_cartesian_gate_layout>(m); | ||
detail::random_coordinate<py_hexagonal_obstruction_layout>(m); | ||
detail::random_coordinate<py_hexagonal_gate_layout>(m); | ||
detail::random_coordinate<py_qca_layout>(m); | ||
detail::random_coordinate<py_inml_layout>(m); | ||
detail::random_coordinate<py_sidb_layout>(m); | ||
} | ||
|
||
} // namespace pyfiction | ||
|
||
#endif // PYFICTION_VERSION_INFO_HPP | ||
#endif // PYFICTION_LAYOUT_UTILS_HPP |