Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into refactor/parametrize_…
Browse files Browse the repository at this point in the history
…type
  • Loading branch information
acl-cqc committed Jul 2, 2024
2 parents eff0907 + 3e4ac18 commit 3477596
Show file tree
Hide file tree
Showing 64 changed files with 3,356 additions and 597 deletions.
9 changes: 9 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[default.extend-identifiers]
bck = "bck" # BiMap uses abbreviation
ser_it = "ser_it"
SerCollection = "SerCollection"
strat = "strat" # common abbreviation for strategy
# some arithmetic op names:
inot = "inot"
fle = "fle"
ine = "ine"
1 change: 1 addition & 0 deletions hugr-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog


## 0.1.1 (2024-06-07)

### Features
Expand Down
4 changes: 2 additions & 2 deletions hugr-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hugr-cli"
version = "0.1.1"
version = "0.1.2"
edition = { workspace = true }
rust-version = { workspace = true }
license = { workspace = true }
Expand All @@ -17,7 +17,7 @@ categories = ["compilers"]
clap = {workspace = true, features = ["derive"]}
clap-stdin.workspace = true
clap-verbosity-flag.workspace = true
hugr-core = { path = "../hugr-core", version = "0.2.0" }
hugr-core = { path = "../hugr-core", version = "0.3.0" }
serde_json.workspace = true
thiserror.workspace = true

Expand Down
27 changes: 27 additions & 0 deletions hugr-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 0.3.0 (2024-06-28)

### Bug Fixes

