+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/quil-py/out/search.js b/quil-py/out/search.js
new file mode 100644
index 00000000..9575c96b
--- /dev/null
+++ b/quil-py/out/search.js
@@ -0,0 +1,46 @@
+window.pdocSearch = (function(){
+/** elasticlunr - http://weixsong.github.io * Copyright (C) 2017 Oliver Nightingale * Copyright (C) 2017 Wei Song * MIT Licensed */!function(){function e(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.9.5",lunr=t,t.utils={},t.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),t.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},t.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!==n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},t.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},t.EventEmitter.prototype.hasHandler=function(e){return e in this.events},t.tokenizer=function(e){if(!arguments.length||null===e||void 0===e)return[];if(Array.isArray(e)){var n=e.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(e){return t.utils.toString(e).toLowerCase()});var i=[];return n.forEach(function(e){var n=e.split(t.tokenizer.seperator);i=i.concat(n)},this),i}return e.toString().trim().toLowerCase().split(t.tokenizer.seperator)},t.tokenizer.defaultSeperator=/[\s\-]+/,t.tokenizer.seperator=t.tokenizer.defaultSeperator,t.tokenizer.setSeperator=function(e){null!==e&&void 0!==e&&"object"==typeof e&&(t.tokenizer.seperator=e)},t.tokenizer.resetSeperator=function(){t.tokenizer.seperator=t.tokenizer.defaultSeperator},t.tokenizer.getSeperator=function(){return t.tokenizer.seperator},t.Pipeline=function(){this._queue=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in t.Pipeline.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[n]=e},t.Pipeline.getRegisteredFunction=function(e){return e in t.Pipeline.registeredFunctions!=!0?null:t.Pipeline.registeredFunctions[e]},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.getRegisteredFunction(e);if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},t.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},t.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var i=null;null!=n&&(i=JSON.stringify(n));for(var o=new t.Configuration(i,this.getFields()).get(),r={},s=Object.keys(e),u=0;u0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();o
+
+
+
+
+
+
\ No newline at end of file
diff --git a/quil-py/quil/__init__.py b/quil-py/quil/__init__.py
index f6002046..57fb3fa6 100644
--- a/quil-py/quil/__init__.py
+++ b/quil-py/quil/__init__.py
@@ -1 +1,6 @@
+"""
+The `quil` package provides tools for constructing, manipulating, parsing, and printing [Quil](https://github.com/quil-lang/quil) programs.
+
+⚠️ This package is still in early development and breaking changes should be expected between minor versions.
+"""
from .quil import *
diff --git a/quil-py/quil/expression/__init__.py b/quil-py/quil/expression/__init__.py
new file mode 100644
index 00000000..720522e6
--- /dev/null
+++ b/quil-py/quil/expression/__init__.py
@@ -0,0 +1 @@
+from quil.expression import *
diff --git a/quil-py/quil/expression/__init__.pyi b/quil-py/quil/expression/__init__.pyi
index 800c8f38..73b6ad4d 100644
--- a/quil-py/quil/expression/__init__.pyi
+++ b/quil-py/quil/expression/__init__.pyi
@@ -1,3 +1,6 @@
+"""
+The ``expression`` module contains classes for representing Quil expressions.
+"""
from enum import Enum
from typing import Dict, final, Sequence, Optional, Union
@@ -14,30 +17,30 @@ class Expression:
"""
A Quil expression.
- Variants:
- ``address``: An address defined by a ``MemoryReference``.
- ``function_call``: A ``FunctionCall``.
- ``infix``: An ``InfixExpression``.
- ``number``: A number defined as a ``complex``.
- ``pi``: The constant `pi`. No inner data.
- ``prefix``: A ``PrefixExpression``.
- ``variable``: A variable defined as a ``str``.
+ # Variants:
+ - ``address``: An address defined by a `quil.instructions.MemoryReference`.
+ - ``function_call``: A `FunctionCallExpression`.
+ - ``infix``: An `InfixExpression`.
+ - ``number``: A number defined as a `complex`.
+ - ``pi``: The constant ``pi``. No inner data.
+ - ``prefix``: A `PrefixExpression`.
+ - ``variable``: A variable defined as a `str`.
As seen above, some variants contain inner data that fully specify the expression.
For example, the ``number`` variant contains an ``int``. This is in contrast to variants like
``pi`` that have no inner data because they require none to fully specify the expression.
This difference is important for determining which methods are available for each variant.
- Methods (for each variant):
- ``is_*``: Returns ``True`` if the expression is that variant, ``False`` otherwise.
+ Methods (for every variant):
+ - ``is_*``: Returns ``True`` if the expression is that variant, ``False`` otherwise.
- If the variant has inner data:
- ``as_*``: returns the inner data if it is the given variant, ``None`` otherwise.
- ``to_*``: returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- ``from_*``: Creates a new ``Expression`` of the given variant from an instance of the inner type.
+ If the variant has inner data:
+ - ``as_*``: returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``Expression`` of the given variant from an instance of the inner type.
- If the variant doesn't have inner data (e.g. ``pi``)
- ``new_*``: Creates a new ``Expression`` for the variant
+ If the variant doesn't have inner data (e.g. ``pi``)
+ - ``new_*``: Creates a new ``Expression`` for the variant
"""
def inner(
@@ -113,7 +116,7 @@ class Expression:
...
def to_real(self) -> float:
"""
- If this is a number with imaginary part "equal to" zero (of _small_ absolute value), return
+ If this is a number with imaginary part "equal to" zero (of small absolute value), return
that number. Otherwise, raises an ``EvaluationError``
"""
def __add__(self, other: "Expression") -> "Expression": ...
@@ -134,6 +137,9 @@ class Expression:
"""
class FunctionCallExpression:
+ """
+ A Quil function call.
+ """
@staticmethod
def __new__(cls, function: ExpressionFunction, expression: Expression) -> "FunctionCallExpression": ...
@property
@@ -146,6 +152,9 @@ class FunctionCallExpression:
def expression(self, expression: Expression): ...
class InfixExpression:
+ """
+ A Quil infix expression.
+ """
@staticmethod
def __new__(cls, left: Expression, operator: InfixOperator, right: Expression): ...
@property
@@ -162,6 +171,9 @@ class InfixExpression:
def right(self, expression: Expression): ...
class PrefixExpression:
+ """
+ A Quil prefix expression.
+ """
@staticmethod
def __new__(cls, operator: PrefixOperator, expression: Expression): ...
@property
@@ -175,6 +187,9 @@ class PrefixExpression:
@final
class ExpressionFunction(Enum):
+ """
+ An enum representing a Quil function that can be applied to an expression.
+ """
Cis = "CIS"
Cosine = "COSINE"
Exponent = "EXPONENT"
@@ -183,11 +198,17 @@ class ExpressionFunction(Enum):
@final
class PrefixOperator(Enum):
+ """
+ An enum that represents the operators supported on a prefix expression.
+ """
Plus = "PLUS"
Minus = "MINUS"
@final
class InfixOperator(Enum):
+ """
+ An enum that represents the operators supported on an infix expression.
+ """
Caret = "CARET"
Plus = "PLUS"
Minus = "MINUS"
diff --git a/quil-py/quil/instructions/__init__.py b/quil-py/quil/instructions/__init__.py
new file mode 100644
index 00000000..3afbd6db
--- /dev/null
+++ b/quil-py/quil/instructions/__init__.py
@@ -0,0 +1,4 @@
+"""
+The `quil.instructions` module contains classes for representing Quil instructions.
+"""
+from quil.instructions import *
diff --git a/quil-py/quil/instructions/__init__.pyi b/quil-py/quil/instructions/__init__.pyi
index 8d0c79d1..a16a90ba 100644
--- a/quil-py/quil/instructions/__init__.pyi
+++ b/quil-py/quil/instructions/__init__.pyi
@@ -11,49 +11,49 @@ class Instruction:
"""
A Quil instruction. Each variant corresponds to a possible type of Quil instruction.
- Variants:
- ``arithmetic``: An arithmetic expression defined by an ``Arithmetic``.
- ``binary_logic``: A binary expression defined by a ``BinaryLogic``.
- ``calibration_definition``: Corresponds to a `DEFCAL` instruction (not `DEFCAL MEASURE`)
- defined by a ``Calibration``.
- ``capture``: Corresponds to a `CAPTURE` instruction
- ``calibration``: Corresponds to a `DEFCAL` instruction.
- ``circuit_definition``: Corresponds to a `DEFCIRCUIT` instruction and its body,
- defined by a ``CircuitDefinition``.
- ``convert``: Corresponds to a `CONVERT` instruction.
- ``comparison``: Corresponds to a comparison of two `MemoryReference`s
- ``declaration``: Corresponds to a `DECLARE` statement defined by a ``Declaration``.
- ``delay``: Corresponds to a `DELAY` instruction.
- ``exchange``: Corresponds to an `EXCHANGE` instruction.
- ``fence``: Corresponds to a `FENCE` instruction.
- ``frame_definition``: Corresponds to a `DEFFRAME` statement, defined by a ``FrameDefinition``.
- ``gate``: A Quil quantum gate instruction defined by a ``Gate``.
- ``gate_definition``: A quantum gate definition defined by a ``GateDefinition``.
- ``halt``: Corresponds to the `HALT` instruction. No inner data.
- ``include``: Corresponds to an `INCLUDE` directive.
- ``jump``: Corresponds to a `JUMP` instruction
- ``jump_when``: Corresponds to a `JUMP-WHEN` instruction
- ``jump_unless``: Corresponds to a `JUMP-UNLESS` instruction
- ``label``: Corresponds to a `LABEL`
- ``load``: Corresponds to a `LOAD` instruction.
- ``measure_calibration_definition``: Corresponds to a `DEFCAL MEASURE` instruction. Defined by a ``MeasureCalibrationDefinition``.
- ``measurement``: Corresponds to a `MEASURE` instruction.
- ``move``: Corresponds to a `MOVE` instruction.
- ``nop``: Corresponds to the `NOP` instruction. No inner data.
- ``pragma``: Corresponds to a `PRAGMA` instruction.
- ``pulse``: Corresponds to a `PULSE` instruction.
- ``raw_capture``: Corresponds to a `RAW-CAPTURE` instruction.
- ``reset``: Corresponds to a `RESET` instruction.
- ``set_frequency``: Corresponds to a `SET-FREQUENCY` instruction.
- ``set_phase``: Corresponds to a `SET-PHASE` instruction.
- ``set_scale``: Corresponds to a `SET-SCALE` instruction.
- ``shift_frequency``: Corresponds to a `SHIFT-FREQUENCY` instruction.
- ``shift_phase``: Corresponds to a `SHIFT-PHASE` instruction.
- ``store``: Corresponds to a `STORE` instruction.
- ``swap_phases``: Corresponds to a `SWAP-PHASES` instruction.
- ``unary_logic``: Corresponds to a unary operation on a `MemoryReference`.
- ``waveform_definition``: A waveform defined by a ``WaveformDefinition``.
- ``wait``: Corresponds to a `WAIT` instruction. No inner data.
+ # Variants:
+ - ``arithmetic``: An arithmetic expression defined by an ``Arithmetic``.
+ - ``binary_logic``: A binary expression defined by a ``BinaryLogic``.
+ - ``calibration_definition``: Corresponds to a `DEFCAL` instruction (not `DEFCAL MEASURE`)
+ - defined by a ``Calibration``.
+ - ``capture``: Corresponds to a `CAPTURE` instruction
+ - ``calibration``: Corresponds to a `DEFCAL` instruction.
+ - ``circuit_definition``: Corresponds to a `DEFCIRCUIT` instruction and its body,
+ - defined by a ``CircuitDefinition``.
+ - ``convert``: Corresponds to a `CONVERT` instruction.
+ - ``comparison``: Corresponds to a comparison of two `MemoryReference`s
+ - ``declaration``: Corresponds to a `DECLARE` statement defined by a ``Declaration``.
+ - ``delay``: Corresponds to a `DELAY` instruction.
+ - ``exchange``: Corresponds to an `EXCHANGE` instruction.
+ - ``fence``: Corresponds to a `FENCE` instruction.
+ - ``frame_definition``: Corresponds to a `DEFFRAME` statement, defined by a ``FrameDefinition``.
+ - ``gate``: A Quil quantum gate instruction defined by a ``Gate``.
+ - ``gate_definition``: A quantum gate definition defined by a ``GateDefinition``.
+ - ``halt``: Corresponds to the `HALT` instruction. No inner data.
+ - ``include``: Corresponds to an `INCLUDE` directive.
+ - ``jump``: Corresponds to a `JUMP` instruction
+ - ``jump_when``: Corresponds to a `JUMP-WHEN` instruction
+ - ``jump_unless``: Corresponds to a `JUMP-UNLESS` instruction
+ - ``label``: Corresponds to a `LABEL`
+ - ``load``: Corresponds to a `LOAD` instruction.
+ - ``measure_calibration_definition``: Corresponds to a `DEFCAL MEASURE` instruction. Defined by a ``MeasureCalibrationDefinition``.
+ - ``measurement``: Corresponds to a `MEASURE` instruction.
+ - ``move``: Corresponds to a `MOVE` instruction.
+ - ``nop``: Corresponds to the `NOP` instruction. No inner data.
+ - ``pragma``: Corresponds to a `PRAGMA` instruction.
+ - ``pulse``: Corresponds to a `PULSE` instruction.
+ - ``raw_capture``: Corresponds to a `RAW-CAPTURE` instruction.
+ - ``reset``: Corresponds to a `RESET` instruction.
+ - ``set_frequency``: Corresponds to a `SET-FREQUENCY` instruction.
+ - ``set_phase``: Corresponds to a `SET-PHASE` instruction.
+ - ``set_scale``: Corresponds to a `SET-SCALE` instruction.
+ - ``shift_frequency``: Corresponds to a `SHIFT-FREQUENCY` instruction.
+ - ``shift_phase``: Corresponds to a `SHIFT-PHASE` instruction.
+ - ``store``: Corresponds to a `STORE` instruction.
+ - ``swap_phases``: Corresponds to a `SWAP-PHASES` instruction.
+ - ``unary_logic``: Corresponds to a unary operation on a `MemoryReference`.
+ - ``waveform_definition``: A waveform defined by a ``WaveformDefinition``.
+ - ``wait``: Corresponds to a `WAIT` instruction. No inner data.
As seen above, some variants contain inner data that fully specify the instruction.
For example, the ``gate`` variant contains a ``Gate``. This is in contrast to variants like
@@ -61,15 +61,15 @@ class Instruction:
This difference is important for determining which methods are available for each variant.
Methods (for each variant):
- ``is_*``: Returns ``True`` if the instruction is that variant, ``False`` otherwise.
+ - ``is_*``: Returns ``True`` if the instruction is that variant, ``False`` otherwise.
- If the variant has inner data (e.g. ``gate``):
- ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
- ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- ``from_*``: Creates a new ``Instruction`` of the given variant from an instance of the inner type.
+ If the variant has inner data (e.g. ``gate``):
+ - ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``Instruction`` of the given variant from an instance of the inner type.
- If the variant doesn't have inner data (e.g. ``halt``)
- ``new_*``: Creates a new ``Instruction`` for the variant.
+ If the variant doesn't have inner data (e.g. ``halt``)
+ - ``new_*``: Creates a new ``Instruction`` for the variant.
"""
def __new__(
@@ -382,16 +382,16 @@ class ArithmeticOperand:
"""
A Quil arithmetic operand.
- Variants:
- ``literal_integer``: An integer literal.
- ``literal_real``: A real numbered literal.
- ``memory_reference``: A Quil ``MemoryReference``.
+ # Variants:
+ - ``literal_integer``: An integer literal.
+ - ``literal_real``: A real numbered literal.
+ - ``memory_reference``: A Quil ``MemoryReference``.
Methods (for each variant):
- ``is_*``: Returns ``True`` if the operand is that variant, ``False`` otherwise.
- ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
- ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- ``from_*``: Creates a new ``ArithmeticOperand`` of the given variant from an instance of the inner type.
+ - ``is_*``: Returns ``True`` if the operand is that variant, ``False`` otherwise.
+ - ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``ArithmeticOperand`` of the given variant from an instance of the inner type.
"""
def inner(self) -> Union[int, float, MemoryReference]:
@@ -486,15 +486,15 @@ class BinaryOperand:
"""
A Quil binary operand.
- Variants:
- ``literal_integer``: An integer literal.
- ``memory_reference``: A Quil ``MemoryReference``.
+ # Variants:
+ - ``literal_integer``: An integer literal.
+ - ``memory_reference``: A Quil ``MemoryReference``.
Methods (for each variant):
- ``is_*``: Returns ``True`` if the operand is that variant, ``False`` otherwise.
- ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
- ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- ``from_*``: Creates a new ``BinaryOperand`` of the given variant from an instance of the inner type.
+ - ``is_*``: Returns ``True`` if the operand is that variant, ``False`` otherwise.
+ - ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``BinaryOperand`` of the given variant from an instance of the inner type.
"""
def inner(self) -> Union[int, MemoryReference]:
@@ -671,16 +671,16 @@ class ComparisonOperand:
"""
A Quil binary operand.
- Variants:
- ``literal_integer``: An integer literal.
- ``literal_real``: A floating point literal.
- ``memory_reference``: A Quil ``MemoryReference``.
+ # Variants:
+ - ``literal_integer``: An integer literal.
+ - ``literal_real``: A floating point literal.
+ - ``memory_reference``: A Quil ``MemoryReference``.
Methods (for each variant):
- ``is_*``: Returns ``True`` if the operand is that variant, ``False`` otherwise.
- ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
- ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- ``from_*``: Creates a new ``BinaryOperand`` of the given variant from an instance of the inner type.
+ - ``is_*``: Returns ``True`` if the operand is that variant, ``False`` otherwise.
+ - ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``BinaryOperand`` of the given variant from an instance of the inner type.
"""
def inner(self) -> Union[int, float, MemoryReference]:
@@ -1035,16 +1035,15 @@ class AttributeValue:
"""
A frame attribute value.
- Variants:
- ``string``: A string attribute containing a ``str``.
- ``expression``: An expression attribute containing an ``Expression``.
+ # Variants:
+ - ``string``: A string attribute containing a ``str``.
+ - ``expression``: An expression attribute containing an ``Expression``.
Methods (for each variant):
- ``is_*``: Returns ``True`` if the ``AttributeValue`` is that variant, ``False`` otherwise.
-
- ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
- ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- ``from_*``: Creates a new ``AttributeValue`` of the given variant from an instance of the inner type.
+ - ``is_*``: Returns ``True`` if the ``AttributeValue`` is that variant, ``False`` otherwise.
+ - ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``AttributeValue`` of the given variant from an instance of the inner type.
"""
def inner(self) -> Union[str, Expression]:
@@ -1530,15 +1529,15 @@ class GateSpecification:
"""
A specification for a gate definition.
- Variants:
- ``matrix``: A gate specificied by a matrix of ``Expression``s representing a unitary operation.
- ``permutation``: A gate specified by a vector of integers that defines a permutation.
+ # Variants:
+ - ``matrix``: A gate specificied by a matrix of ``Expression``s representing a unitary operation.
+ - ``permutation``: A gate specified by a vector of integers that defines a permutation.
Methods (for each variant):
- - is_*: Returns ``True`` if the inner type is of that variant.
- - as_*: Returns the inner data if it is the given variant, ``None`` otherwise.
- - to_*: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- - from_*: Creates a new ``GateSpecification`` using an instance of the inner type for the variant.
+ - is_*: Returns ``True`` if the inner type is of that variant.
+ - as_*: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - to_*: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - from_*: Creates a new ``GateSpecification`` using an instance of the inner type for the variant.
"""
def inner(self) -> Union[List[List[Expression]], List[int], PauliSum]:
@@ -1613,15 +1612,15 @@ class Qubit:
"""
A Qubit
- Variants:
- ``fixed``: A qubit represented as a fixed integer index.
- ``variable``: A qubit represented by a name.
+ # Variants:
+ - ``fixed``: A qubit represented as a fixed integer index.
+ - ``variable``: A qubit represented by a name.
Methods (for each variant):
- - is_*: Returns ``True`` if the inner type is of that variant.
- - as_*: Returns the inner data if it is the given variant, ``None`` otherwise.
- - to_*: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- - from_*: Creates a new ``Qubit`` using an instance of the inner type for the variant.
+ - ``is_*``: Returns ``True`` if the inner type is of that variant.
+ - ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``Qubit`` using an instance of the inner type for the variant.
"""
def inner(self) -> Union[int, str]:
@@ -1743,15 +1742,15 @@ class Fence:
class PragmaArgument:
"""
- Variants:
- ``identifier``: A Pragma argument defined by a Quil identifier
- ``integer``: A Pragma argument defined by an integer
+ # Variants:
+ - ``identifier``: A Pragma argument defined by a Quil identifier
+ - ``integer``: A Pragma argument defined by an integer
Methods (for each variant):
- - is_*: Returns ``True`` if the inner type is of that variant.
- - as_*: Returns the inner data if it is the given variant, ``None`` otherwise.
- - to_*: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- - from_*: Creates a new ``PragmaArgument`` using an instance of the inner type for the variant.
+ - ``is_*``: Returns ``True`` if the inner type is of that variant.
+ - ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``PragmaArgument`` using an instance of the inner type for the variant.
"""
def inner(self) -> Union[str, int]:
@@ -2037,15 +2036,15 @@ class Target:
"""
Represents a Quil target.
- Variants:
- ``fixed``: A fixed target defined by a Quil identifier
- ``placeholder``: A placeholder target that can be assigned a new name at a later time.
+ # Variants:
+ - ``fixed``: A fixed target defined by a Quil identifier
+ - ``placeholder``: A placeholder target that can be assigned a new name at a later time.
Methods (for each variant):
- - is_*: Returns ``True`` if the inner type is of that variant.
- - as_*: Returns the inner data if it is the given variant, ``None`` otherwise.
- - to_*: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
- - from_*: Creates a new ``PragmaArgument`` using an instance of the inner type for the variant.
+ - ``is_*``: Returns ``True`` if the inner type is of that variant.
+ - ``as_*``: Returns the inner data if it is the given variant, ``None`` otherwise.
+ - ``to_*``: Returns the inner data if it is the given variant, raises ``ValueError`` otherwise.
+ - ``from_*``: Creates a new ``PragmaArgument`` using an instance of the inner type for the variant.
"""
def __new__(cls, inner: Union[str, TargetPlaceholder]) -> "Target": ...
diff --git a/quil-py/quil/program/__init__.py b/quil-py/quil/program/__init__.py
new file mode 100644
index 00000000..2a4642c3
--- /dev/null
+++ b/quil-py/quil/program/__init__.py
@@ -0,0 +1,5 @@
+"""
+The `quil.program` module contains classes for constructing and representing a
+Quil program.
+"""
+from quil.program import *
diff --git a/quil-py/quil/validation/__init__.py b/quil-py/quil/validation/__init__.py
new file mode 100644
index 00000000..bec07569
--- /dev/null
+++ b/quil-py/quil/validation/__init__.py
@@ -0,0 +1,5 @@
+"""
+The `quil.validation` module contains classes and functions that can validate
+components of a Quil program or instruction.
+"""
+from quil.validation import *
diff --git a/quil-py/quil/validation/identifier.py b/quil-py/quil/validation/identifier.py
new file mode 100644
index 00000000..e7271869
--- /dev/null
+++ b/quil-py/quil/validation/identifier.py
@@ -0,0 +1 @@
+from quil.validation.identifier import *