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

Throw exceptions. #1274

Merged
merged 5 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def package(self):
cmake.install()

def requirements(self):
self.requires("tket/1.2.95@tket/stable")
self.requires("tket/1.2.96@tket/stable")
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tkassert/0.3.4@tket/stable")
Expand Down
32 changes: 32 additions & 0 deletions pytket/tests/circuit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,38 @@ def test_add_circbox_with_mixed_registers() -> None:
)


def test_deserialization_from_junk() -> None:
# https://github.com/CQCL/tket/issues/1243
with pytest.raises(RuntimeError):
Circuit.from_dict(
{
"phase": "1.9999999999999998",
"qubits": [("q", (20057, 24021, 112, 9628, 79))],
"bits": [("c", (128, 3, 384))],
"implicit_permutation": [
(("c", (1174437931,)), ("q", (0,))),
(("c", (25199232,)), ("c", (29697, 126852352))),
],
"commands": [
{
"op": {
"type": "CCX",
"conditional": {
"op": {"type": "CCX"},
"width": 3,
"value": 2,
},
},
"args": [],
}
],
"name": "ú\x19",
"created_qubits": [("c", (0,))],
"discarded_qubits": [("c", (0,))],
}
)


if __name__ == "__main__":
test_circuit_gen()
test_symbolic_ops()
Expand Down
2 changes: 1 addition & 1 deletion tket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class TketConan(ConanFile):
name = "tket"
version = "1.2.95"
version = "1.2.96"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
4 changes: 2 additions & 2 deletions tket/src/Circuit/CommandJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void to_json(nlohmann::json& j, const Command& com) {
const unit_vector_t& args = com.get_args();

if (sig.size() != args.size()) {
JsonError("Number of args does not match signature of op.");
throw JsonError("Number of args does not match signature of op.");
}

nlohmann::json j_args;
Expand Down Expand Up @@ -72,7 +72,7 @@ void from_json(const nlohmann::json& j, Command& com) {

const nlohmann::json& j_args = j.at("args");
if (sig.size() != j_args.size()) {
JsonError("Number of args does not match signature of op.");
throw JsonError("Number of args does not match signature of op.");
}
unit_vector_t args;
for (std::size_t i = 0; i < sig.size(); i++) {
Expand Down
Loading