Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐍 Add a .pyi file for integration with type checking, documentation, and IDE auto-completion #604

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8afbc7e
:snake: Added a `pyfiction.pyi` file with an example for setting up t…
marcelwa Dec 2, 2024
6b04f4d
:art: Replace `offset_area`, `cube_area`, and `siqad_area` with `area…
marcelwa Dec 3, 2024
9458338
:art: Fix duplicated `namespace py = pybind11;`
marcelwa Dec 3, 2024
d421796
:label: Complete type interface for coordinates
marcelwa Dec 3, 2024
0ad8c54
:label: Type interface for all coordinate layouts
marcelwa Dec 3, 2024
b468f54
:label: Type interface for all clocked layouts
marcelwa Dec 3, 2024
edf4b03
:label: Type interface for all gate-level layouts
marcelwa Dec 3, 2024
7f82138
:label: Type interface for all cell-level layouts
marcelwa Dec 3, 2024
559237d
:pencil2: Fix copy-paste error
marcelwa Dec 3, 2024
6113fd5
:label: Type interface for all obstruction layouts
marcelwa Dec 3, 2024
5641f9f
:label: Type interface for `technology_network`
marcelwa Dec 3, 2024
7d19916
:label: Type interface for `dynamic_truth_table`
marcelwa Dec 3, 2024
189a135
:label: Type interface for `a_star`
marcelwa Dec 3, 2024
6fbfef9
:label: Adjusted type interface for `a_star`
marcelwa Dec 3, 2024
4e06684
:label: Type interface for distance functions
marcelwa Dec 3, 2024
73bf524
:label: Type interface for `enumerate_all_paths`
marcelwa Dec 3, 2024
e35e38a
:label: Type interface for `yen_k_shortest_paths`
marcelwa Dec 3, 2024
fb8d3d7
:label: Type interface for all network transformations
marcelwa Dec 3, 2024
ee344bf
:bug: Fixed copy-paste errors
marcelwa Dec 3, 2024
236f63c
:label: Type interface for nm² area computations
marcelwa Dec 3, 2024
086ec43
:label: Type interface for gate library application and CP/TP calcula…
marcelwa Dec 3, 2024
3bf6811
:label: Type interface for `color_routing`
marcelwa Dec 4, 2024
5528c98
:label: Type interface for `exact` and `orthogonal`
marcelwa Dec 4, 2024
f5bc1fb
:memo: Update pyfiction docstrings
actions-user Dec 4, 2024
c27082f
:label: Type interface for logic simulation
marcelwa Dec 4, 2024
9acb053
Merge remote-tracking branch 'origin/python-interface' into python-in…
marcelwa Dec 4, 2024
e9fa1af
:label: Type interface for verification
marcelwa Dec 4, 2024
7f6b767
:label: Type interface for most I/O functionality
marcelwa Dec 4, 2024
d4e2aea
:art: first test.
Drewniok Dec 4, 2024
ac2039e
:art: first test.
Drewniok Dec 4, 2024
06ec97a
Merge branch 'main' into python-interface
Drewniok Dec 4, 2024
d38011d
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Dec 4, 2024
55e1d81
:snake: expose hexagonalization stats
simon1hofmann Dec 4, 2024
1946f06
:label: Type interface for more physical design algorithms
simon1hofmann Dec 4, 2024
1064ba7
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Dec 4, 2024
919d72f
:art: add SiDB functionality to pyi.
Drewniok Dec 5, 2024
3c0fbd2
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Dec 5, 2024
7ebf04b
:art: add more functions to pyi.
Drewniok Dec 10, 2024
da13edd
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Dec 10, 2024
c493ced
:bug: Fix compilation issue due to broken include
marcelwa Dec 10, 2024
b8609e7
:bug: Restore file that was mysteriously overwritten with a different…
marcelwa Dec 10, 2024
3814730
:memo: Update pyfiction docstrings
actions-user Dec 10, 2024
d04cd5d
:bug: Fixed many errors, warnings, and inconsistencies in the Python …
marcelwa Dec 10, 2024
b500068
Merge remote-tracking branch 'origin/python-interface' into python-in…
marcelwa Dec 10, 2024
e670dc3
:rotating_light: Fixed a bunch more warnings and errors (still a long…
marcelwa Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 10 additions & 27 deletions bindings/mnt/pyfiction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
## physical_design
apply_qca_one_library,
apply_topolinano_library,
# Technology
area,
assess_physical_population_stability,
assess_physical_population_stability_100,
assess_physical_population_stability_111,
# Technology
assess_physical_population_stability_params,
automatic_base_number_detection,
bdl_input_iterator_100,
Expand Down Expand Up @@ -71,7 +72,6 @@
color_routing_params,
compute_operational_ratio,
compute_operational_ratio_params,
convert_layout_to_siqad_coordinates,
convert_potential_to_distance,
create_and3_tt,
create_and_tt,
Expand Down Expand Up @@ -105,9 +105,7 @@
critical_temperature_non_gate_based,
critical_temperature_params,
critical_temperature_stats,
cube_area,
cube_coordinate,
cube_volume,
defect_extent,
dependent_cell_mode,
design_sidb_gates,
Expand Down Expand Up @@ -152,9 +150,6 @@
## verfication
gate_level_drv_params,
gate_level_drvs,
generate_multiple_random_sidb_layouts,
generate_random_sidb_layout,
generate_random_sidb_layout_params,
get_name,
gold_cost_objective,
gold_effort_mode,
Expand Down Expand Up @@ -197,9 +192,7 @@
num_adjacent_coordinates,
occupation_probability_gate_based,
occupation_probability_non_gate_based,
offset_area,
offset_coordinate,
offset_volume,
operational_condition,
operational_domain,
operational_domain_contour_tracing,
Expand All @@ -219,7 +212,6 @@
physically_valid_parameters_domain,
place,
population_stability_information,
positive_charges,
post_layout_optimization,
post_layout_optimization_params,
post_layout_optimization_stats,
Expand Down Expand Up @@ -263,9 +255,7 @@
sign_to_charge_state,
### logic
simulate,
siqad_area,
siqad_coordinate,
siqad_volume,
sqd_parsing_error,
squared_euclidean_distance,
## network_transformation
Expand All @@ -291,6 +281,7 @@
undefined_cell_label_exception,
unrecognized_cell_definition_exception,
unsupported_character_exception,
volume,
wiring_reduction,
wiring_reduction_params,
wiring_reduction_stats,
Expand Down Expand Up @@ -336,7 +327,8 @@
"apply_topolinano_library",
# Technology
"area",
"assess_physical_population_stability",
"assess_physical_population_stability_100",
"assess_physical_population_stability_111",
"assess_physical_population_stability_params",
"automatic_base_number_detection",
"bdl_input_iterator_100",
Expand Down Expand Up @@ -371,7 +363,6 @@
"color_routing_params",
"compute_operational_ratio",
"compute_operational_ratio_params",
"convert_layout_to_siqad_coordinates",
"convert_potential_to_distance",
"create_and3_tt",
"create_and_tt",
Expand Down Expand Up @@ -405,9 +396,7 @@
"critical_temperature_non_gate_based",
"critical_temperature_params",
"critical_temperature_stats",
"cube_area",
"cube_coordinate",
"cube_volume",
"defect_extent",
"dependent_cell_mode",
"design_sidb_gates",
Expand Down Expand Up @@ -452,9 +441,6 @@
## verfication
"gate_level_drv_params",
"gate_level_drvs",
"generate_multiple_random_sidb_layouts",
"generate_random_sidb_layout",
"generate_random_sidb_layout_params",
"get_name",
"gold_cost_objective",
"gold_effort_mode",
Expand All @@ -477,6 +463,7 @@
"is_charged_defect_type",
"is_crossable_wire",
"is_fanout_substituted",
set_name,
"is_ground_state",
"is_kink_induced_non_operational",
"is_negatively_charged_defect",
Expand All @@ -497,9 +484,7 @@
"num_adjacent_coordinates",
"occupation_probability_gate_based",
"occupation_probability_non_gate_based",
"offset_area",
"offset_coordinate",
"offset_volume",
"operational_condition",
"operational_domain",
"operational_domain_contour_tracing",
Expand All @@ -519,7 +504,6 @@
"physically_valid_parameters_domain",
"place",
"population_stability_information",
"positive_charges",
"post_layout_optimization",
"post_layout_optimization_params",
"post_layout_optimization_stats",
Expand All @@ -541,7 +525,6 @@
"route_path",
# "write_location_and_ground_state",
"sample_writing_mode",
"set_name",
"shifted_cartesian_gate_layout",
"shifted_cartesian_layout",
"shifted_cartesian_obstruction_layout",
Expand All @@ -550,7 +533,6 @@
"sidb_charge_state",
"sidb_defect",
"sidb_defect_type",
"sidb_lattice_mode",
"sidb_layout",
"sidb_nm_distance_100",
"sidb_nm_distance_111",
Expand All @@ -563,9 +545,9 @@
"sign_to_charge_state",
### logic
"simulate",
"siqad_area",
"area",
"siqad_coordinate",
"siqad_volume",
"volume",
"sqd_parsing_error",
"squared_euclidean_distance",
## network_transformation
Expand Down Expand Up @@ -614,4 +596,5 @@
"write_sqd_sim_result",
"yen_k_shortest_paths",
"yen_k_shortest_paths_params",
"sidb_lattice_mode",
]
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ inline void technology_mapping(pybind11::module& m)
py::class_<fiction::technology_mapping_stats>(m, "technology_mapping_stats", DOC(fiction_technology_mapping_stats))
.def(py::init<>())
.def("__repr__", [](const fiction::technology_mapping_stats& stats) { return stats.report(); })
.def("report", &fiction::technology_mapping_stats::report, DOC(fiction_technology_mapping_stats_report))
.def_readonly("mapper_stats", &fiction::technology_mapping_stats::mapper_stats,
DOC(fiction_technology_mapping_stats_mapper_stats));
.def("report", &fiction::technology_mapping_stats::report, DOC(fiction_technology_mapping_stats_report));

m.def("and_or_not", &fiction::and_or_not, DOC(fiction_and_or_not));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ inline void yen_k_shortest_paths(pybind11::module& m)
py::class_<fiction::yen_k_shortest_paths_params>(m, "yen_k_shortest_paths_params",
DOC(fiction_yen_k_shortest_paths_params))
.def(py::init<>())
.def_readwrite("a_star_params", &fiction::yen_k_shortest_paths_params::astar_params,
.def_readwrite("astar_params", &fiction::yen_k_shortest_paths_params::astar_params,
DOC(fiction_yen_k_shortest_paths_params_astar_params))

;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <fiction/algorithms/physical_design/exact.hpp>

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include <sstream>

Expand All @@ -26,7 +25,6 @@ namespace pyfiction
inline void exact(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

py::enum_<fiction::technology_constraints>(m, "technology_constraints", DOC(fiction_technology_constraints))
.value("NONE", fiction::technology_constraints::NONE, DOC(fiction_technology_constraints_NONE))
Expand All @@ -39,6 +37,8 @@ inline void exact(pybind11::module& m)
.def(py::init<>())
.def_readwrite("scheme", &fiction::exact_physical_design_params::scheme,
DOC(fiction_exact_physical_design_params_scheme))
.def_readwrite("upper_bound_area", &fiction::exact_physical_design_params::upper_bound_area,
DOC(fiction_exact_physical_design_params_upper_bound_area))
.def_readwrite("upper_bound_x", &fiction::exact_physical_design_params::upper_bound_x,
DOC(fiction_exact_physical_design_params_upper_bound_x))
.def_readwrite("upper_bound_y", &fiction::exact_physical_design_params::upper_bound_y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace pyfiction
inline void graph_oriented_layout_design(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

py::enum_<fiction::graph_oriented_layout_design_params::effort_mode>(
m, "gold_effort_mode", DOC(fiction_graph_oriented_layout_design_params_effort_mode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@

#include <pybind11/pybind11.h>

namespace pyfiction
{
#include <sstream>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: included header sstream is not used directly [misc-include-cleaner]

Suggested change

namespace detail
namespace pyfiction
{

template <typename Lyt>
void hexagonalization(pybind11::module& m)
inline void hexagonalization(pybind11::module& m)
{
namespace py = pybind11;

m.def(
"hexagonalization", [](const Lyt& lyt) -> py_hexagonal_gate_layout
{ return fiction::hexagonalization<py_hexagonal_gate_layout, Lyt>(lyt); }, py::arg("layout"),
DOC(fiction_hexagonalization));
}

} // namespace detail

inline void hexagonalization(pybind11::module& m)
{
detail::hexagonalization<py_cartesian_gate_layout>(m);
py::class_<fiction::hexagonalization_stats>(m, "hexagonalization_stats", DOC(fiction_hexagonalization_stats))
.def(py::init<>())
.def("__repr__",
[](const fiction::hexagonalization_stats& stats)
{
std::stringstream stream{};
stats.report(stream);
return stream.str();
})
.def_readonly("time_total", &fiction::hexagonalization_stats::time_total,
DOC(fiction_hexagonalization_stats_duration));

m.def("hexagonalization", &fiction::hexagonalization<py_hexagonal_gate_layout, py_cartesian_gate_layout>,
py::arg("layout"), py::arg("statistics") = nullptr, DOC(fiction_hexagonalization));
}

} // namespace pyfiction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <fiction/algorithms/physical_design/orthogonal.hpp>

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include <sstream>

Expand All @@ -24,7 +23,6 @@ namespace pyfiction
inline void orthogonal(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

py::class_<fiction::orthogonal_physical_design_params>(m, "orthogonal_params",
DOC(fiction_orthogonal_physical_design_params))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace pyfiction
inline void post_layout_optimization(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

py::class_<fiction::post_layout_optimization_params>(m, "post_layout_optimization_params",
DOC(fiction_post_layout_optimization_params))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace pyfiction
inline void wiring_reduction(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

py::class_<fiction::wiring_reduction_params>(m, "wiring_reduction_params", DOC(fiction_wiring_reduction_params))
.def(py::init<>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef PYFICTION_LOGIC_SIMULATION_HPP
#define PYFICTION_LOGIC_SIMULATION_HPP

#include "pyfiction/documentation.hpp"
#include "pyfiction/types.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'pyfiction/types.hpp' file not found [clang-diagnostic-error]

#include "pyfiction/types.hpp"
         ^


#include <fiction/utils/name_utils.hpp>
Expand All @@ -16,6 +15,7 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include <cassert>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ template <typename Lyt>
void assess_physical_population_stability(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

m.def("assess_physical_population_stability", &fiction::assess_physical_population_stability<Lyt>, py::arg("lyt"),
py::arg("params") = fiction::assess_physical_population_stability_params{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ template <typename Lyt>
void compute_operational_ratio(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

m.def("compute_operational_ratio", &fiction::compute_operational_ratio<Lyt, py_tt>, py::arg("lyt"), py::arg("spec"),
py::arg("pp"), py::arg("params") = fiction::operational_domain_params{},
Expand All @@ -36,7 +35,6 @@ void compute_operational_ratio(pybind11::module& m)
inline void compute_operational_ratio(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

py::class_<fiction::compute_operational_ratio_params>(m, "compute_operational_ratio_params",
DOC(fiction_compute_operational_ratio_params))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void detect_bdl_pairs(pybind11::module& m)
inline void detect_bdl_pairs(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

py::class_<fiction::bdl_pair<fiction::offset::ucoord_t>>(m, "bdl_pair", DOC(fiction_bdl_pair))
.def(py::init<>(), DOC(fiction_bdl_pair_bdl_pair))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ template <typename Lyt>
void detect_bdl_wires(pybind11::module& m, const std::string& lattice)
{
namespace py = pybind11;
namespace py = pybind11;

using bdl_wire_t = fiction::bdl_wire<Lyt>;

Expand Down Expand Up @@ -52,7 +51,6 @@ void detect_bdl_wires(pybind11::module& m, const std::string& lattice)
inline void detect_bdl_wires(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

// Enum for wire selection options
py::enum_<fiction::bdl_wire_selection>(m, "bdl_wire_selection", DOC(fiction_bdl_wire_selection))
Expand Down
Loading
Loading