- SimpleReplacement panic on multiports ([#1191](https://github.com/CQCL/hugr/pull/1191))
- Add some validation for const nodes ([#1222](https://github.com/CQCL/hugr/pull/1222))
- Cfg not validating entry/exit types ([#1229](https://github.com/CQCL/hugr/pull/1229))
- `extract_hugr` not removing root node ports ([#1239](https://github.com/CQCL/hugr/pull/1239))

### Documentation

- Fix documentation of `ValidationError::ConstTypeError` ([#1227](https://github.com/CQCL/hugr/pull/1227))

### Features

- CircuitBuilder::add_constant ([#1168](https://github.com/CQCL/hugr/pull/1168))
- [**breaking**] Make the rewrite errors more useful ([#1174](https://github.com/CQCL/hugr/pull/1174))
- [**breaking**] Validate Extensions using hierarchy, ignore input_extensions, RIP inference ([#1142](https://github.com/CQCL/hugr/pull/1142))
- [**breaking**] Infer extension deltas for Case, Cfg, Conditional, DataflowBlock, Dfg, TailLoop ([#1195](https://github.com/CQCL/hugr/pull/1195))
- Helper functions for requesting inference, use with builder in tests ([#1219](https://github.com/CQCL/hugr/pull/1219))

### Refactor

- [**breaking**] Remove NodeType and input_extensions ([#1183](https://github.com/CQCL/hugr/pull/1183))
- [**breaking**] FunctionBuilder takes impl Into<PolyFuncType> ([#1220](https://github.com/CQCL/hugr/pull/1220))


## 0.2.0 (2024-06-07)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion hugr-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hugr-core"
version = "0.2.0"
version = "0.3.0"
edition = { workspace = true }
rust-version = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion hugr-core/src/extension/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ pub struct ConstExternalSymbol {
pub symbol: String,
/// The type of the value found at this symbol reference.
pub typ: Type,
/// Whether the value at the symbol referenence is constant or mutable.
/// Whether the value at the symbol reference is constant or mutable.
pub constant: bool,
}

Expand Down
4 changes: 4 additions & 0 deletions hugr-core/src/hugr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ mod test {
}

#[test]
#[cfg_attr(miri, ignore)] // Opening files is not supported in (isolated) miri
#[ignore = "issue 1225: In serialisation we do not distinguish between unknown CustomConst serialised value invalid but known CustomConst serialised values"]
fn hugr_validation_0() {
// https://github.com/CQCL/hugr/issues/1091 bad case
Expand All @@ -341,6 +342,7 @@ mod test {
}

#[test]
#[cfg_attr(miri, ignore)] // Opening files is not supported in (isolated) miri
fn hugr_validation_1() {
// https://github.com/CQCL/hugr/issues/1091 good case
let mut hugr: Hugr = serde_json::from_reader(BufReader::new(
Expand All @@ -351,6 +353,7 @@ mod test {
}

#[test]
#[cfg_attr(miri, ignore)] // Opening files is not supported in (isolated) miri
fn hugr_validation_2() {
// https://github.com/CQCL/hugr/issues/1185 bad case
let mut hugr: Hugr = serde_json::from_reader(BufReader::new(
Expand All @@ -364,6 +367,7 @@ mod test {
}

#[test]
#[cfg_attr(miri, ignore)] // Opening files is not supported in (isolated) miri
fn hugr_validation_3() {
// https://github.com/CQCL/hugr/issues/1185 good case
let mut hugr: Hugr = serde_json::from_reader(BufReader::new(
Expand Down
3 changes: 2 additions & 1 deletion hugr-core/src/hugr/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use itertools::{Itertools, MapInto};
use portgraph::render::{DotFormat, MermaidFormat};
use portgraph::{multiportgraph, LinkView, PortView};

use super::internal::HugrInternals;
use super::internal::{HugrInternals, HugrMutInternals};
use super::{
Hugr, HugrError, HugrMut, NodeMetadata, NodeMetadataMap, ValidationError, DEFAULT_OPTYPE,
};
Expand Down Expand Up @@ -511,6 +511,7 @@ pub trait ExtractHugr: HugrView + Sized {
let old_root = hugr.root();
let new_root = hugr.insert_from_view(old_root, &self).new_root;
hugr.set_root(new_root);
hugr.set_num_ports(new_root, 0, 0);
hugr.remove_node(old_root);
hugr
}
Expand Down
19 changes: 19 additions & 0 deletions hugr-core/src/hugr/views/descendants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ where

#[cfg(test)]
pub(super) mod test {
use rstest::rstest;

use crate::extension::PRELUDE_REGISTRY;
use crate::{
builder::{Container, Dataflow, DataflowSubContainer, HugrBuilder, ModuleBuilder},
type_row,
Expand Down Expand Up @@ -269,4 +272,20 @@ pub(super) mod test {

Ok(())
}

#[rstest]
fn extract_hugr() -> Result<(), Box<dyn std::error::Error>> {
let (hugr, def, _inner) = make_module_hgr()?;

let region: DescendantsGraph = DescendantsGraph::try_new(&hugr, def)?;
let extracted = region.extract_hugr();
extracted.validate(&PRELUDE_REGISTRY)?;

let region: DescendantsGraph = DescendantsGraph::try_new(&hugr, def)?;

assert_eq!(region.node_count(), extracted.node_count());
assert_eq!(region.root_type(), extracted.root_type());

Ok(())
}
}
7 changes: 4 additions & 3 deletions hugr-core/src/hugr/views/sibling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,13 @@ mod test {

#[rstest]
fn extract_hugr() -> Result<(), Box<dyn std::error::Error>> {
let (hugr, def, _inner) = make_module_hgr()?;
let (hugr, _def, inner) = make_module_hgr()?;

let region: SiblingGraph = SiblingGraph::try_new(&hugr, def)?;
let region: SiblingGraph = SiblingGraph::try_new(&hugr, inner)?;
let extracted = region.extract_hugr();
extracted.validate(&PRELUDE_REGISTRY)?;

let region: SiblingGraph = SiblingGraph::try_new(&hugr, def)?;
let region: SiblingGraph = SiblingGraph::try_new(&hugr, inner)?;

assert_eq!(region.node_count(), extracted.node_count());
assert_eq!(region.root_type(), extracted.root_type());
Expand Down
2 changes: 1 addition & 1 deletion hugr-core/src/hugr/views/sibling_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl SiblingSubgraph {
/// The in- and out-arity of the signature will match the
/// number of incoming and outgoing edges respectively. In particular, the
/// assumption is made that no two incoming edges have the same source
/// (no copy nodes at the input bounary).
/// (no copy nodes at the input boundary).
pub fn try_from_nodes(
nodes: impl Into<Vec<Node>>,
hugr: &impl HugrView,
Expand Down
2 changes: 1 addition & 1 deletion hugr-core/src/proptest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::Hugr;
/// [TypeParam], as well as several others, form a mutually recursive hierarchy.
///
/// The proptest [proptest::strategy::Strategy::prop_recursive] is inadequate to
/// generate values for these types. Instead, ther Arbitrary instances take a
/// generate values for these types. Instead, the Arbitrary instances take a
/// `RecursionDepth` as their (or part of their)
/// [proptest::arbitrary::Arbitrary::Parameters]. We then use that parameter to
/// generate children of that value. Usually we forward it unchanged, but in
Expand Down
10 changes: 5 additions & 5 deletions hugr-core/src/types/type_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl TypeParam {
}
}

/// Make a new `TypeParam::List` (an arbitrary-length homogenous list)
/// Make a new `TypeParam::List` (an arbitrary-length homogeneous list)
pub fn new_list(elem: impl Into<TypeParam>) -> Self {
Self::List {
param: Box::new(elem.into()),
Expand Down Expand Up @@ -491,15 +491,15 @@ mod test {
#[test]
fn type_arg_fits_param() {
let rowvar = TypeRV::new_row_var_use;
fn check(arg: impl Into<TypeArg>, parm: &TypeParam) -> Result<(), TypeArgError> {
check_type_arg(&arg.into(), parm)
fn check(arg: impl Into<TypeArg>, param: &TypeParam) -> Result<(), TypeArgError> {
check_type_arg(&arg.into(), param)
}
fn check_seq<T: Clone + Into<TypeArg>>(
args: &[T],
parm: &TypeParam,
param: &TypeParam,
) -> Result<(), TypeArgError> {
let arg = args.iter().cloned().map_into().collect_vec().into();
check_type_arg(&arg, parm)
check_type_arg(&arg, param)
}
// Simple cases: a TypeArg::Type is a TypeParam::Type but singleton sequences are lists
check(USIZE_T, &TypeBound::Eq.into()).unwrap();
Expand Down
8 changes: 8 additions & 0 deletions hugr-passes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.3.0 (2024-06-28)

### Features

- [**breaking**] Validate Extensions using hierarchy, ignore input_extensions, RIP inference ([#1142](https://github.com/CQCL/hugr/pull/1142))
- Helper functions for requesting inference, use with builder in tests ([#1219](https://github.com/CQCL/hugr/pull/1219))


## 0.2.0 (2024-06-07)

### Features
Expand Down
4 changes: 2 additions & 2 deletions hugr-passes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hugr-passes"
version = "0.2.0"
version = "0.3.0"
edition = { workspace = true }
rust-version = { workspace = true }
license = { workspace = true }
Expand All @@ -13,7 +13,7 @@ keywords = ["Quantum", "Quantinuum"]
categories = ["compilers"]

[dependencies]
hugr-core = { path = "../hugr-core", version = "0.2.0" }
hugr-core = { path = "../hugr-core", version = "0.3.0" }
itertools = { workspace = true }
lazy_static = { workspace = true }
paste = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion hugr-passes/src/const_fold/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ fn orphan_output() {
// x2 := or(x0,x1)
// output x2 == true;
//
// We arange things so that the `or` folds away first, leaving the not
// We arrange things so that the `or` folds away first, leaving the not
// with no outputs.
use hugr_core::ops::handle::NodeHandle;

Expand Down
1 change: 1 addition & 0 deletions hugr-py/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
Binary file added hugr-py/docs/_static/Quantinuum_logo_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hugr-py/docs/_static/Quantinuum_logo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions hugr-py/docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.wy-side-nav-search,
.wy-nav-top {
background: #5A46BE;
}

.wy-grid-for-nav,
.wy-body-for-nav,
.wy-nav-side,
.wy-side-scroll,
.wy-menu,
.wy-menu-vertical {
background-color: #FFFFFF;
}

.wy-menu-vertical a:hover {
background-color: #d9d9d9;
}

.btn-link:visited,
.btn-link,
a:visited,
.a.reference.external,
.a.reference.internal,
.wy-menu-vertical a,
.wy-menu-vertical li,
.wy-menu-vertical ul,
.span.pre,
.sig-param,
.std.std-ref,


html[data-theme=light] {
--pst-color-inline-code: rgb(199, 37, 78) !important;
}

.sig-name {
font-size: 1.25rem;
}
3 changes: 3 additions & 0 deletions hugr-py/docs/api-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_autosummary
_build
generated
5 changes: 5 additions & 0 deletions hugr-py/docs/api-docs/_templates/autosummary/base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. auto{{ objtype }}:: {{ objname }}
37 changes: 37 additions & 0 deletions hugr-py/docs/api-docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
..
Custom class template to make sphinx-autosummary list the full API doc after
the summary. See https://github.com/sphinx-doc/sphinx/issues/7912
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:
:inherited-members:

{% block methods %}
{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
:nosignatures:
{% for item in methods %}
{%- if not item.startswith('_') %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
Loading

0 comments on commit 3477596

Please sign in to comment.