Skip to content

Commit

Permalink
Breaking: Improve Timing Graph (#61)
Browse files Browse the repository at this point in the history
* Move graphviz-dot format writer to own module

* Install dot_writer

* Breaking: revise graphviz dot generation API

* Update: represent instructions as rectangles in program graphviz dot format

* Fix: error in memory access dependencies

* Merge branch 'main' into feat/improve-dot-graphs

* Chore: add top-level crate docs with links

* Prefix instruction text with [index] in dotfile output

* Move graphviz dot utility behind a feature flag

* Chore: Test with --all-features in CI

* Fix: move graphviz-dot tests out to conditional module

* Chore: update test snapshots to include instruction index

Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
Co-authored-by: Steve Manuel <nilslice@gmail.com>
Co-authored-by: Mark Skilbeck <mark.skilbeck@rigetti.com>
  • Loading branch information
4 people committed Jun 1, 2022
1 parent 0e942ba commit e10749c
Show file tree
Hide file tree
Showing 49 changed files with 1,214 additions and 961 deletions.
1 change: 1 addition & 0 deletions .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features

fmt:
name: Rustfmt
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target
node_modules
Cargo.lock

# JetBrains Editors
.idea/
93 changes: 50 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ keywords = ["Quil", "Quantum", "Rigetti"]
categories = ["parser-implementations", "science", "compilers", "emulators"]

[dependencies]
dot-writer = { version = "0.1.2", optional = true }
indexmap = "1.6.1"
lexical = "5.2.0"
nom = "6.1.0"
Expand All @@ -24,6 +25,9 @@ proptest = "1.0.0"
proptest-derive = "0.3.0"
criterion = { version = "0.3.5", features = ["html_reports"] }

[features]
graphviz-dot = ["dot-writer"]

[[bench]]
name = "parser"
harness = false
31 changes: 15 additions & 16 deletions src/expression.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
/**
* Copyright 2021 Rigetti 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.
**/
// Copyright 2021 Rigetti 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.

use num_complex::Complex64;
use std::collections::{hash_map::DefaultHasher, HashMap};
use std::f64::consts::PI;
Expand Down Expand Up @@ -799,7 +798,7 @@ mod tests {
fn complexes_are_parseable_as_expressions(value in arb_complex64()) {
let parsed = Expression::from_str(&format_complex(&value));
assert!(parsed.is_ok());
assert_eq!(Expression::Number(value), parsed.unwrap().simplify());
assert_eq!(Expression::Number(value), parsed.unwrap().into_simplified());
}

}
Expand Down
31 changes: 15 additions & 16 deletions src/instruction.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
/**
* Copyright 2021 Rigetti 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.
**/
// Copyright 2021 Rigetti 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.

use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt};

Expand Down Expand Up @@ -886,7 +885,7 @@ impl Instruction {
/// let mut instructions = program.to_instructions(true);
/// instructions.iter_mut().for_each(|inst| inst.apply_to_expressions(Expression::simplify));
///
/// assert_eq!(instructions[0].to_string(), String::from("SHIFT-PHASE 0 \"rf\" 4"))
/// assert_eq!(instructions[0].to_string(), String::from("SHIFT-PHASE 0 \"rf\" 4.0"))
///
/// ```
pub fn apply_to_expressions(&mut self, mut closure: impl FnMut(&mut Expression)) {
Expand Down
Loading

0 comments on commit e10749c

Please sign in to comment.