From 3bcd4ccc74da07ad9147aed80ab72642a4f0c9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Tue, 1 Oct 2024 08:31:48 +0100 Subject: [PATCH] chore: Update rust dependencies and dependabot config (#68) --- .github/dependabot.yml | 38 +++++++- Cargo.lock | 192 ++++++++++++++++++++++++--------------- Cargo.toml | 19 ++-- pybindings/Cargo.toml | 2 +- pybindings/src/scalar.rs | 3 +- quizx/Cargo.toml | 3 +- quizx/src/graph.rs | 17 +--- quizx/src/json.rs | 12 ++- quizx/src/tensor.rs | 15 ++- 9 files changed, 190 insertions(+), 111 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 95cbee9..9345edf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,7 +8,41 @@ updates: - package-ecosystem: "cargo" # See documentation for possible values directory: "/" # Location of package manifests schedule: - interval: "weekly" + interval: "monthly" commit-message: # Use a conventional commit tag - prefix: "chore(deps)" + prefix: "chore(deps-rs)" + groups: + dev: + dependency-type: "development" + update-types: ["patch", "minor"] + patch: + update-types: ["patch"] + minor: + update-types: ["minor"] + # Major updates still generate individual PRs + + - package-ecosystem: "pip" + directory: "/" # Location of package manifests + schedule: + interval: "monthly" + commit-message: + # Use a conventional commit tag + prefix: "chore(deps-py)" + groups: + dev: + dependency-type: "development" + update-types: ["patch", "minor"] + patch: + update-types: ["patch"] + minor: + update-types: ["minor"] + # Major updates still generate individual PRs + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + commit-message: + # Use a conventional commit tag + prefix: "ci(deps)" diff --git a/Cargo.lock b/Cargo.lock index 7f326c4..a243cfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,12 +68,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -107,15 +101,23 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "derive_more" -version = "0.99.18" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ - "convert_case", "proc-macro2", "quote", - "rustc_version", - "syn 2.0.60", + "syn 2.0.79", + "unicode-xid", ] [[package]] @@ -234,7 +236,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.79", ] [[package]] @@ -298,9 +300,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -310,9 +312,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown", @@ -346,9 +348,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -478,14 +480,16 @@ dependencies = [ [[package]] name = "ndarray" -version = "0.15.6" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" +checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" dependencies = [ "matrixmultiply", "num-complex", "num-integer", "num-traits", + "portable-atomic", + "portable-atomic-util", "rawpointer", "rayon", ] @@ -651,6 +655,15 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +[[package]] +name = "portable-atomic-util" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcdd8420072e66d54a407b3316991fe946ce3ab1083a7f575b2463866624704d" +dependencies = [ + "portable-atomic", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -663,27 +676,36 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.21.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" +checksum = "15ee168e30649f7f234c3d49ef5a7a6cbf5134289bc46c29ff3155fa3221c225" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", "num-complex", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -693,9 +715,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +checksum = "e61cef80755fe9e46bb8a0b8f20752ca7676dcc07a5277d8b7768c6172e529b3" dependencies = [ "once_cell", "target-lexicon", @@ -703,9 +725,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" +checksum = "67ce096073ec5405f5ee2b8b31f03a68e02aa10d5d4f565eca04acc41931fa1c" dependencies = [ "libc", "pyo3-build-config", @@ -713,27 +735,27 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" +checksum = "2440c6d12bc8f3ae39f1e775266fa5122fd0c8891ce7520fa6048e683ad3de28" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.60", + "syn 2.0.79", ] [[package]] name = "pyo3-macros-backend" -version = "0.21.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" +checksum = "1be962f0e06da8f8465729ea2cb71a416d2257dff56cbe40a70d3e62a93ae5d1" dependencies = [ "heck", "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.60", + "syn 2.0.79", ] [[package]] @@ -742,7 +764,7 @@ version = "0.1.0" dependencies = [ "approx", "derive_more", - "itertools 0.12.1", + "itertools 0.13.0", "ndarray", "num", "openqasm", @@ -753,7 +775,6 @@ dependencies = [ "rustc-hash", "serde", "serde_json", - "thiserror", ] [[package]] @@ -770,9 +791,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -855,25 +876,25 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.8.3", + "regex-syntax 0.8.5", ] [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax 0.8.5", ] [[package]] @@ -884,9 +905,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "relative-path" @@ -896,9 +917,9 @@ checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" [[package]] name = "rstest" -version = "0.19.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5316d2a1479eeef1ea21e7f9ddc67c191d497abc8fc3ba2467857abbb68330" +checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035" dependencies = [ "futures", "futures-timer", @@ -908,32 +929,33 @@ dependencies = [ [[package]] name = "rstest_macros" -version = "0.19.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04a9df72cc1f67020b0d63ad9bfe4a323e459ea7eb68e03bd9824db49f9a4c25" +checksum = "825ea780781b15345a146be27eaefb05085e337e869bff01b4306a4fd4a9ad5a" dependencies = [ "cfg-if", "glob", + "proc-macro-crate", "proc-macro2", "quote", "regex", "relative-path", "rustc_version", - "syn 2.0.60", + "syn 2.0.79", "unicode-ident", ] [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] @@ -964,29 +986,29 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -1041,9 +1063,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -1069,22 +1091,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.79", ] [[package]] @@ -1096,11 +1118,28 @@ dependencies = [ "crunchy", ] +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-xid" @@ -1214,3 +1253,12 @@ name = "windows_x86_64_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] diff --git a/Cargo.toml b/Cargo.toml index c21244a..a3fe26e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,19 +7,18 @@ default-members = ["quizx"] quizx = { path = "./quizx" } num = "0.4.3" approx = "0.5.1" -itertools = "0.12.1" -ndarray = "0.15.6" +itertools = "0.13.0" +ndarray = "0.16.1" openqasm = "0.1.2" -pyo3 = { version = "0.21" } +pyo3 = { version = "0.22.3" } rand = "0.8.3" rayon = "1.5.0" -regex = "1.10.6" -rustc-hash = "1.1.0" -derive_more = "0.99.18" -rstest = "0.19.0" -serde = "1.0.204" -serde_json = "1.0.122" -thiserror = "1.0.63" +regex = "1.11.0" +rustc-hash = "2.0.0" +derive_more = "1.0.0" +rstest = "0.23.0" +serde = "1.0.210" +serde_json = "1.0.128" [workspace.package] version = "0.1.0" diff --git a/pybindings/Cargo.toml b/pybindings/Cargo.toml index 0f73667..31b8ea5 100644 --- a/pybindings/Cargo.toml +++ b/pybindings/Cargo.toml @@ -15,6 +15,6 @@ crate-type = ["cdylib"] quizx = { workspace = true } num = { workspace = true } pyo3 = { workspace = true, features = ["extension-module", "num-complex"] } -derive_more = { workspace = true } +derive_more = { workspace = true, features = ["add", "mul"] } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } diff --git a/pybindings/src/scalar.rs b/pybindings/src/scalar.rs index 4e79ec2..544bd5d 100644 --- a/pybindings/src/scalar.rs +++ b/pybindings/src/scalar.rs @@ -16,6 +16,7 @@ //! Python-side scalar definition. +use derive_more::{Add, Mul}; use num::complex::Complex; use num::rational::Rational64; use num::{FromPrimitive, One, Zero}; @@ -38,7 +39,7 @@ use quizx::scalar::{FromPhase, ScalarN, Sqrt2}; /// The float representation of a scalar is given as a 64-bit /// floating point complex number. #[pyclass] -#[derive(Debug, Clone, derive_more::Add, derive_more::Mul, PartialEq)] +#[derive(Debug, Clone, Add, Mul, PartialEq)] pub struct Scalar { /// Rust representation of the scalar. /// diff --git a/quizx/Cargo.toml b/quizx/Cargo.toml index 260663e..27d6c0a 100644 --- a/quizx/Cargo.toml +++ b/quizx/Cargo.toml @@ -17,11 +17,10 @@ regex = { workspace = true } rand = { workspace = true } itertools = { workspace = true } openqasm = { workspace = true } -thiserror = { workspace = true } rstest = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } -derive_more = { workspace = true } +derive_more = { workspace = true, features = ["display", "error", "from"] } [dev-dependencies] rstest = { workspace = true } diff --git a/quizx/src/graph.rs b/quizx/src/graph.rs index b05ec77..6211c5c 100644 --- a/quizx/src/graph.rs +++ b/quizx/src/graph.rs @@ -16,6 +16,7 @@ use crate::phase::Phase; use crate::scalar::*; +use derive_more::{Display, From}; use num::rational::Rational64; use rustc_hash::{FxHashMap, FxHashSet}; use serde::{Deserialize, Serialize}; @@ -119,20 +120,8 @@ impl BasisElem { } /// Coordinates for rendering a node. -#[derive( - derive_more::Display, - Debug, - Default, - Clone, - Copy, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - derive_more::From, -)] -#[display(fmt = "({},{})", x, y)] +#[derive(Display, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, From)] +#[display("({},{})", x, y)] pub struct Coord { pub x: i32, pub y: i32, diff --git a/quizx/src/json.rs b/quizx/src/json.rs index 3a9f8ad..15a112f 100644 --- a/quizx/src/json.rs +++ b/quizx/src/json.rs @@ -54,6 +54,7 @@ pub use phase::PhaseOptions; use crate::graph::VType; use crate::hash_graph::{EType, GraphLike}; +use derive_more::{Display, Error, From}; use serde::{de, Deserialize, Serialize}; use std::collections::HashMap; use std::path::Path; @@ -331,17 +332,18 @@ where } /// An error that can occur when decoding a json graph. -#[derive(Debug, thiserror::Error)] +#[derive(Debug, Display, Error, From)] +#[non_exhaustive] pub enum JsonError { /// Found an invalid phase value. - #[error("Got an invalid phase value {phase}")] + #[display("Got an invalid phase value {phase}")] InvalidPhase { phase: String }, /// Found an invalid phase value in a node definition. - #[error("Got an invalid phase value {phase} for node {name}")] + #[display("Got an invalid phase value {phase} for node {name}")] InvalidNodePhase { name: String, phase: String }, /// Some other serde error. - #[error(transparent)] - SerdeError(#[from] serde_json::Error), + #[from] + SerdeError(serde_json::Error), } #[cfg(test)] diff --git a/quizx/src/tensor.rs b/quizx/src/tensor.rs index f84eb86..32730bd 100644 --- a/quizx/src/tensor.rs +++ b/quizx/src/tensor.rs @@ -240,7 +240,7 @@ impl QubitOps for Tensor { shape[q] = 2; } let del: Tensor = Tensor::delta(qs.len()) - .into_shape(shape) + .into_shape_with_order(shape) .expect("Bad indices for delta_at"); *self *= &del; } @@ -258,7 +258,7 @@ impl QubitOps for Tensor { A::one() } }) - .into_shape(shape) + .into_shape_with_order(shape) .expect("Bad indices for cphase_at"); *self *= &cp; } @@ -289,9 +289,16 @@ impl QubitOps for Tensor { .map(|i| if i < d1 - n { 1 } else { 2 }) .collect(); - let t1 = self.into_shared().reshape(shape1); + let t1 = self + .into_shared() + .into_shape_with_order(shape1) + .expect("Invalid tensor reshape"); let t1p = t1.broadcast(vec![2; d1 + n]).unwrap(); - let t2 = other.clone().into_shared().reshape(shape2); + let t2 = other + .clone() + .into_shared() + .into_shape_with_order(shape2) + .expect("Invalid tensor reshape"); let mut t3 = &t1p * &t2; for _ in 0..n { t3 = t3.sum_axis(Axis(d1 - n));