Skip to content

Commit

Permalink
Feature/routing-v3 (#167)
Browse files Browse the repository at this point in the history
* Update build_and_test.yml

* Feature/TokenSwapping (#94)

* Copy TokenSwapping CodeBase, update CMakeLists.txt

* Add TokenSwapping tests

* Update GraphTests to use TokenSwapping RNG

* Remove "class RNG;"

* Add cpp files to compilation

* Add "MappingManager" class and port older routing solution (#95)

* Copy code from private repository

* Add binders for mapping module

* Adding mapping module to setup.py

* Add shared_ptr to Architecture subclasses in binder file

* Port python test for mapping module

* Add token swapping stage to routing v3 (#96)

* Assert candidate swaps size (#108)

* Add assertion that there are at least some swaps to trial

* Pseudo code for Yao

* Fix routing with measurements issue

* Add classically controlled gates to lexiroute test

Co-authored-by: sjdilkes <[email protected]>

* Update Architecture method names

* get_all_nodes -> nodes

* Update Compilation Passes to use RoutingV3 (#115)

* Add token swapping stage, add test

* Update compilation passes to use new routing

* Add json serialization

* Continue adding JSON serialisation for routing_config

* Improve Json definitions

* Update JSON Serialization and use of Barrier

* Change from reference_wrapper to shared_ptr

* Add JSON_DECL for std::vector<RoutingMethodPtr>

* format routing_test

* Fix up tests and binders for python

* Uncoment measurement tests

* rename method to merge_ancilla

* debug proptest

* Make add_qubit add qubit to unit_bimaps_ if not nullptr

* Architectures -> Architecture

* Install boost on MacOS.

* comments to debug

* update proptest to support ancillas properly

* remove couts

* format

* Make Unitary dimensions match

* add tket assert for comparison

* Update test to check value

* add_qubit -> add_ancilla

* Remove kwargs formatting from argument

* Rename Architecture Methods

* rename architecture methods

* Allow architecture mapping to take original edges, to calculate Node to size_t mapping

* add get_square_grid_edges, to allow fixed tests independent of SquareGrid

* use ArchitectureMapping and edges in most tests, instead of Architecture

* trivial typos, comments, cmake update

* add copyright notices, pragma once, remove semicolon typos

* update binders for inheritance and docs

* format

* Remove NodeGraph

* update formatting

* Update CMakeLists and Setup.py

* Use explicit shared_ptr

* Refactor Routing module binder

Make "FullMappingPass" use a kwargs based argument to get round faulty docs type definitions.

* remove trailing whitespace

* update clang formatting

* reformat file

* update orientation of BRIDGE gates

* Update conf docs mapping, remove kwargs full mapping pass

Co-authored-by: Alec Edgington <[email protected]>
Co-authored-by: Zen Harper <[email protected]>

* Remove outdated Routing code from repository (#165)

* Add token swapping stage, add test

* Update compilation passes to use new routing

* Add json serialization

* Continue adding JSON serialisation for routing_config

* Improve Json definitions

* Update JSON Serialization and use of Barrier

* Change from reference_wrapper to shared_ptr

* Add JSON_DECL for std::vector<RoutingMethodPtr>

* format routing_test

* Fix up tests and binders for python

* Uncoment measurement tests

* rename method to merge_ancilla

* debug proptest

* Make add_qubit add qubit to unit_bimaps_ if not nullptr

* Architectures -> Architecture

* Install boost on MacOS.

* comments to debug

* update proptest to support ancillas properly

* remove couts

* format

* Make Unitary dimensions match

* add tket assert for comparison

* Update test to check value

* add_qubit -> add_ancilla

* Remove kwargs formatting from argument

* Rename Architecture Methods

* rename architecture methods

* Allow architecture mapping to take original edges, to calculate Node to size_t mapping

* add get_square_grid_edges, to allow fixed tests independent of SquareGrid

* use ArchitectureMapping and edges in most tests, instead of Architecture

* trivial typos, comments, cmake update

* add copyright notices, pragma once, remove semicolon typos

* update binders for inheritance and docs

* format

* Remove NodeGraph

* update formatting

* Update CMakeLists and Setup.py

* Use explicit shared_ptr

* Refactor Routing module binder

Make "FullMappingPass" use a kwargs based argument to get round faulty docs type definitions.

* remove trailing whitespace

* update clang formatting

* reformat file

* update orientation of BRIDGE gates

* Remove src/Routing

Move Placement files into new src/Placement subdirectory, update tests as necessary, move connectivty constraint verification to utils

* update tket/pytket to not install or use old pytket.routing

* clang formatting

* Update mitigation test to use explicit placement

* remove binder file

* Update conf docs mapping, remove kwargs full mapping pass

* update docs for new python modules

* Move Verification files to src/Mapping subdirectory

* Delete test_Routing.cpp

* Update imports for Verification.hpp

* Add default argument to LexiRouteRoutingMethod binder

Update python tests to use default

* upadte Verification.cpp compilation pass

* Formatting

Co-authored-by: Alec Edgington <[email protected]>
Co-authored-by: Zen Harper <[email protected]>

* Improve LexiRoute.cpp coverage

* Improve MappingFrontier.cpp test coverage

* Rmoeve decmopose_module method

* readd missing test

* Update LexiRoute test coverage

* Remove redundant comments

* Feature/reorder multi qubit gates (#157)

* Add token swapping stage, add test

* Update compilation passes to use new routing

* Add json serialization

* Continue adding JSON serialisation for routing_config

* Improve Json definitions

* Update JSON Serialization and use of Barrier

* Change from reference_wrapper to shared_ptr

* Add JSON_DECL for std::vector<RoutingMethodPtr>

* format routing_test

* Fix up tests and binders for python

* Uncoment measurement tests

* rename method to merge_ancilla

* debug proptest

* Make add_qubit add qubit to unit_bimaps_ if not nullptr

* Architectures -> Architecture

* Install boost on MacOS.

* comments to debug

* update proptest to support ancillas properly

* remove couts

* format

* Make Unitary dimensions match

* add tket assert for comparison

* Update test to check value

* add_qubit -> add_ancilla

* Remove kwargs formatting from argument

* Rename Architecture Methods

* rename architecture methods

* Allow architecture mapping to take original edges, to calculate Node to size_t mapping

* add get_square_grid_edges, to allow fixed tests independent of SquareGrid

* use ArchitectureMapping and edges in most tests, instead of Architecture

* trivial typos, comments, cmake update

* add copyright notices, pragma once, remove semicolon typos

* update binders for inheritance and docs

* format

* Remove NodeGraph

* update formatting

* Reorder CZ circuits

* Revert "Reorder CZ circuits"

This reverts commit 9d67720.

* Make two methods in MappingFrontier public

* Add MultiGateReorderRoutingMethod

* Remove unnecessary frontier advancement

* Avoid copying the whole MappingFrontier

* Remove the edge_in_frontier method

* Add comment for vertex rewiring

* Allow users to set search limits

* Change default max depth/size limits to 10

* Fix using incorrect port colours

* Obtain unitid by traversing to frontier instead of inputs

* Add test for MultiGateReorderRoutingMethod

* Refactor condition checks and rewire

* Implement check_method

* Add test for routing with LexiRoute

Co-authored-by: sjdilkes <[email protected]>
Co-authored-by: Alec Edgington <[email protected]>
Co-authored-by: Zen Harper <[email protected]>

* modify TKET_ASSERT: allow extra messages, catch exceptions in evaluation

* replace some exceptions with tket asserts; should be ignored by test coverage

* Start moving files for modularisation

* compilation refactor commit

* Reorder base cmake

* add assertmessage.cpp to compiilation

* Rework TokenSwapping includes

* clang format

* update linking for pytket

* reformat with black

* Revert "reformat with black"

This reverts commit 66ce863.

* reformat setup.py

* update proptests cmakelists

* Feature/add serialisation for multi qubit reorder (#184)

* Add JSON serialisation for  MultiGateReorderRoutingMethod
and getters

* Add tests for JSON serialisation for MultiGateReorderRoutingMethod

* Update test coverage for RoutingMethod serialization

* make mapping_frontier from mapping_frontier

* routing -> mapping

* use TKET_ASSERT_WITH_THROW instead of TKET_ASSERT

* Replace TKET_ASSERT with throw and use GCOVR_EXCL_START,STOP where appropriate

* replace throws with TKET_ASSERT_WITH_THROW where appropriate

* Add the TKET_ASSERT_WITH_THROW macro

* add simple swap functions tests

* add TKET_ASSERT_WITH_THROW tests, for detailed error messages

* clang format

* try to fix code coverage branching problems in TKET_ASSERT_WITH_THROW by hiding throws

* correct "does not return a value" error

* Infra/use bimap for quantum boundary (#185)

* Add sequenced_bimap_t

* Use sequenced_bimap_t for unit_vertport_frontier_t

* Update MultiGateReorder

* remove try/catch from tket assert with throw, to cut down branching

* remove TKET_ASSERT_WITH_THROW, replace with TKET_ASSERT

* Remove AssertMessage(), add TKET_ASSERT_WITH_MESSAGE

* manually add coverage exclusion tags for now, until the branching problem is fixed

* Add copyright information

* [RV3] [refactor] Clean up of the dependencies of the modules (#199)

* remove cycle from cmake lists

* clean up

* add comment

* fix binder include

* try to fix pytket build

* try to fix problems

* fix windows build

* try to fix windows

* add bimaps attribute to MappingFrontier

* update_quantum_boundary_uids remaps bimaps entries

* Update build_and_test.yml

* Update changelog.rst

* Update copyright dates

2021 -> 2022

* Update pytket/binders/mapping.cpp

Co-authored-by: Alec Edgington <[email protected]>

* Update pytket/binders/mapping.cpp

Co-authored-by: Alec Edgington <[email protected]>

* Update pytket/binders/mapping.cpp

Co-authored-by: Alec Edgington <[email protected]>

* Corrections for PR

* Remove tokenswapping from dependneices

* Feature/decompose boxes in routing (#197)

* Reject boxes in Architecture::valid_operation

* Add `next_q_cut` method to a quantum cut
Only consider quantum edges

* Use `next_q_cut` in `advance_frontier_boundary`

* Add BoxDecompositionRoutingMethod

* Add tests

* Reformat

* Reject boxes in LexiRouteMethod::check_method

* Update tests

* Add JSON serialisation

* Handle unused arguments

* Refactor Circuit::decompose_boxes

* fix naming

Co-authored-by: sjdilkes <[email protected]>

* update compilation for tokenswapping

* Revert "Feature/decompose boxes in routing (#197)"

This reverts commit 86fb61e.

* Address PR Requested changes

* change copyright to 2022

* remove unused code, including PathFinderInterface

* rename HybridTsa00 -> HybridTsa; move files out of include directory

* move DebugFunctions into tests

* move get_swaps_lower_bound out of tket into tests

* simple typos; unused code; extra comments, asserts

* rename main_entry_functions -> SwapsFromQubitMapping; remove unused function

* move RNG from token swapping to Utils; erase tests/Graphs/RNG

* move get_random_set out of token swapping into test utils

* move some stuff out of namespace tsa_internal into namespace tket

* more cleanup

* clang format

* added OpType dependency to token swapping

* clang format

* replace throws with TKET_ASSERT_WITH_MESSAGE

* move BruteForceColouring.hpp, ColouringPriority.hpp out of include directory

* add TokenSwappingWithArch project; move files out of TokenSwapping

* remove architecture from TokenSwapping

* move DistancesInterface, NeighboursInterface out of namespace tsa_internal

* update TokenSwapping tests to use TokenSwappingWithArch

* bool type for delay_measures

* Create architecture_test.py

* Reduce test times: add TSGlobalTestParameters with run_long_tests option

* add test_DebugFunctions.cpp and remove test coverage exclusion

* Remove unreachable code.

* update architecture binder

* Revert "update architecture binder"

This reverts commit d7bbd01.

* formatting, remove nodegraph test

* update architecture and mapping tests

* add architecture_aware_synthesis_test.py

* Create placement_test.py

* Update range of python mapping tests

* update routing test coverage

* Cover Alec's comments

* format transform_test

* change length of line

* remove trailing white space

* name -> name_of_ethod

* name -> name_of_method RoutingMethod

* tokenswappingwitharch

* add type ignores

* "name_of_method" -> "name'

* Update valid_operation description

* reformat transform_test

and remove "had"

* remove second auto_rebase_pass

* Add missing import.

* Add option to tket-tests conan build determining whether full tests are run.

If tket-tests:full=True, the compiler flag TKET_TESTS_FULL is defined.

* remove TokenSwappingWithArch project; move files into Architecture

* Set "full tests" option on scheduled CI runs only.

* change TKET_ASSERT_WITH_MESSAGE to have parentheses around message

* Add note to README.

* rename HybridTSA_00 to HybridTsa

* Replace TSGlobalTestParameters with #ifdef TKET_TESTS_FULL

* commit other forgotten files

* Remove GetTketAssertMessage and TKET_ASSERT_WITH_MESSAGE, go back to AssertMessage().

* clang format

* Move test_Utils.cpp to test/Utils directory, rename to test_HelperFunctions.cpp

* fix "function does not return a value" error

* fix "non-void function does not return a value" error, attempt 2!

* Forgot to remove final TokenSwappingWithArch bits

* Fix build failure.

Puzzling.

* Fix for mypy,

Co-authored-by: yao-cqc <[email protected]>
Co-authored-by: Alec Edgington <[email protected]>
Co-authored-by: Zen Harper <[email protected]>
Co-authored-by: cqc-melf <[email protected]>
Co-authored-by: Alec Edgington <[email protected]>
Co-authored-by: melf <[email protected]>
  • Loading branch information
7 people authored Feb 19, 2022
1 parent 4f6746e commit 8b818fa
Show file tree
Hide file tree
Showing 231 changed files with 28,437 additions and 5,768 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
${conan_cmd} profile update settings.compiler.libcxx=libstdc++11 tket
${conan_cmd} profile update options.tket:shared=True tket
echo "CONAN_CMD=${conan_cmd}" >> $GITHUB_ENV
- name: set option to run full test suite
if: github.event_name == 'schedule'
run: ${CONAN_CMD} profile update options.tket-tests:full=True tket
- name: add remote
run: ${CONAN_CMD} remote add tket-conan https://tket.jfrog.io/artifactory/api/conan/tket-conan
- name: Install ninja and ccache
Expand Down Expand Up @@ -177,6 +180,9 @@ jobs:
conan profile update options.tket:shared=True tket
export CC=`which conan`
echo "CONAN_CMD=${CC}" >> $GITHUB_ENV
- name: set option to run full test suite
if: github.event_name == 'schedule'
run: conan profile update options.tket-tests:full=True tket
- name: add remote
run: conan remote add tket-conan https://tket.jfrog.io/artifactory/api/conan/tket-conan --force
- name: Install boost
Expand Down Expand Up @@ -268,6 +274,9 @@ jobs:
conan profile update options.tket:shared=True tket
export CC=`which conan`
echo "CONAN_CMD=${CC}" >> $GITHUB_ENV
- name: set option to run full test suite
if: github.event_name == 'schedule'
run: conan profile update options.tket-tests:full=True tket
- name: add remote
run: conan remote add tket-conan https://tket.jfrog.io/artifactory/api/conan/tket-conan --force
- name: Install boost
Expand Down Expand Up @@ -366,6 +375,9 @@ jobs:
conan profile update options.tket:shared=True tket
$conan_cmd = (gcm conan).Path
echo "CONAN_CMD=${conan_cmd}" >> $GITHUB_ENV
- name: set option to run full test suite
if: github.event_name == 'schedule'
run: conan profile update options.tket-tests:full=True tket
- name: add remote
run: conan remote add tket-conan https://tket.jfrog.io/artifactory/api/conan/tket-conan
- name: Cache tket build
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ conan create --profile=tket recipes/tket-tests
If you want to build them without running them, pass `--test-folder None` to the
`conan` command. (You can still run them manually afterwards.)

Some tests (those that add significantly to the runtime) are not built by
default. To build all tests, add `-o tket-tests:full=True` to the above
`conan create` command.

There is also a small set of property-based tests which you can build and run
with:

Expand Down
42 changes: 30 additions & 12 deletions pytket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ target_link_libraries(circuit PRIVATE
tket-Gate
tket-Ops
tket-OpType
tket-Routing
tket-Mapping
tket-TokenSwapping
tket-Simulation
tket-Utils)
target_link_libraries(circuit PRIVATE ${TKET_EXTRA_LIBS})
Expand All @@ -66,23 +67,19 @@ if (WIN32)
target_link_libraries(circuit PRIVATE bcrypt)
endif()

pybind11_add_module(routing binders/routing.cpp)
target_include_directories(routing PRIVATE binders/include)
target_link_libraries(routing PRIVATE
pybind11_add_module(mapping binders/mapping.cpp)
target_include_directories(mapping PRIVATE binders/include)
target_link_libraries(mapping PRIVATE
tket-Architecture
tket-Characterisation
tket-Circuit
tket-Gate
tket-Graphs
tket-Mapping
tket-Ops
tket-OpType
tket-Routing
tket-TokenSwapping
tket-Utils)
target_link_libraries(routing PRIVATE ${TKET_EXTRA_LIBS})
if (WIN32)
# For boost::uuid:
target_link_libraries(routing PRIVATE bcrypt)
endif()

pybind11_add_module(transform binders/transform.cpp)
target_include_directories(transform PRIVATE binders/include)
Expand Down Expand Up @@ -116,11 +113,12 @@ target_link_libraries(predicates PRIVATE
tket-Converters
tket-Gate
tket-Graphs
tket-Mapping
tket-Ops
tket-OpType
tket-PauliGraph
tket-Predicates
tket-Routing
tket-TokenSwapping
tket-Transformations
tket-Utils)
target_link_libraries(predicates PRIVATE ${TKET_EXTRA_LIBS})
Expand All @@ -140,11 +138,12 @@ target_link_libraries(passes PRIVATE
tket-Converters
tket-Gate
tket-Graphs
tket-Mapping
tket-Ops
tket-OpType
tket-PauliGraph
tket-Predicates
tket-Routing
tket-TokenSwapping
tket-Transformations
tket-Utils)
target_link_libraries(passes PRIVATE ${TKET_EXTRA_LIBS})
Expand All @@ -153,6 +152,25 @@ if (WIN32)
target_link_libraries(passes PRIVATE bcrypt)
endif()


pybind11_add_module(architecture binders/architecture.cpp)
target_include_directories(architecture PRIVATE binders/include)
target_link_libraries(architecture PRIVATE
tket-Architecture
tket-Graphs
tket-Utils)
target_link_libraries(architecture PRIVATE ${TKET_EXTRA_LIBS})


pybind11_add_module(placement binders/placement.cpp)
target_include_directories(placement PRIVATE binders/include)
target_link_libraries(placement PRIVATE
tket-Placement
tket-Architecture
tket-Circuit
tket-Utils)
target_link_libraries(placement PRIVATE ${TKET_EXTRA_LIBS})

pybind11_add_module(program binders/program.cpp)
target_include_directories(program PRIVATE binders/include)
target_link_libraries(program PRIVATE
Expand Down
176 changes: 176 additions & 0 deletions pytket/binders/architecture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
// Copyright 2019-2022 Cambridge Quantum Computing
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "Architecture/Architecture.hpp"

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

#include "Utils/Json.hpp"
#include "binder_json.hpp"

namespace py = pybind11;
using json = nlohmann::json;

namespace tket {

PYBIND11_MODULE(architecture, m) {
py::class_<Architecture, std::shared_ptr<Architecture>>(
m, "Architecture",
"Class describing the connectivity of qubits on a general device.")
.def(
py::init([](const std::vector<std::pair<unsigned, unsigned>>
&connections) { return Architecture(connections); }),
"The constructor for an architecture with connectivity "
"between qubits.\n\n:param connections: A list of pairs "
"representing qubit indices that can perform two-qubit "
"operations",
py::arg("connections"))
.def(
py::init<const std::vector<std::pair<Node, Node>> &>(),
"The constructor for an architecture with connectivity "
"between qubits.\n\n:param connections: A list of pairs "
"representing Nodes that can perform two-qubit operations",
py::arg("connections"))
.def(
"__repr__",
[](const Architecture &arc) {
return "<tket::Architecture, nodes=" +
std::to_string(arc.n_nodes()) + ">";
})
.def(
"get_distance", &Architecture::get_distance,
"given two nodes in Architecture, "
"returns distance between them",
py::arg("node_0"), py::arg("node_1"))
.def(
"get_adjacent_nodes", &Architecture::get_neighbour_nodes,
"given a node, returns adjacent nodes in Architecture.",
py::arg("node"))
.def_property_readonly(
"nodes", &Architecture::get_all_nodes_vec,
"Returns all nodes of architecture as Node objects.")
.def_property_readonly(
"coupling", &Architecture::get_all_edges_vec,
"Returns the coupling map of the Architecture as "
"UnitIDs. ")
.def(
"to_dict", [](const Architecture &arch) { return json(arch); },
"Return a JSON serializable dict representation of "
"the Architecture.\n"
":return: dict containing nodes and links.")
.def_static(
"from_dict", [](const json &j) { return j.get<Architecture>(); },
"Construct Architecture instance from JSON serializable "
"dict representation of the Architecture.")
// as far as Python is concerned, Architectures are immutable
.def(
"__deepcopy__",
[](const Architecture &arc, py::dict = py::dict()) { return arc; })
.def(
"__repr__",
[](const Architecture &arc) {
return "<tket::Architecture, nodes=" +
std::to_string(arc.n_nodes()) + ">";
})
.def(py::self == py::self);
py::class_<SquareGrid, std::shared_ptr<SquareGrid>, Architecture>(
m, "SquareGrid",
"Architecture class for qubits arranged in a square lattice of "
"given number of rows and columns. Qubits are arranged with qubits "
"values increasing first along rows then along columns i.e. for a "
"3 x 3 grid:\n\n 0 1 2\n\n 3 4 5\n\n 6 7 8")
.def(
py::init<const unsigned, const unsigned>(),
"The constructor for a Square Grid architecture with some "
"undirected connectivity between qubits.\n\n:param n_rows: "
"The number of rows in the grid\n:param n_columns: The number "
"of columns in the grid",
py::arg("n_rows"), py::arg("n_columns"))
.def(
py::init<const unsigned, const unsigned, const unsigned>(),
"The constructor for a Square Grid architecture with some "
"undirected connectivity between qubits.\n\n:param n_rows: "
"The number of rows in the grid\n:param n_columns: The number "
"of columns in the grid\n:param n_layers: The number of "
"layers of grids",
py::arg("n_rows"), py::arg("n_columns"), py::arg("n_layers"))
.def(
"squind_to_qind",
[](const SquareGrid &self, const unsigned row, const unsigned col) {
return self.squind_to_qind(row, col);
},
"Converts a (row,column) index for a square grid to a "
"single "
"qubit index\n\n:param row: The given row index\n:param "
"column: The given column index\n:return: the "
"corresponding "
"global qubit index",
py::arg("row"), py::arg("column"))
.def(
"qind_to_squind", &SquareGrid::qind_to_squind,
"Converts a single qubit index to a (row,column) index for a "
"square grid.\n\n:param index: The global qubit "
"index\n:return: the corresponding grid index as a pair "
"(row,column)",
py::arg("index"))
// as far as Python is concerned, Architectures are immutable
.def(
"__deepcopy__",
[](const SquareGrid &arc, py::dict = py::dict()) { return arc; })
.def("__repr__", [](const SquareGrid &arc) {
return "<tket::SquareGrid, rows=" + std::to_string(arc.get_rows()) +
", columns=" + std::to_string(arc.get_columns()) +
", layers=" + std::to_string(arc.get_layers()) + ">";
});
py::class_<RingArch, std::shared_ptr<RingArch>, Architecture>(
m, "RingArch",
"Architecture class for number of qubits arranged in a ring.")
.def(
py::init<const unsigned>(),
"The constructor for a RingArchitecture with some undirected "
"connectivity between qubits.\n\n:param number of qubits",
py::arg("nodes"))
.def("__repr__", [](const RingArch &arc) {
return "<tket::RingArch, nodes=" + std::to_string(arc.n_nodes()) + ">";
});
py::class_<FullyConnected>(
m, "FullyConnected",
"An architecture with full connectivity between qubits.")
.def(
py::init<unsigned>(),
"Construct a fully-connected architecture."
"\n\n:param n: number of qubits",
py::arg("n"))
.def(
"__repr__",
[](const FullyConnected &arc) {
return "<tket::FullyConnected, nodes=" +
std::to_string(arc.n_nodes()) + ">";
})
.def(py::self == py::self)
.def_property_readonly(
"nodes", &FullyConnected::get_all_nodes_vec,
"All nodes of the architecture as :py:class:`Node` objects.")
.def(
"to_dict", [](const FullyConnected &arch) { return json(arch); },
"JSON-serializable dict representation of the architecture."
"\n\n:return: dict containing nodes")
.def_static(
"from_dict", [](const json &j) { return j.get<FullyConnected>(); },
"Construct FullyConnected instance from dict representation.");
}
} // namespace tket
2 changes: 1 addition & 1 deletion pytket/binders/circuit/Circuit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "Circuit/Command.hpp"
#include "Gate/OpPtrFunctions.hpp"
#include "Gate/SymTable.hpp"
#include "Mapping/Verification.hpp"
#include "Ops/Op.hpp"
#include "Routing/Verification.hpp"
#include "Simulation/CircuitSimulator.hpp"
#include "UnitRegister.hpp"
#include "Utils/Json.hpp"
Expand Down
Loading

0 comments on commit 8b818fa

Please sign in to comment.