diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml
index d45a296b737..143313aa57e 100644
--- a/.github/workflows/automerge.yml
+++ b/.github/workflows/automerge.yml
@@ -5,7 +5,7 @@ on:
pull_request:
# Note that we only support automerge on branches that have required checks.
branches:
- - master
+ - main
- feature/*
types:
- labeled
@@ -19,7 +19,7 @@ on:
pull_request_review:
# Note that we only support automerge on branches that have required checks.
branches:
- - master
+ - main
- feature/*
types:
- submitted
diff --git a/.github/workflows/qdk-sync.yml b/.github/workflows/qdk-sync.yml
new file mode 100644
index 00000000000..26b4da3d7d6
--- /dev/null
+++ b/.github/workflows/qdk-sync.yml
@@ -0,0 +1,28 @@
+name: Sync QDK repos
+
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ sync-repos:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Login to Azure
+ uses: Azure/login@v1
+ with:
+ creds: ${{ secrets.AZURE_CREDENTIALS }}
+
+ - id: AzureKeyVault
+ uses: Azure/get-keyvault-secrets@v1.0
+ with:
+ keyvault: 'kv-qdk-build'
+ secrets: 'qdkBuildPAT'
+
+ - name: 'Trigger QDK sync build'
+ uses: Azure/pipelines@releases/v1
+ with:
+ azure-devops-project-url: 'https://dev.azure.com/ms-quantum-public/Microsoft Quantum (public)'
+ azure-pipeline-name: 'microsoft.qdk.sync'
+ azure-devops-token: ${{ steps.AzureKeyVault.outputs.qdkBuildPAT }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 720a2c62f04..7a4ad5261f8 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -5,7 +5,7 @@ repos:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: no-commit-to-branch
- args: [-b, "master"]
+ args: [-b, "main"]
- id: check-yaml
- repo: local
hooks:
diff --git a/Build/e2e.yml b/Build/e2e.yml
new file mode 100644
index 00000000000..a5b980711be
--- /dev/null
+++ b/Build/e2e.yml
@@ -0,0 +1,33 @@
+name: $(Build.Major).$(Build.Minor).$(date:yyMM).$(BuildId)
+
+parameters:
+- name: validation_level
+ displayName: Validation Level
+ type: string
+ default: normal
+ values:
+ - minimal
+ - normal
+ - full
+
+trigger: none
+
+pr:
+- main
+- feature/*
+- features/*
+- release/*
+
+resources:
+ repositories:
+ - repository: qdk
+ type: github
+ endpoint: github
+ name: microsoft/qdk
+ ref: refs/heads/main
+
+extends:
+ template: build/qdk-module-e2e.yml@qdk
+ parameters:
+ module: QuantumLibraries
+ validation_level: ${{ parameters.validation_level }}
diff --git a/Build/manifest.ps1 b/Build/manifest.ps1
index fe82d57e8ef..9765de673a3 100644
--- a/Build/manifest.ps1
+++ b/Build/manifest.ps1
@@ -1,23 +1,50 @@
-#!/usr/bin/env pwsh
-#Requires -PSEdition Core
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License.
+
+<#
+ .SYNOPSIS
+ Provides the list of artifacts (Packages and Assemblies) generated by this repository.
+
+ .PARAMETER OutputFormat
+ Specifies if the output of this script should be a hashtable with the artifacts
+ as strings with the absolute path (AbsolutePath) or FileInfo structures.
+#>
+param(
+ [ValidateSet('FileInfo','AbsolutePath')]
+ [string] $OutputFormat = 'FileInfo'
+);
+
& "$PSScriptRoot/set-env.ps1"
-@{
+$artifacts = @{
Packages = @(
- "Microsoft.Quantum.Standard",
- "Microsoft.Quantum.Standard.Visualization",
"Microsoft.Quantum.Chemistry",
+ "Microsoft.Quantum.Chemistry.DataModel",
+ "Microsoft.Quantum.Chemistry.Jupyter",
+ "Microsoft.Quantum.Chemistry.Runtime",
+ "Microsoft.Quantum.Chemistry.Tools",
+ "Microsoft.Quantum.MachineLearning",
"Microsoft.Quantum.Numerics",
- "Microsoft.Quantum.MachineLearning"
- );
+ "Microsoft.Quantum.Standard",
+ "Microsoft.Quantum.Standard.Visualization"
+ ) | ForEach-Object { Join-Path $Env:NUGET_OUTDIR "$_.$Env:NUGET_VERSION.nupkg" };
+
Assemblies = @(
".\Standard\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Standard.dll",
".\Visualization\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Standard.Visualization.dll",
".\Numerics\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Numerics.dll",
".\MachineLearning\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.MachineLearning.dll",
".\Chemistry\src\DataModel\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.DataModel.dll",
+ ".\Chemistry\src\Jupyter\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Jupyter.dll",
".\Chemistry\src\Runtime\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Runtime.dll",
".\Chemistry\src\Tools\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\qdk-chem.dll"
- ) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot ".." $_) };
-} | Write-Output;
+ ) | ForEach-Object { Join-Path $PSScriptRoot (Join-Path ".." $_) };
+}
+
+if ($OutputFormat -eq 'FileInfo') {
+ $artifacts.Packages = $artifacts.Packages | ForEach-Object { Get-Item $_ };
+ $artifacts.Assemblies = $artifacts.Assemblies | ForEach-Object { Get-Item $_ };
+}
+
+$artifacts | Write-Output;
diff --git a/Build/props/tests.props b/Build/props/tests.props
index 1c76f5de1e9..5cc3d169a4a 100644
--- a/Build/props/tests.props
+++ b/Build/props/tests.props
@@ -6,7 +6,7 @@
-
+
@@ -14,4 +14,3 @@
-
diff --git a/Build/steps.yml b/Build/steps.yml
index 2f386fd117b..4e6aebbfbe2 100644
--- a/Build/steps.yml
+++ b/Build/steps.yml
@@ -36,4 +36,10 @@ steps:
workingDirectory: $(System.DefaultWorkingDirectory)/Build
+- pwsh: .\manifest.ps1
+ displayName: "List built packages & assemblies"
+ workingDirectory: '$(System.DefaultWorkingDirectory)/Build'
+ condition: succeededOrFailed()
+
+
- template: step-wrap-up.yml
diff --git a/Chemistry/README.md b/Chemistry/README.md
index af55bebbab0..53784f5a395 100644
--- a/Chemistry/README.md
+++ b/Chemistry/README.md
@@ -1,14 +1,14 @@
# Microsoft Quantum Chemistry Library #
This folder contains the C# and Q# sources used to implement the [Microsoft Quantum Chemistry library](https://docs.microsoft.com/en-us/quantum/libraries/chemistry/).
-Samples of how to use the library can be found in the Chemistry folder of the [Microsoft/Quantum repository](https://github.com/Microsoft/Quantum/tree/master/Chemistry).
+Samples of how to use the library can be found in the Chemistry folder of the [Microsoft/Quantum repository](https://github.com/microsoft/Quantum/tree/main/Chemistry).
## Building and testing ##
The quantum chemistry library consists of two cross-platform project built using [.NET Core](https://docs.microsoft.com/en-us/dotnet/core/):
-- [**DataModel.csproj**](https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry/src/DataModel/DataModel.csproj): C# sources used to load, parse, and pre-compute Hamiltonians loaded from LIQđđ|âȘ or Broombridge files.
-- [**Runtime.csproj**](https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry/src/Runtime/Runtime.csproj): Q# sources used to implement quantum chemistry simulation algorithms, given representations produced by the DataModel.
+- [**DataModel.csproj**](https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry/src/DataModel/DataModel.csproj): C# sources used to load, parse, and pre-compute Hamiltonians loaded from LIQđđ|âȘ or Broombridge files.
+- [**Runtime.csproj**](https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry/src/Runtime/Runtime.csproj): Q# sources used to implement quantum chemistry simulation algorithms, given representations produced by the DataModel.
Once .NET Core is installed, you may build and run its tests by executing the following from a command line:
diff --git a/Chemistry/src/DataModel/DataModel.csproj b/Chemistry/src/DataModel/DataModel.csproj
index 47f07491b0d..bdc7bb56ed9 100644
--- a/Chemistry/src/DataModel/DataModel.csproj
+++ b/Chemistry/src/DataModel/DataModel.csproj
@@ -14,7 +14,7 @@
Microsoft.Quantum.Chemistry.DataModel
See: https://docs.microsoft.com/en-us/quantum/relnotes/
MIT
- https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry
+ https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry
qdk-nuget-icon.png
Quantum Q# Qsharp
1591
diff --git a/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeDataStructurev0.1.cs b/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeDataStructurev0.1.cs
index e38acf87039..60864998679 100644
--- a/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeDataStructurev0.1.cs
+++ b/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeDataStructurev0.1.cs
@@ -128,7 +128,7 @@ internal static V0_1.IntegralSet ToBroombridgeV0_1(this ElectronicStructureProbl
#region Broombridge v0.1 format
public static class V0_1
{
- public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/master/Chemistry/Schema/broombridge-0.1.schema.json";
+ public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/main/Chemistry/Schema/broombridge-0.1.schema.json";
public struct Data
{
diff --git a/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeDataStructurev0.2.cs b/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeDataStructurev0.2.cs
index 2bcc87a8162..755a6c80a63 100644
--- a/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeDataStructurev0.2.cs
+++ b/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeDataStructurev0.2.cs
@@ -167,7 +167,7 @@ this IEnumerable initialStates
#region Broombridge v0.2 format
public static class V0_2
{
- public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/master/Chemistry/Schema/broombridge-0.2.schema.json";
+ public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/main/Chemistry/Schema/broombridge-0.2.schema.json";
internal static class UpdaterStrings
{
public const string SingleConfigurational = "single_configurational";
diff --git a/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeSerializer.cs b/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeSerializer.cs
index 3616e82ca97..ce02a23a0b2 100644
--- a/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeSerializer.cs
+++ b/Chemistry/src/DataModel/Serialization/Broombridge/BroombridgeSerializer.cs
@@ -92,7 +92,7 @@ public static class Deserializers
///
internal static Dictionary VersionNumberDict = new Dictionary()
{
- // https://github.com/Microsoft/Quantum/blob/master/Chemistry/Schema/broombridge-0.1.schema.json
+ // https://github.com/microsoft/Quantum/blob/main/Chemistry/Schema/broombridge-0.1.schema.json
["0.1"] = VersionNumber.v0_1,
["broombridge-0.1.schema"] = VersionNumber.v0_1,
// TODO: URL of 0.2 schema.
diff --git a/Chemistry/src/Jupyter/BroombridgeMagic.cs b/Chemistry/src/Jupyter/BroombridgeMagic.cs
index abf5f8f5340..d3bbcc3bf9d 100644
--- a/Chemistry/src/Jupyter/BroombridgeMagic.cs
+++ b/Chemistry/src/Jupyter/BroombridgeMagic.cs
@@ -16,7 +16,7 @@ public class BroombridgeMagic : MagicSymbol
public BroombridgeMagic()
{
this.Name = $"%chemistry.broombridge";
- this.Documentation = new Documentation() { Summary = "Loads and returns Broombridge electronic structure problem representation from a given .yaml file." };
+ this.Documentation = new Microsoft.Jupyter.Core.Documentation() { Summary = "Loads and returns Broombridge electronic structure problem representation from a given .yaml file." };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
diff --git a/Chemistry/src/Jupyter/ChemistryEncodeMagic.cs b/Chemistry/src/Jupyter/ChemistryEncodeMagic.cs
index 8eac3a69ca3..6e88be2b0be 100644
--- a/Chemistry/src/Jupyter/ChemistryEncodeMagic.cs
+++ b/Chemistry/src/Jupyter/ChemistryEncodeMagic.cs
@@ -17,7 +17,7 @@ public class ChemistryEncodeMagic : MagicSymbol
public ChemistryEncodeMagic()
{
this.Name = $"%chemistry.encode";
- this.Documentation = new Documentation() { Summary = "Encodes a fermion Hamiltonian to a format consumable by Q#." };
+ this.Documentation = new Microsoft.Jupyter.Core.Documentation() { Summary = "Encodes a fermion Hamiltonian to a format consumable by Q#." };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
diff --git a/Chemistry/src/Jupyter/FermionHamiltonianMagic.cs b/Chemistry/src/Jupyter/FermionHamiltonianMagic.cs
index b61954ed4e0..07e3583bd37 100644
--- a/Chemistry/src/Jupyter/FermionHamiltonianMagic.cs
+++ b/Chemistry/src/Jupyter/FermionHamiltonianMagic.cs
@@ -26,7 +26,7 @@ public class FermionHamiltonianLoadMagic : MagicSymbol
public FermionHamiltonianLoadMagic()
{
this.Name = $"%chemistry.fh.load";
- this.Documentation = new Documentation() { Summary = "Loads the fermion Hamiltonian for an electronic structure problem. The problem is loaded from a file or passed as an argument." };
+ this.Documentation = new Microsoft.Jupyter.Core.Documentation() { Summary = "Loads the fermion Hamiltonian for an electronic structure problem. The problem is loaded from a file or passed as an argument." };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
@@ -113,7 +113,10 @@ public class FermionHamiltonianAddTermsMagic : MagicSymbol
public FermionHamiltonianAddTermsMagic()
{
this.Name = $"%chemistry.fh.add_terms";
- this.Documentation = new Documentation() { Summary = "Adds terms to a fermion Hamiltonian." };
+ this.Documentation = new Microsoft.Jupyter.Core.Documentation
+ {
+ Summary = "Adds terms to a fermion Hamiltonian."
+ };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
diff --git a/Chemistry/src/Jupyter/Jupyter.csproj b/Chemistry/src/Jupyter/Jupyter.csproj
index 833b8769531..79cd4321aea 100644
--- a/Chemistry/src/Jupyter/Jupyter.csproj
+++ b/Chemistry/src/Jupyter/Jupyter.csproj
@@ -10,8 +10,8 @@
Microsoft's Quantum Chemistry Libraries Jupyter integration.
© Microsoft Corporation. All rights reserved.
See: https://docs.microsoft.com/en-us/quantum/relnotes/
- https://github.com/Microsoft/QuantumLibraries/raw/master/LICENSE.txt
- https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry
+ https://github.com/microsoft/QuantumLibraries/raw/main/LICENSE.txt
+ https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry
qdk-nuget-icon.png
Quantum Q# Qsharp Jupyter
1591
@@ -29,6 +29,10 @@
+
+
+
+
diff --git a/Chemistry/src/Jupyter/WavefunctionMagic.cs b/Chemistry/src/Jupyter/WavefunctionMagic.cs
index bed1d935b78..f32b2bf538e 100644
--- a/Chemistry/src/Jupyter/WavefunctionMagic.cs
+++ b/Chemistry/src/Jupyter/WavefunctionMagic.cs
@@ -20,7 +20,7 @@ public class WavefunctionMagic : MagicSymbol
public WavefunctionMagic()
{
this.Name = $"%chemistry.inputstate.load";
- this.Documentation = new Documentation() { Summary = "Loads Broombridge electronic structure problem and returns selected input state." };
+ this.Documentation = new Microsoft.Jupyter.Core.Documentation() { Summary = "Loads Broombridge electronic structure problem and returns selected input state." };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
diff --git a/Chemistry/src/Metapackage/Metapackage.csproj b/Chemistry/src/Metapackage/Metapackage.csproj
index d4b1668e95a..cd940394e81 100644
--- a/Chemistry/src/Metapackage/Metapackage.csproj
+++ b/Chemistry/src/Metapackage/Metapackage.csproj
@@ -13,7 +13,7 @@
Microsoft.Quantum.Chemistry
See: https://docs.microsoft.com/en-us/quantum/relnotes/
MIT
- https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry
+ https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry
qdk-nuget-icon.png
Quantum Q# Qsharp
1591
diff --git a/Chemistry/src/Runtime/JordanWigner/JordanWignerClusterOperatorEvolutionSet.qs b/Chemistry/src/Runtime/JordanWigner/JordanWignerClusterOperatorEvolutionSet.qs
index 3489b204f33..660b48b4b4c 100644
--- a/Chemistry/src/Runtime/JordanWigner/JordanWignerClusterOperatorEvolutionSet.qs
+++ b/Chemistry/src/Runtime/JordanWigner/JordanWignerClusterOperatorEvolutionSet.qs
@@ -10,7 +10,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
open Microsoft.Quantum.Arrays;
/// # Summary
- /// Computes Z component of JordanWigner string between
+ /// Computes Z component of JordanâWigner string between
/// fermion indices in a fermionic operator with an even
/// number of creation / annihilation operators.
///
@@ -89,7 +89,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
let ops = [[PauliX, PauliY], [PauliY, PauliX]];
let signs = [+1.0, -1.0];
- for ((op, sign) in Zip(ops, signs)) {
+ for ((op, sign) in Zipped(ops, signs)) {
let pauliString = _ComputeJordanWignerPauliString(Length(qubits), idxFermions, op);
Exp(pauliString, sign * angle, qubits);
}
@@ -124,7 +124,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
let ops = [[y,y,x,y],[x,x,x,y],[x,y,y,y],[y,x,y,y],[x,y,x,x],[y,x,x,x],[y,y,y,x],[x,x,y,x]];
let (sortedIndices, signs, globalSign) = _JordanWignerClusterOperatorPQRSTermSigns([p,q,r,s]);
- for ((op, sign) in Zip(ops, signs)) {
+ for ((op, sign) in Zipped(ops, signs)) {
let pauliString = _ComputeJordanWignerPauliString(Length(qubits), sortedIndices, op);
Exp(pauliString, globalSign * sign * angle, qubits);
}
@@ -272,4 +272,3 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
}
-
diff --git a/Chemistry/src/Runtime/JordanWigner/JordanWignerEvolutionSet.qs b/Chemistry/src/Runtime/JordanWigner/JordanWignerEvolutionSet.qs
index 969a72221da..d9890ef31bd 100644
--- a/Chemistry/src/Runtime/JordanWigner/JordanWignerEvolutionSet.qs
+++ b/Chemistry/src/Runtime/JordanWigner/JordanWignerEvolutionSet.qs
@@ -8,7 +8,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
open Microsoft.Quantum.Chemistry;
open Microsoft.Quantum.Arrays;
- // This evolution set runs off data optimized for a JordanWigner encoding.
+ // This evolution set runs off data optimized for a JordanâWigner encoding.
// This collects terms Z, ZZ, PQandPQQR, hpqrs separately.
// This only apples the needed hpqrs XXXX XXYY terms.
// Operations here are expressed in terms of Exp([...])
@@ -134,7 +134,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
if (idxFermions[0] < qubitQidx and qubitQidx < idxFermions[3]) {
let termPR1 = GeneratorIndex((idxTermType, [1.0]), [idxFermions[0], idxFermions[3] - 1]);
- _ApplyJordanWignerPQTerm_(termPR1, angle, new Qubit[0], Exclude([qubitQidx], qubits));
+ _ApplyJordanWignerPQTerm_(termPR1, angle, new Qubit[0], Excluding([qubitQidx], qubits));
}
else {
let termPR1 = GeneratorIndex((idxTermType, [1.0]), [0, idxFermions[3] - idxFermions[0]]);
@@ -280,4 +280,3 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
}
-
diff --git a/Chemistry/src/Runtime/JordanWigner/JordanWignerVQE.qs b/Chemistry/src/Runtime/JordanWigner/JordanWignerVQE.qs
index ba605577cb2..41e688129fa 100644
--- a/Chemistry/src/Runtime/JordanWigner/JordanWignerVQE.qs
+++ b/Chemistry/src/Runtime/JordanWigner/JordanWignerVQE.qs
@@ -39,7 +39,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner.VQE {
mutable jwTermEnergy = 0.;
- for ((coeff, op) in Zip(coeffs, ops)) {
+ for ((coeff, op) in Zipped(coeffs, ops)) {
// Only perform computation if the coefficient is significant enough
if (AbsD(coeff) >= 1e-10) {
// Compute expectation value using the fast frequency estimator, add contribution to Jordan-Wigner term energy
@@ -95,7 +95,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner.VQE {
mutable compactOp = compactOps[iOp];
mutable op = ConstantArray(nQubits, PauliI);
- for ((idx, pauli) in Zip(indices, compactOp)) {
+ for ((idx, pauli) in Zipped(indices, compactOp)) {
set op w/= idx <- pauli;
}
for (i in indices[0]+1..indices[1]-1) {
diff --git a/Chemistry/src/Runtime/Runtime.csproj b/Chemistry/src/Runtime/Runtime.csproj
index aa91f2bf0ef..af4bcb22167 100644
--- a/Chemistry/src/Runtime/Runtime.csproj
+++ b/Chemistry/src/Runtime/Runtime.csproj
@@ -1,4 +1,4 @@
-
+
netstandard2.1
@@ -6,6 +6,10 @@
true
false
True
+
+ Microsoft.Quantum.Chemistry
@@ -15,7 +19,7 @@
Microsoft.Quantum.Chemistry.Runtime
See: https://docs.microsoft.com/en-us/quantum/relnotes/
MIT
- https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry
+ https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry
qdk-nuget-icon.png
Quantum Q# Qsharp
1591
@@ -36,7 +40,7 @@
-
+
@@ -44,4 +48,3 @@
-
diff --git a/Chemistry/tests/ChemistryTests/QSharpTests.csproj b/Chemistry/tests/ChemistryTests/QSharpTests.csproj
index 0c32a5c7541..93341456f6e 100644
--- a/Chemistry/tests/ChemistryTests/QSharpTests.csproj
+++ b/Chemistry/tests/ChemistryTests/QSharpTests.csproj
@@ -1,4 +1,4 @@
-
+
@@ -12,4 +12,3 @@
-
diff --git a/Chemistry/tests/SystemTests/SystemTests.csproj b/Chemistry/tests/SystemTests/SystemTests.csproj
index 27269417885..fb9aaedeaac 100644
--- a/Chemistry/tests/SystemTests/SystemTests.csproj
+++ b/Chemistry/tests/SystemTests/SystemTests.csproj
@@ -1,4 +1,4 @@
-
+
@@ -39,4 +39,3 @@
-
diff --git a/Chemistry/tests/TestData/Broombridge/LiH_0.1.yaml b/Chemistry/tests/TestData/Broombridge/LiH_0.1.yaml
index d445ffea4e1..4da9dd7aede 100644
--- a/Chemistry/tests/TestData/Broombridge/LiH_0.1.yaml
+++ b/Chemistry/tests/TestData/Broombridge/LiH_0.1.yaml
@@ -1,5 +1,5 @@
-"$schema": https://raw.githubusercontent.com/Microsoft/Quantum/master/Chemistry/Schema/broombridge-0.1.schema.json
+"$schema": https://raw.githubusercontent.com/Microsoft/Quantum/main/Chemistry/Schema/broombridge-0.1.schema.json
bibliography:
- {url: 'https://www.nwchem-sw.org'}
diff --git a/Chemistry/tests/TestData/Broombridge/LiH_0.2.yaml b/Chemistry/tests/TestData/Broombridge/LiH_0.2.yaml
index 48fd61a5792..3c0586b6c06 100644
--- a/Chemistry/tests/TestData/Broombridge/LiH_0.2.yaml
+++ b/Chemistry/tests/TestData/Broombridge/LiH_0.2.yaml
@@ -1,4 +1,4 @@
-"$schema": https://raw.githubusercontent.com/Microsoft/Quantum/master/Chemistry/Schema/broombridge-0.2.schema.json
+"$schema": https://raw.githubusercontent.com/Microsoft/Quantum/main/Chemistry/Schema/broombridge-0.2.schema.json
bibliography:
- {url: 'https://www.nwchem-sw.org'}
diff --git a/Chemistry/tests/TestData/Broombridge/broombridge_v0.1.yaml b/Chemistry/tests/TestData/Broombridge/broombridge_v0.1.yaml
index b74f4f0072f..2617b40d25a 100644
--- a/Chemistry/tests/TestData/Broombridge/broombridge_v0.1.yaml
+++ b/Chemistry/tests/TestData/Broombridge/broombridge_v0.1.yaml
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Generated by nwchem version v...
-"$schema": https://github.com/Microsoft/Quantum/blob/master/Chemistry/Schema/broombridge-0.1.schema.json
+"$schema": https://github.com/microsoft/Quantum/blob/main/Chemistry/Schema/broombridge-0.1.schema.json
format: # required
version: "0.1" # must match exactly
generator: # optional
diff --git a/Chemistry/tests/TestData/Broombridge/broombridge_v0.2.yaml b/Chemistry/tests/TestData/Broombridge/broombridge_v0.2.yaml
index b6bb948516f..79d3d30d62e 100644
--- a/Chemistry/tests/TestData/Broombridge/broombridge_v0.2.yaml
+++ b/Chemistry/tests/TestData/Broombridge/broombridge_v0.2.yaml
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Generated by nwchem version v...
-"$schema": https://github.com/Microsoft/Quantum/blob/master/Chemistry/Schema/broombridge-0.2.schema.json
+"$schema": https://github.com/microsoft/Quantum/blob/main/Chemistry/Schema/broombridge-0.2.schema.json
format:
version: "0.2" # required. Must match exactly
generator: # optional
diff --git a/Chemistry/tests/TestData/Broombridge/hydrogen_0.1.yaml b/Chemistry/tests/TestData/Broombridge/hydrogen_0.1.yaml
index fda4dff03ef..fdf98af2368 100644
--- a/Chemistry/tests/TestData/Broombridge/hydrogen_0.1.yaml
+++ b/Chemistry/tests/TestData/Broombridge/hydrogen_0.1.yaml
@@ -1,5 +1,5 @@
-"$schema": https://raw.githubusercontent.com/Microsoft/Quantum/master/Chemistry/Schema/broombridge-0.1.schema.json
+"$schema": https://raw.githubusercontent.com/Microsoft/Quantum/main/Chemistry/Schema/broombridge-0.1.schema.json
bibliography:
- {url: 'https://www.nwchem-sw.org'}
diff --git a/Chemistry/tests/TestData/Broombridge/hydrogen_0.2.yaml b/Chemistry/tests/TestData/Broombridge/hydrogen_0.2.yaml
index 61bd380ccd3..129c9bf1390 100644
--- a/Chemistry/tests/TestData/Broombridge/hydrogen_0.2.yaml
+++ b/Chemistry/tests/TestData/Broombridge/hydrogen_0.2.yaml
@@ -1,5 +1,5 @@
-"$schema": https://raw.githubusercontent.com/Microsoft/Quantum/master/Chemistry/Schema/broombridge-0.2.schema.json
+"$schema": https://raw.githubusercontent.com/Microsoft/Quantum/main/Chemistry/Schema/broombridge-0.2.schema.json
bibliography:
- {url: 'https://www.nwchem-sw.org'}
diff --git a/Chemistry/tests/TestData/FciDump/h2_631g.yaml b/Chemistry/tests/TestData/FciDump/h2_631g.yaml
index 9024b04fdd4..292b786e7de 100644
--- a/Chemistry/tests/TestData/FciDump/h2_631g.yaml
+++ b/Chemistry/tests/TestData/FciDump/h2_631g.yaml
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# H2 molecule using 6-31G basis, containing 2 electrons 4 orbitals
-$schema: https://raw.githubusercontent.com/Microsoft/Quantum/master/Chemistry/Schema/broombridge-0.2.schema.json
+$schema: https://raw.githubusercontent.com/Microsoft/Quantum/main/Chemistry/Schema/broombridge-0.2.schema.json
format:
version: '0.2'
problem_description:
diff --git a/Design/meetings/2020/api-design-2020-09-10.md b/Design/meetings/2020/api-design-2020-09-10.md
new file mode 100644
index 00000000000..22bf37c488e
--- /dev/null
+++ b/Design/meetings/2020/api-design-2020-09-10.md
@@ -0,0 +1,81 @@
+# Q# API Design Meeting / 10 September 2020
+
+Attendees (in order by username): @bettinaheim, @cgranade, @efratshabtai, @guenp, @msoeken.
+
+## Agenda
+
+- Improvements to `Microsoft.Quantum.Array` namespace
+- Removing `Microsoft.Quantum.Simulation.QuantumProcessor.Extensions` namespace
+
+## Discussion
+
+### Microsoft.Quantum.Arrays
+
+**Proposal**: https://github.com/microsoft/QuantumLibraries/issues/313
+
+**Discussion**:
+
+- Zip is very commonly used in existing Q# code, is it worth being consistent in this case at the cost of causing significant breakage?
+ - Consistency is important for reaching Q# 1.0.
+ - Can we resolve using code actions as aliases instead of deprecation stubs?
+ - No conventions and nomenclature are truly universal across languages.
+ - Helped by IntelliSense features as well, need matching investment in IQ#.
+ - Modify unknown identifier error message to provide actionable guidance ("did you mean...?")
+ - Aliases can be helpful, but are maintenance nightmare.
+ - **Action item**: discuss aliases, error messages, and/or other possible onboarding paths further.
+- Likely missing: function `((Int -> 'T), Range) -> 'T[]`.
+ - There as `MappedOverRange`, but should we have a better name?
+ - Perhaps "over" is confusing?
+ - Inconsistent w/ use of suffixes for input types.
+ - **Action item**: Propose better name here, addressing "over" and type suffix conventions.
+- `CumulativeFolded`: Should it return initial state or not?
+ - `np.cumsum` excludes initial state
+ - **Action item**: Examine other languages here.
+- `ColumnAt`: No matching `RowAt`, because it's not directly needed. Should we add anyway?
+ - `RowAt` is distinct from `ElementAt` in that it requires two levels of indices, whereas `ElementAt` does not.
+ - **Action item**: Modify proposal to add `RowAt`.
+- `Count`: simpler for what is currently a common usecase for `Filtered`.
+ - Would be simplified by https://github.com/microsoft/qsharp-compiler/issues/557; defer introducing specializations until result of that discussion.
+- `EmptyArray`: doesn't solve problem that `[]` can't be used as an empty array of a given type, while `[3]` works as an array literal.
+ - **Action item**: File as issue on qsharp-compiler?
+- `Interleaved`: Should it support more than two inputs?
+ - If array-valued input, can use Transposed and Flattened together.
+ - Possibly change to take array-valued input, but then implementation can check length of input and do a more efficient thing if possible.
+ - **Action item**: Modify proposal to take array of inputs.
+- `Unique`: doesn't work as written, would be slow if implemented.
+ - **Action item**: Modify proposal to defer.
+- `Zipped`/`Unzipped`: Not elegant to have `Unzipped3`, `Unzipped4`, ...
+ - Also solvable by https://github.com/microsoft/qsharp-compiler/issues/557, but solution would be unwieldy.
+- Missing: function to sort arrays.
+ - **Action item**: Modify proposal to add `Sorted`.
+- `ApplyTo{Head,Tail,Most,Rest}`
+ - ApplyToHead is redundant with ApplyToFirstQubit, but worth keeping for consistency with Tail, Most, Rest.
+- `ArrayAsHeadAndRest` / `ArrayAsMostAndTail`:
+ - **Action item**: Rename to `HeadAndRest` / `MostAndTail`, move to `Microsoft.Quantum.Arrays`.
+- Missing fact to check that a 2D array is rectangular / square.
+ - `RectangularArrayFact` / `SquareArrayFact`?
+ - **Action item**: Modify proposal to add these two facts.
+
+**Other action items**:
+
+- Comment on user feedback with ElementAt.
+- Rename `folder` input on Microsoft.Quantum.Arrays.Folded to `fn` for consistency with `CumulativeFolded`.
+- Discuss grouping removal of deprecation stubs, rather than splitting removals over multiple releases. Would 1.0 be a reasonable timeframe?
+
+**Consensus**: Proceed as per above action items.
+
+### Remove Microsoft.Quantum.Simulation.QuantumProcessor.Extensions
+
+**Proposal**: The functions and operations in the Microsoft.Quantum.Simulation.QuantumProcessor.Extensions namespace are completely redundant with existing Q# standard library callables, and exist to help manage dependency ordering. It is proposed to move duplicated callables to the qsharp-runtime repo, and deprecate the copies in Microsoft.Quantum.Simulation.QuantumProcessor.Extensions.
+
+**Discussion**:
+
+- Does this affect the rewrite steps?
+ - Yes, but we can port those rewrite steps, and should do so. It will take minimal effort to do so.
+- Impact on samples/katas?
+ - Minimal; only one sample uses at all.
+- Observation: calling deprecated operations from deprecated operations still results in warnings (e.g.: ResultStack).
+ - Proposal: don't raise deprecation warnings from within deprecated callables.
+ - Action item: make feature request on qsharp-compiler.
+
+**Consensus**: Proceed as proposed.
diff --git a/MachineLearning.sln b/MachineLearning.sln
index a083c3f402f..adf6e4fcc2c 100644
--- a/MachineLearning.sln
+++ b/MachineLearning.sln
@@ -1,13 +1,15 @@
ï»ż
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MachineLearning", "MachineLearning", "{D067C787-94C3-4DB8-9012-1F22AE784BEF}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MachineLearningTests", "MachineLearning\tests\MachineLearningTests.csproj", "{94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MachineLearningTests", "MachineLearning\tests\MachineLearningTests.csproj", "{94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MachineLearning", "MachineLearning\src\MachineLearning.csproj", "{B045BF35-6BE6-4982-9618-8725C70D3F91}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MachineLearning", "MachineLearning\src\MachineLearning.csproj", "{B045BF35-6BE6-4982-9618-8725C70D3F91}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard", "Standard\src\Standard.csproj", "{9907AAA7-10DA-470B-A154-5A19D1A831E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -18,9 +20,6 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C}.Debug|Any CPU.Build.0 = Debug|Any CPU
@@ -46,9 +45,27 @@ Global
{B045BF35-6BE6-4982-9618-8725C70D3F91}.Release|x64.Build.0 = Release|Any CPU
{B045BF35-6BE6-4982-9618-8725C70D3F91}.Release|x86.ActiveCfg = Release|Any CPU
{B045BF35-6BE6-4982-9618-8725C70D3F91}.Release|x86.Build.0 = Release|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|x64.Build.0 = Debug|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|x86.Build.0 = Debug|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|x64.ActiveCfg = Release|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|x64.Build.0 = Release|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|x86.ActiveCfg = Release|Any CPU
+ {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C} = {D067C787-94C3-4DB8-9012-1F22AE784BEF}
{B045BF35-6BE6-4982-9618-8725C70D3F91} = {D067C787-94C3-4DB8-9012-1F22AE784BEF}
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {08B056E4-F7DA-4802-B23C-BB11D6616F5E}
+ EndGlobalSection
EndGlobal
diff --git a/MachineLearning/src/MachineLearning.csproj b/MachineLearning/src/MachineLearning.csproj
index d1028037fc1..5017c5932ff 100644
--- a/MachineLearning/src/MachineLearning.csproj
+++ b/MachineLearning/src/MachineLearning.csproj
@@ -1,8 +1,9 @@
-
+
netstandard2.1
Microsoft.Quantum.MachineLearning
true
+ Microsoft.Quantum.MachineLearning
1591
+
+
+ true
+
+
+
+
Microsoft
Microsoft's Quantum standard libraries.
@@ -30,7 +37,7 @@
-
+
diff --git a/Standard/src/Synthesis/ControlledOnTruthTable.qs b/Standard/src/Synthesis/ControlledOnTruthTable.qs
index c716242ea53..6f28a15894d 100644
--- a/Standard/src/Synthesis/ControlledOnTruthTable.qs
+++ b/Standard/src/Synthesis/ControlledOnTruthTable.qs
@@ -139,7 +139,7 @@ namespace Microsoft.Quantum.Synthesis {
/// and the least significant bit `0` corresponds to the input assignment `(0, 0, 0)`.
/// It can be represented by the big integer `0xE8L` in hexadecimal notation or as `232L`
/// in decimal notation. The `L` suffix indicates that the constant is of type `BigInt`.
- /// More details on this representation can also be found in the [truth tables kata](https://github.com/microsoft/QuantumKatas/tree/master/TruthTables).
+ /// More details on this representation can also be found in the [truth tables kata](https://github.com/microsoft/QuantumKatas/tree/main/TruthTables).
///
/// The implementation makes use of @"microsoft.quantum.intrinsic.cnot"
/// and @"microsoft.quantum.intrinsic.r1" gates.
diff --git a/Standard/src/Synthesis/DecompositionBased.qs b/Standard/src/Synthesis/DecompositionBased.qs
index 3ad114f4af5..26a55f056ed 100644
--- a/Standard/src/Synthesis/DecompositionBased.qs
+++ b/Standard/src/Synthesis/DecompositionBased.qs
@@ -279,7 +279,7 @@ namespace Microsoft.Quantum.Synthesis {
let register = qubits!;
for ((func, target) in TruthTablesFromPermutation(perm, variableOrder)) {
- ApplyXControlledOnTruthTable(func, Exclude([target], register), register[target]);
+ ApplyXControlledOnTruthTable(func, Excluding([target], register), register[target]);
}
}
}
diff --git a/Standard/src/Synthesis/Transposition.qs b/Standard/src/Synthesis/Transposition.qs
index 9f7c1a81183..08c93b6f8ec 100644
--- a/Standard/src/Synthesis/Transposition.qs
+++ b/Standard/src/Synthesis/Transposition.qs
@@ -54,11 +54,11 @@ namespace Microsoft.Quantum.Synthesis {
within {
for (target in Most(diff)) {
- (BitControlledX(bbits[...target - 1] + abits[target + 1...]))(Exclude([target], qs), qs[target]);
+ (BitControlledX(bbits[...target - 1] + abits[target + 1...]))(Excluding([target], qs), qs[target]);
}
} apply {
let target = Tail(diff);
- (BitControlledX(bbits[...target - 1] + abits[target + 1...]))(Exclude([target], qs), qs[target]);
+ (BitControlledX(bbits[...target - 1] + abits[target + 1...]))(Excluding([target], qs), qs[target]);
}
}
}
diff --git a/Standard/tests/AmplitudeAmplificationTests.qs b/Standard/tests/AmplitudeAmplificationTests.qs
index 4f731c119e8..f25ebe30718 100644
--- a/Standard/tests/AmplitudeAmplificationTests.qs
+++ b/Standard/tests/AmplitudeAmplificationTests.qs
@@ -31,7 +31,8 @@ namespace Microsoft.Quantum.Tests {
/// In this minimal example, there are no system qubits, only a single flag qubit.
/// ExampleStatePrep is already of type StateOracle, so we call
/// StandardAmplitudeAmplification(iterations: Int, stateOracle : StateOracle, idxFlagQubit : Int startQubits: Qubit[]) : ()
- operation AmpAmpByOracleTest () : Unit {
+ @Test("QuantumSimulator")
+ operation CheckAmpAmpByOracle () : Unit {
using (qubits = Qubit[1]) {
ResetAll(qubits);
@@ -54,8 +55,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation AmpAmpObliviousByOraclePhasesTest () : Unit {
+ @Test("QuantumSimulator")
+ operation CheckAmpAmpObliviousByOraclePhases () : Unit {
using (qubits = Qubit[1]) {
ResetAll(qubits);
@@ -80,8 +81,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation AmpAmpTargetStateReflectionOracleTest () : Unit {
+ @Test("QuantumSimulator")
+ operation CheckAmpAmpTargetStateReflectionOracle () : Unit {
using (qubits = Qubit[1]) {
ResetAll(qubits);
diff --git a/Standard/tests/ApplyMultiControlledTests.qs b/Standard/tests/ApplyMultiControlledTests.qs
index e05139732bd..e5ef7cbe1c4 100644
--- a/Standard/tests/ApplyMultiControlledTests.qs
+++ b/Standard/tests/ApplyMultiControlledTests.qs
@@ -11,7 +11,8 @@ namespace Microsoft.Quantum.Tests {
/// Tests multiply controlled not implementation that uses
/// ApplyMultiControlledCA against multiply controlled version of
/// the Microsoft.Quantum.Intrinsic.X
- operation ApplyMultiControlledTest () : Unit {
+ @Test("QuantumSimulator")
+ operation CheckApplyMultiControlled() : Unit {
let twoQubitOp = CNOT;
diff --git a/Standard/tests/ApplyRepeatedOverTests.qs b/Standard/tests/ApplyRepeatedOverTests.qs
index 51594b46a3e..7bb4220d151 100644
--- a/Standard/tests/ApplyRepeatedOverTests.qs
+++ b/Standard/tests/ApplyRepeatedOverTests.qs
@@ -8,8 +8,8 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Arrays;
-
- operation ApplySeriesOfOpsTest() : Unit {
+ @Test("QuantumSimulator")
+ operation CheckApplySeriesOfOps() : Unit {
// create the sample ops + their targets here
let op1 = ApplyToFirstQubit(X, _);
let op2 = ApplyToFirstTwoQubits(CNOT, _);
@@ -34,7 +34,8 @@ namespace Microsoft.Quantum.Tests {
ApplyToEachCA(H, Subarray([1, 2, 3, 4], register));
}
- operation ApplyRepeatedOpTest() : Unit {
+ @Test("QuantumSimulator")
+ operation CheckApplyRepeatedOp() : Unit {
let op = ApplyToFirstThreeQubits(CCNOT, _);
let targets = [[0, 1, 2], [2, 1, 0], [3, 4, 5], [2, 4, 0], [5, 3, 1]];
AssertOperationsEqualReferenced(6, ApplyOpRepeatedlyOver(op, targets, _), SampleApplyRepeatedOp(_));
@@ -49,7 +50,8 @@ namespace Microsoft.Quantum.Tests {
CCNOT(register[5], register[3], register[1]);
}
- operation PermuteQubitsTest() : Unit {
+ @Test("QuantumSimulator")
+ operation CheckPermuteQubits() : Unit {
let sampleOrder = [5, 3, 2, 0, 1, 4];
AssertOperationsEqualReferenced(6, PermuteQubits(sampleOrder, _) , SamplePermuteQubits);
}
diff --git a/Standard/tests/Arithmetic/ReflectionTests.qs b/Standard/tests/Arithmetic/ReflectionTests.qs
index 5002490cd97..7f87f7dfb5f 100644
--- a/Standard/tests/Arithmetic/ReflectionTests.qs
+++ b/Standard/tests/Arithmetic/ReflectionTests.qs
@@ -19,7 +19,8 @@ namespace Microsoft.Quantum.Tests {
ReflectAboutInteger(5, littleEndian);
}
- operation ReflectAboutIntegerTest() : Unit {
+ @Test("QuantumSimulator")
+ operation CheckReflectAboutInteger() : Unit {
AssertOperationsEqualReferenced(3,
ReflectAboutFiveUsingLibrary,
ManuallyReflectAboutFive
diff --git a/Standard/tests/ArithmeticTests.qs b/Standard/tests/ArithmeticTests.qs
index e841a3092c3..e15edf9a6c9 100644
--- a/Standard/tests/ArithmeticTests.qs
+++ b/Standard/tests/ArithmeticTests.qs
@@ -18,9 +18,9 @@ namespace Microsoft.Quantum.ArithmeticTests {
}
}
-
- operation ApplyXorInPlaceTest () : Unit {
-
+ @Test("QuantumSimulator")
+ operation CheckApplyXorInPlace() : Unit {
+
ApplyToEach(InPlaceXorTestHelper, [(63, 6), (42, 6)]);
}
@@ -42,7 +42,7 @@ namespace Microsoft.Quantum.ArithmeticTests {
/// Exhaustively tests Microsoft.Quantum.Artihmetic.IncrementByInteger
/// on 4 qubits
@Test("QuantumSimulator")
- operation IncrementByIntegerTest () : Unit {
+ operation CheckIncrementByInteger() : Unit {
let numberOfQubits = 4;
@@ -86,7 +86,7 @@ namespace Microsoft.Quantum.ArithmeticTests {
/// Tests Microsoft.Quantum.Arithmetic.IncrementByModularInteger
/// on 4 qubits with modulus 13
@Test("QuantumSimulator")
- operation IncrementByModularIntegerTest () : Unit {
+ operation CheckIncrementByModularInteger() : Unit {
let numberOfQubits = 4;
let modulus = 13;
@@ -122,7 +122,7 @@ namespace Microsoft.Quantum.ArithmeticTests {
/// Tests Microsoft.Quantum.Canon.ModularAddProductLE
/// on 4 qubits with modulus 13
@Test("QuantumSimulator")
- operation MultiplyAndAddByModularIntegerTest () : Unit {
+ operation CheckMultiplyAndAddByModularInteger() : Unit {
let numberOfQubits = 4;
let modulus = 13;
@@ -160,7 +160,7 @@ namespace Microsoft.Quantum.ArithmeticTests {
/// Tests Microsoft.Quantum.Canon.ModularMultiplyByConstantLE
/// on 4 qubits with modulus 13
@Test("QuantumSimulator")
- operation MultiplyByModularIntegerTest () : Unit {
+ operation CheckMultiplyByModularInteger() : Unit {
let numberOfQubits = 4;
let modulus = 13;
diff --git a/Standard/tests/ArrayTests.qs b/Standard/tests/ArrayTests.qs
index 5dbadf4d724..71f5ecc8777 100644
--- a/Standard/tests/ArrayTests.qs
+++ b/Standard/tests/ArrayTests.qs
@@ -1,18 +1,19 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Tests {
- open Microsoft.Quantum.Logical;
- open Microsoft.Quantum.Diagnostics;
+ open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Canon;
+ open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Intrinsic;
- open Microsoft.Quantum.Arrays;
+ open Microsoft.Quantum.Logical;
+ open Microsoft.Quantum.Math;
@Test("QuantumSimulator")
- function ZipTest() : Unit {
+ function TestZipped() : Unit {
let left = [1, 2, 101];
let right = [PauliY, PauliI];
- let zipped = Zip(left, right);
+ let zipped = Zipped(left, right);
let (leftActual1, rightActual1) = zipped[0];
if (leftActual1 != 1 or rightActual1 != PauliY) {
@@ -26,9 +27,19 @@ namespace Microsoft.Quantum.Tests {
}
}
+ @Test("QuantumSimulator")
+ function TestUnzipped() : Unit {
+ let first = [6, 5, 5, 3, 2, 1];
+ let second = [true, false, false, false, true, false];
+
+ let (first2, second2) = Unzipped(Zipped(first, second));
+ AllEqualityFactI(first2, first, "Unexpected array of integers");
+ AllEqualityFactB(second2, second, "Unexpected array of Booleans");
+ }
+
@Test("QuantumSimulator")
- function LookupTest () : Unit {
+ function TestLookup() : Unit {
let array = [1, 12, 71, 103];
let fn = LookupFunction(array);
@@ -41,21 +52,21 @@ namespace Microsoft.Quantum.Tests {
}
internal function AllEqualI(expected : Int[], actual : Int[]) : Bool {
- return All(EqualI, Zip(expected, actual));
+ return All(EqualI, Zipped(expected, actual));
}
@Test("QuantumSimulator")
- function ChunksTest() : Unit {
+ function TestChunks() : Unit {
let data = [10, 11, 12, 13, 14, 15];
// 2 Ă 3 case.
- Fact(All(AllEqualI, Zip(
+ Fact(All(AllEqualI, Zipped(
[[10, 11], [12, 13], [14, 15]],
Chunks(2, data)
)), "Wrong chunks in 2x3 case.");
// Case with some leftovers.
- Fact(All(AllEqualI, Zip(
+ Fact(All(AllEqualI, Zipped(
[[10, 11, 12, 13], [14, 15]],
Chunks(4, data)
)), "Wrong chunks in case with leftover elements.");
@@ -65,116 +76,125 @@ namespace Microsoft.Quantum.Tests {
return x * x;
}
-
- function ConstantArrayTest () : Unit {
-
+ @Test("QuantumSimulator")
+ function ConstantArrayOfDoublesIsCorrect() : Unit {
let dblArray = ConstantArray(71, 2.17);
EqualityFactI(Length(dblArray), 71, $"ConstantArray(Int, Double) had the wrong length.");
let ignore = Mapped(NearEqualityFactD(_, 2.17), dblArray);
+ }
+ @Test("QuantumSimulator")
+ function ConstantArrayOfFunctionsIsCorrect() : Unit {
// Stress test by making an array of Int -> Int.
let fnArray = ConstantArray(7, Squared);
EqualityFactI(Length(fnArray), 7, $"ConstantArray(Int, Int -> Int) had the wrong length.");
EqualityFactI(fnArray[3](7), 49, $"ConstantArray(Int, Int -> Int) had the wrong value.");
}
-
- function SubarrayTest () : Unit {
-
+ @Test("QuantumSimulator")
+ function SubarrayIsCorrect () : Unit {
let array0 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let subarrayOdd = Subarray([1, 3, 5, 7, 9], array0);
let subarrayEven = Subarray([0, 2, 4, 6, 8, 10], array0);
Fact(All(IsEven, subarrayEven), $"the even elements of [1..10] were not correctly sliced.");
Fact(not Any(IsEven, subarrayOdd), $"the odd elements of [1..10] were not correctly sliced.");
let array1 = [10, 11, 12, 13];
- Ignore(Mapped(EqualityFactI(_, _, $"Subarray failed: subpermutation case."), Zip([12, 11], Subarray([2, 1], array1))));
+ Ignore(Mapped(EqualityFactI(_, _, $"Subarray failed: subpermutation case."), Zipped([12, 11], Subarray([2, 1], array1))));
}
-
- function FilterTest () : Unit {
-
+ @Test("QuantumSimulator")
+ function FilteredIsEvenHasNoOdds() : Unit {
let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let evenArray = Filtered(IsEven, array);
- EqualityFactB(All(IsEven, evenArray), true, $"the even elements of [1..10] were not correctly filtered.");
+ Fact(All(IsEven, evenArray), $"the even elements of [1..10] were not correctly filtered.");
}
+ @Test("QuantumSimulator")
+ function CountOfIsEvenIsCorrect() : Unit {
+ let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+ let countEvens = Count(IsEven, array);
+ EqualityFactI(countEvens, 5, $"the even elements of [1..10] were not correctly counted.");
+ }
- function ReverseTest () : Unit {
-
+ @Test("QuantumSimulator")
+ function ReversedIsCorrect() : Unit {
let array = [1, 2, 3];
- Ignore(Mapped(EqualityFactI(_, _, $"Reversed failed."), Zip([3, 2, 1], Reversed(array))));
+ Ignore(Mapped(EqualityFactI(_, _, $"Reversed failed."), Zipped([3, 2, 1], Reversed(array))));
}
-
- function ExcludeTest () : Unit {
-
+ @Test("QuantumSimulator")
+ function ExcludingIsCorrect() : Unit {
let array = [10, 11, 12, 13, 14, 15];
- Ignore(Mapped(EqualityFactI(_, _, $"Exclude failed."), Zip([10, 11, 13, 14], Exclude([2, 5], array))));
+ Ignore(Mapped(EqualityFactI(_, _, $"Excluding failed."), Zipped([10, 11, 13, 14], Excluding([2, 5], array))));
}
-
- function PadTest () : Unit {
+ @Test("QuantumSimulator")
+ function PaddedIsCorrect() : Unit {
mutable arrayTestCase = [(-5, 2, [10, 11, 12], [10, 11, 12, 2, 2]), (5, 2, [10, 11, 12], [2, 2, 10, 11, 12]), (-3, -2, [10, 11, 12], [10, 11, 12])];
for (idxTest in IndexRange(arrayTestCase)) {
let (nElementsTotal, defaultElement, inputArray, outputArray) = arrayTestCase[idxTest];
let paddedArray = Padded(nElementsTotal, defaultElement, inputArray);
- Ignore(Mapped(EqualityFactI(_, _, $"Padded failed."), Zip(outputArray, paddedArray)));
+ Ignore(Mapped(EqualityFactI(_, _, $"Padded failed."), Zipped(outputArray, paddedArray)));
}
}
- function EnumeratedTest() : Unit {
+ @Test("QuantumSimulator")
+ function EnumeratedIsCorrect() : Unit {
let example = [37, 12];
let expected = [(0, 37), (1, 12)];
let actual = Enumerated(example);
- for ((actualElement, expectedElement) in Zip(actual, expected)) {
+ for ((actualElement, expectedElement) in Zipped(actual, expected)) {
EqualityFactI(Fst(actualElement), Fst(expectedElement), "Indices did not match.");
EqualityFactI(Snd(actualElement), Snd(expectedElement), "Elements did not match.");
}
}
- function SequenceITest() : Unit {
+ @Test("QuantumSimulator")
+ function SequenceIIsCorrect() : Unit {
let example = [(0, 3), (23, 29), (-5, -2)];
let expected = [[0, 1, 2, 3], [23, 24, 25, 26, 27, 28, 29], [-5, -4, -3, -2]];
let actual = Mapped(SequenceI, example);
- for ((exp, act) in Zip(expected, actual)) {
+ for ((exp, act) in Zipped(expected, actual)) {
EqualityFactI(Length(exp), Length(act), "Lengths of arrays did not match.");
- for ((i, j) in Zip(exp, act)) {
+ for ((i, j) in Zipped(exp, act)) {
EqualityFactI(i, j, "Elements did not match.");
}
}
}
- function SequenceLTest() : Unit {
+ @Test("QuantumSimulator")
+ function SequenceLIsCorrect() : Unit {
let example = [(0L, 3L), (23L, 29L), (-5L, -2L)];
let expected = [[0L, 1L, 2L, 3L], [23L, 24L, 25L, 26L, 27L, 28L, 29L], [-5L, -4L, -3L, -2L]];
let actual = Mapped(SequenceL, example);
- for ((exp, act) in Zip(expected, actual)) {
+ for ((exp, act) in Zipped(expected, actual)) {
EqualityFactI(Length(exp), Length(act), "Lengths of arrays did not match.");
- for ((i, j) in Zip(exp, act)) {
+ for ((i, j) in Zipped(exp, act)) {
EqualityFactL(i, j, "Elements did not match.");
}
}
}
-
- function SequenceForNumbersTest() : Unit {
+ @Test("QuantumSimulator")
+ function SequenceForNumbersIsCorrect() : Unit {
let example = [3, 5, 0];
let expected = [[0, 1, 2, 3], [0, 1, 2, 3, 4, 5], [0]];
let actual = Mapped(SequenceI(0, _), example);
- for ((exp, act) in Zip(expected, actual)) {
+ for ((exp, act) in Zipped(expected, actual)) {
EqualityFactI(Length(exp), Length(act), "Lengths of arrays did not match.");
- for ((i, j) in Zip(exp, act)) {
+ for ((i, j) in Zipped(exp, act)) {
EqualityFactI(i, j, "Elements did not match.");
}
}
}
- function IsEmptyTest() : Unit {
+ @Test("QuantumSimulator")
+ function IsEmptyIsCorrect() : Unit {
Fact(IsEmpty(new Int[0]), "Empty array marked as non-empty.");
Fact(IsEmpty(new Qubit[0]), "Empty array marked as non-empty.");
Fact(IsEmpty(new (Double, (Int -> String))[0]), "Empty array marked as non-empty.");
@@ -182,13 +202,14 @@ namespace Microsoft.Quantum.Tests {
Fact(not IsEmpty([""]), "Non-empty array marked as empty.");
}
- function SwapOrderToPermuteArrayTest() : Unit {
+ @Test("QuantumSimulator")
+ function SwapOrderToPermuteArrayIsCorrect() : Unit {
let newOrder = [0, 4, 2, 1, 3];
let expected = [(1, 4), (1, 3)];
let actual = _SwapOrderToPermuteArray(newOrder);
EqualityFactI(Length(expected), Length(actual), "Number of swaps does not match");
- for ((exp, act) in Zip(expected, actual)) {
+ for ((exp, act) in Zipped(expected, actual)) {
let (leftExp, rightExp) = exp;
let (leftAct, rightAct) = act;
@@ -197,7 +218,8 @@ namespace Microsoft.Quantum.Tests {
}
}
- function SwappedTest() : Unit {
+ @Test("QuantumSimulator")
+ function SwappedIsCorrect() : Unit {
let example = [2, 4, 6, 8, 10];
let expected = [2, 8, 6, 4, 10];
let leftIndex = 1;
@@ -205,26 +227,27 @@ namespace Microsoft.Quantum.Tests {
let newArray = Swapped(leftIndex, rightIndex, example);
EqualityFactI(Length(expected), Length(newArray), "Swapped array is a different size than original");
- for ((exp, act) in Zip(expected, newArray)) {
+ for ((exp, act) in Zipped(expected, newArray)) {
EqualityFactI(exp, act, "Elements did not match");
}
}
- function TupleArrayAsNestedArrayTest() : Unit {
+ @Test("QuantumSimulator")
+ function TupleArrayAsNestedArrayIsCorrect() : Unit {
let example = [(0, 1), (2, 3), (4, 5), (6, 7)];
let expected = [[0, 1], [2, 3], [4, 5], [6, 7]];
let actual = TupleArrayAsNestedArray(example);
EqualityFactI(Length(expected), Length(actual), "Arrays are of different sizes");
- for ((exp, act) in Zip(expected, actual)) {
- for ((elementExp, elementAct) in Zip(exp, act)) {
+ for ((exp, act) in Zipped(expected, actual)) {
+ for ((elementExp, elementAct) in Zipped(exp, act)) {
EqualityFactI(elementExp, elementAct, "Elements did not match");
}
}
}
-
- function EqualATest() : Unit {
+ @Test("QuantumSimulator")
+ function EqualAIsCorrect() : Unit {
// arrays of integers
let equalArrays = EqualA(EqualI, [2, 3, 4], [2, 3, 4]);
Fact(equalArrays, "Equal arrays were not reported as equal");
@@ -237,6 +260,109 @@ namespace Microsoft.Quantum.Tests {
let differentElements = EqualA(EqualR, [One, Zero], [One, One]);
Fact(not differentElements, "Arrays with different elements were reported as equal");
}
-}
+ @Test("QuantumSimulator")
+ operation TestInterleaved() : Unit {
+ AllEqualityFactI(Interleaved([1, 2, 3], [-1, -2, -3]), [1, -1, 2, -2, 3, -3], "Interleaving failed");
+ AllEqualityFactB(Interleaved(ConstantArray(3, false), ConstantArray(2, true)), [false, true, false, true, false], "Interleaving failed");
+ }
+
+ @Test("QuantumSimulator")
+ operation TestCumulativeFolded() : Unit {
+ AllEqualityFactI(CumulativeFolded(PlusI, 0, SequenceI(1, 5)), [1, 3, 6, 10, 15], "CumulativeFolded failed");
+ }
+ @Test("QuantumSimulator")
+ operation TestTransposed() : Unit {
+ for ((actual, expected) in Zipped(Transposed([[1, 2, 3], [4, 5, 6]]), [[1, 4], [2, 5], [3, 6]])) {
+ AllEqualityFactI(actual, expected, "Transposed failed");
+ }
+ }
+
+ @Test("QuantumSimulator")
+ operation TestColumnAt() : Unit {
+ let matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
+ AllEqualityFactI(ColumnAt(0, matrix), [1, 4, 7], "ColumnAt failed");
+ AllEqualityFactI(ColumnAt(1, matrix), [2, 5, 8], "ColumnAt failed");
+ AllEqualityFactI(ColumnAt(2, matrix), [3, 6, 9], "ColumnAt failed");
+ }
+
+ @Test("QuantumSimulator")
+ operation TestElementAt() : Unit {
+ let lucas = [2, 1, 3, 4, 7, 11, 18, 29, 47, 76];
+ let prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29];
+ let fibonacci = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34];
+ let catalan = [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862];
+ let famous2 = Mapped(ElementAt(2, _), [lucas, prime, fibonacci, catalan]);
+ AllEqualityFactI(famous2, [3, 5, 1, 2], "ElementAt failed");
+ }
+
+ @Test("QuantumSimulator")
+ operation TestElementsAt() : Unit {
+ let lucas = [2, 1, 3, 4, 7, 11, 18, 29, 47, 76];
+ let prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29];
+ let fibonacci = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34];
+ let catalan = [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862];
+ let famousOdd = Mapped(ElementsAt(0..2..9, _), [lucas, prime, fibonacci, catalan]);
+ for ((actual, expected) in Zipped(famousOdd, [[2, 3, 7, 18, 47], [2, 5, 11, 17, 23], [0, 1, 3, 8, 21], [1, 2, 14, 132, 1430]])) {
+ AllEqualityFactI(actual, expected, "ElementsAt failed");
+ }
+ }
+
+ @Test("QuantumSimulator")
+ operation TestDiagonal() : Unit {
+ AllEqualityFactI(Diagonal([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [1, 5, 9], "Diagonal failed");
+ AllEqualityFactI(Diagonal([[1, 2, 3], [4, 5, 6]]), [1, 5], "Diagonal failed");
+ AllEqualityFactI(Diagonal([[1, 2], [4, 5], [7, 8]]), [1, 5], "Diagonal failed");
+ }
+
+ @Test("QuantumSimulator")
+ operation TestWindows() : Unit {
+ let EqualIntA = EqualA(EqualI, _, _);
+ let EqualIntAA = EqualA(EqualIntA, _, _);
+
+ Fact(EqualIntAA(Windows(-1, [1, 2, 3]), new Int[][0]), "unexpected windows");
+ Fact(EqualIntAA(Windows(0, [1, 2, 3]), new Int[][0]), "unexpected windows");
+ Fact(EqualIntAA(Windows(1, [1, 2, 3]), [[1], [2], [3]]), "unexpected windows");
+ Fact(EqualIntAA(Windows(2, [1, 2, 3]), [[1, 2], [2, 3]]), "unexpected windows");
+ Fact(EqualIntAA(Windows(3, [1, 2, 3]), [[1, 2, 3]]), "unexpected windows");
+ Fact(EqualIntAA(Windows(4, [1, 2, 3]), new Int[][0]), "unexpected windows");
+ }
+
+ @Test("QuantumSimulator")
+ operation TestPrefixes() : Unit {
+ let array = [0, 1, 1, 2, 3, 5];
+ let prefixes = Prefixes(array);
+
+ EqualityFactI(Length(prefixes), Length(array), "unexpected length for prefixes");
+ AllEqualityFactI(prefixes[0], [0], "unexpected prefix");
+ AllEqualityFactI(prefixes[1], [0, 1], "unexpected prefix");
+ AllEqualityFactI(prefixes[2], [0, 1, 1], "unexpected prefix");
+ AllEqualityFactI(prefixes[3], [0, 1, 1, 2], "unexpected prefix");
+ AllEqualityFactI(prefixes[4], [0, 1, 1, 2, 3], "unexpected prefix");
+ AllEqualityFactI(prefixes[5], [0, 1, 1, 2, 3, 5], "unexpected prefix");
+ }
+
+ @Test("QuantumSimulator")
+ operation TestSuccessfulRectangularFact() : Unit {
+ RectangularArrayFact([[1, 2], [3, 4]], "Array is not rectangular");
+ RectangularArrayFact([[1, 2, 3], [4, 5, 6]], "Array is not rectangular");
+ }
+
+ operation RectangularFactTestShouldFail() : Unit {
+ RectangularArrayFact([[1, 2], [3, 4, 5]], "Array is not rectangular");
+ }
+
+ @Test("QuantumSimulator")
+ operation TestSuccessfulSquareFact() : Unit {
+ SquareArrayFact([[1, 2], [3, 4]], "Array is not a square");
+ }
+
+ operation SquareFact1TestShouldFail() : Unit {
+ SquareArrayFact([[1, 2, 3], [4, 5, 6]], "Array is not a square");
+ }
+
+ operation SquareFact2TestShouldFail() : Unit {
+ SquareArrayFact([[1, 2], [3, 4, 5]], "Array is not a square");
+ }
+}
diff --git a/Standard/tests/Arrays/SortedTests.qs b/Standard/tests/Arrays/SortedTests.qs
new file mode 100644
index 00000000000..a0dbc5fdd37
--- /dev/null
+++ b/Standard/tests/Arrays/SortedTests.qs
@@ -0,0 +1,76 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+namespace Microsoft.Quantum.Arrays {
+ open Microsoft.Quantum.Random;
+ open Microsoft.Quantum.Diagnostics;
+ open Microsoft.Quantum.Logical;
+
+ @Test("QuantumSimulator")
+ function IntsAreSorted() : Unit {
+ Fact(IsSorted(LessThanOrEqualI, [1, 10, 100]), "[1, 10, 100] was marked as unsorted.");
+ }
+
+ @Test("QuantumSimulator")
+ function DoublesAreSorted() : Unit {
+ Fact(IsSorted(LessThanOrEqualD, [1.0, 10.1, 100.2]), "[1.0, 10.1, 100.2] was marked as unsorted.");
+ }
+
+ @Test("QuantumSimulator")
+ function IntsAreNotSorted() : Unit {
+ Contradiction(IsSorted(LessThanOrEqualI, [100, 10, 3]), "[100, 10, 3] was marked as sorted.");
+ }
+
+ @Test("QuantumSimulator")
+ function SortedIntsAreSorted() : Unit {
+ Fact(IsSorted(LessThanOrEqualI,
+ Sorted(LessThanOrEqualI, [100, 10, 3])),
+ "Sorted(<=, [100, 10, 3]) was marked as unsorted."
+ );
+ }
+
+ @Test("QuantumSimulator")
+ function SortedDoublesAreSorted() : Unit {
+ Fact(IsSorted(LessThanOrEqualD,
+ Sorted(LessThanOrEqualD, [100.0, 10.1, 3.14])),
+ "Sorted(<=, [100.0, 10.1, 3.14]) was marked as unsorted."
+ );
+ }
+
+ @Test("QuantumSimulator")
+ operation CheckRandomArraysAreSortedWhenSorted() : Unit {
+ let nItems = 100;
+ let nTrials = 10;
+ let maxItem = 1000;
+ for (_ in 0..nTrials - 1) {
+ let data = DrawMany((DiscreteUniformDistribution(0, maxItem))::Sample, nItems, ());
+ Fact(IsSorted(LessThanOrEqualI, Sorted(LessThanOrEqualI, data)), $"{data} was not sorted after running Sorted.");
+ }
+ }
+
+ @Test("QuantumSimulator")
+ function LexographicSortIsCorrect() : Unit {
+ let arrayComparison = LexographicComparison(LessThanOrEqualI);
+ let data = [
+ [1, 2, 3],
+ [1, 2],
+ [0, 2],
+ [1, 3]
+ ];
+ let sorted = Sorted(arrayComparison, data);
+
+ AllEqualityFactI(
+ sorted[0], [0, 2], "0th item was not correct."
+ );
+ AllEqualityFactI(
+ sorted[1], [1, 2], "1st item was not correct."
+ );
+ AllEqualityFactI(
+ sorted[2], [1, 2, 3], "2nd item was not correct."
+ );
+ AllEqualityFactI(
+ sorted[3], [1, 3], "3rd item was not correct."
+ );
+ }
+
+}
diff --git a/Standard/tests/Arrays/UniqueTests.qs b/Standard/tests/Arrays/UniqueTests.qs
new file mode 100644
index 00000000000..4309359bcf8
--- /dev/null
+++ b/Standard/tests/Arrays/UniqueTests.qs
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+namespace Microsoft.Quantum.Arrays {
+ open Microsoft.Quantum.Diagnostics;
+ open Microsoft.Quantum.Logical;
+
+ @Test("QuantumSimulator")
+ operation UniqueInts() : Unit {
+ AllEqualityFactI(Unique(EqualI, [0, 0, 1, 2, 2, 3, 4, 5, 5, 8, 42, 42, 39]), [0, 1, 2, 3, 4, 5, 8, 42, 39], "Data is not unique");
+ AllEqualityFactI(Unique(EqualI, [0, 1, 1, 0, 0, 1, 1, 0]), [0, 1, 0, 1, 0], "Data is not unique");
+ AllEqualityFactI(Unique(EqualI, Sorted(LessThanOrEqualI, [2, 2, 1, 1, 2, 2, 1, 1])), [1, 2], "Sorted data is not unique");
+ }
+
+ @Test("QuantumSimulator")
+ operation UniqueDoubles() : Unit {
+ let unique = Unique(EqualD, [1.1, 1.1, 2.2, 2.2, 2.2, 3.3, 0.5, 42.0]);
+ EqualityFactI(Length(unique), 5, "Unexpected length of unique data");
+ Fact(unique[0] == 1.1, "Unexpected element in unique data");
+ Fact(unique[1] == 2.2, "Unexpected element in unique data");
+ Fact(unique[2] == 3.3, "Unexpected element in unique data");
+ Fact(unique[3] == 0.5, "Unexpected element in unique data");
+ Fact(unique[4] == 42.0, "Unexpected element in unique data");
+ }
+}
diff --git a/Standard/tests/AssertTests.qs b/Standard/tests/AssertTests.qs
index 30e8eb2ea76..945435f038f 100644
--- a/Standard/tests/AssertTests.qs
+++ b/Standard/tests/AssertTests.qs
@@ -12,7 +12,7 @@ namespace Microsoft.Quantum.Tests {
// with the intent of testing the assert and testing harness mechanisms themselves.
operation EmptyTest() : Unit { }
- operation PreparationTest() : Unit {
+ operation TestPreparation() : Unit {
using (qubit = Qubit()) {
Diag.AssertMeasurementProbability([PauliZ], [qubit], Zero, 1.0, $"Freshly prepared qubit was not in |0âȘ state.", 1E-10);
}
@@ -56,7 +56,8 @@ namespace Microsoft.Quantum.Tests {
/// These tests are already performed in Solid itself, such that
/// this operation tests whether we can reproduce that using our
/// operation equality assertions.
- operation SelfAdjointOperationsTest() : Unit {
+ @Diag.Test("QuantumSimulator")
+ operation TestSelfAdjointOperations() : Unit {
for (op in [I, X, Y, Z, H]) {
Diag.AssertOperationsEqualReferenced(3, ApplyToEach(op, _), ApplyToEachA(op, _));
}
@@ -77,8 +78,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation AssertProbIntTest() : Unit {
+ @Diag.Test("QuantumSimulator")
+ operation TestAssertProbInt() : Unit {
let theta = 0.123;
let prob = 0.015052858190174602;
let tolerance = 1E-09;
@@ -93,8 +94,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation AssertPhaseTest() : Unit {
+ @Diag.Test("QuantumSimulator")
+ operation TestAssertPhase() : Unit {
let phase = 0.456;
let tolerance = 1E-09;
diff --git a/Standard/tests/BitwiseTests.qs b/Standard/tests/BitwiseTests.qs
index f20aca9a954..2dd8401f608 100644
--- a/Standard/tests/BitwiseTests.qs
+++ b/Standard/tests/BitwiseTests.qs
@@ -5,7 +5,8 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Bitwise;
open Microsoft.Quantum.Diagnostics;
- function ShiftTest() : Unit {
+ @Test("QuantumSimulator")
+ function ShiftIsCorrect() : Unit {
let smallValue = 5; // 0b101
EqualityFactI(20, LeftShiftedI(smallValue, 2), "Shifted values incorrect.");
EqualityFactI(2, RightShiftedI(smallValue, 1), "Shifted values incorrect.");
diff --git a/Standard/tests/CombinatorTests.qs b/Standard/tests/CombinatorTests.qs
index 9834abaec41..cf9c7e3d267 100644
--- a/Standard/tests/CombinatorTests.qs
+++ b/Standard/tests/CombinatorTests.qs
@@ -8,14 +8,14 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Arrays;
-
- function ComposeTest () : Unit {
+ @Test("QuantumSimulator")
+ function ComposeIsCorrect() : Unit {
let target = [3, 17, 2];
EqualityFactI((Compose(ModulusI(_, 14), Max))(target), 3, $"Compose(ModulusI(_, 14), Max) did not return expected result.");
}
-
- operation WithTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestWith() : Unit {
let actual = ApplyWith(H, X, _);
let expected = Z;
@@ -25,22 +25,23 @@ namespace Microsoft.Quantum.Tests {
// Make sure that if CurryTest fails, it's because of Curry and not
// something else.
- operation CurryPreTest () : Unit {
+ @Test("QuantumSimulator")
+ operation PreTestCurried() : Unit {
AssertOperationsEqualInPlace(1, Exp([PauliZ], 1.7, _), Exp([PauliZ], 1.7, _));
AssertOperationsEqualReferenced(1, Exp([PauliZ], 1.7, _), Exp([PauliZ], 1.7, _));
}
-
- operation CurryTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestCurried() : Unit {
let curried = CurriedOp(Exp([PauliZ], _, _));
AssertOperationsEqualInPlace(1, curried(1.7), Exp([PauliZ], 1.7, _));
AssertOperationsEqualReferenced(1, curried(1.7), Exp([PauliZ], 1.7, _));
}
-
- operation BindTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestBind() : Unit {
let bound = BoundCA([H, X, H]);
AssertOperationsEqualReferenced(3, ApplyToEach(bound, _), ApplyToEachA(Z, _));
@@ -52,8 +53,8 @@ namespace Microsoft.Quantum.Tests {
return op;
}
-
- operation BindATest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestBindA() : Unit {
let bound = BoundA(Mapped(StripControlled, [T, T]));
AssertOperationsEqualReferenced(3, ApplyToEach(bound, _), ApplyToEachA(S, _));
@@ -80,8 +81,8 @@ namespace Microsoft.Quantum.Tests {
return op;
}
-
- operation BindCTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestBindC() : Unit {
let stripped = Mapped(StripAdjoint, [T, T]);
let bound = BoundC(stripped);
@@ -91,8 +92,8 @@ namespace Microsoft.Quantum.Tests {
AssertOperationsEqualReferenced(6, op, target);
}
-
- operation BindCATest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestBindCA() : Unit {
let bound = BoundCA([T, T]);
AssertOperationsEqualReferenced(3, ApplyToEach(bound, _), ApplyToEachA(S, _));
AssertOperationsEqualReferenced(3, ApplyToEach(Adjoint bound, _), ApplyToEachA(Adjoint S, _));
@@ -101,8 +102,8 @@ namespace Microsoft.Quantum.Tests {
AssertOperationsEqualReferenced(4, op, target);
}
-
- operation OperationPowTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestOperationPow() : Unit {
AssertOperationsEqualReferenced(3, ApplyToEach(OperationPow(H, 2), _), NoOp);
AssertOperationsEqualReferenced(3, ApplyToEach(OperationPow(Z, 2), _), NoOp);
@@ -110,8 +111,8 @@ namespace Microsoft.Quantum.Tests {
AssertOperationsEqualReferenced(3, ApplyToEach(OperationPow(T, 8), _), NoOp);
}
-
- operation ApplyToSubregisterTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyToSubregister() : Unit {
let bigOp = ApplyPauli([PauliI, PauliX, PauliY, PauliZ, PauliI], _);
let smallOp = ApplyPauli([PauliX, PauliY, PauliZ], _);
@@ -134,14 +135,14 @@ namespace Microsoft.Quantum.Tests {
operation CControlledActual (op : (Qubit => Unit), target : Qubit[]) : Unit {
- ApplyToEach(CControlled(op), Zip([true, false, true], target));
+ ApplyToEach(CControlled(op), Zipped([true, false, true], target));
}
operation CControlledActualC (op : (Qubit => Unit is Ctl), target : Qubit[]) : Unit {
body (...) {
- ApplyToEachC(CControlledC(op), Zip([true, false, true], target));
+ ApplyToEachC(CControlledC(op), Zipped([true, false, true], target));
}
controlled distribute;
@@ -151,7 +152,7 @@ namespace Microsoft.Quantum.Tests {
operation CControlledActualA (op : (Qubit => Unit is Adj), target : Qubit[]) : Unit {
body (...) {
- ApplyToEachA(CControlledA(op), Zip([true, false, true], target));
+ ApplyToEachA(CControlledA(op), Zipped([true, false, true], target));
}
adjoint invert;
@@ -161,7 +162,7 @@ namespace Microsoft.Quantum.Tests {
operation CControlledActualCA (op : (Qubit => Unit is Adj + Ctl), target : Qubit[]) : Unit {
body (...) {
- ApplyToEachCA(CControlledCA(op), Zip([true, false, true], target));
+ ApplyToEachCA(CControlledCA(op), Zipped([true, false, true], target));
}
adjoint invert;
@@ -169,8 +170,8 @@ namespace Microsoft.Quantum.Tests {
controlled adjoint distribute;
}
-
- operation CControlledTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestCControlled() : Unit {
AssertOperationsEqualReferenced(3, CControlledActual(H, _), CControlledExpected(H, _));
AssertOperationsEqualReferenced(3, CControlledActual(Z, _), CControlledExpected(Z, _));
@@ -178,7 +179,7 @@ namespace Microsoft.Quantum.Tests {
AssertOperationsEqualReferenced(3, CControlledActual(T, _), CControlledExpected(T, _));
}
-
+ @Test("QuantumSimulator")
operation CControlledTestC () : Unit {
AssertOperationsEqualReferenced(3, CControlledActualC(H, _), CControlledExpected(H, _));
@@ -187,7 +188,7 @@ namespace Microsoft.Quantum.Tests {
AssertOperationsEqualReferenced(3, CControlledActualC(T, _), CControlledExpected(T, _));
}
-
+ @Test("QuantumSimulator")
operation CControlledTestA () : Unit {
AssertOperationsEqualReferenced(3, CControlledActualA(H, _), CControlledExpected(H, _));
@@ -196,7 +197,7 @@ namespace Microsoft.Quantum.Tests {
AssertOperationsEqualReferenced(3, CControlledActualA(T, _), CControlledExpected(T, _));
}
-
+ @Test("QuantumSimulator")
operation CControlledTestCA () : Unit {
AssertOperationsEqualReferenced(3, CControlledActualCA(H, _), CControlledExpected(H, _));
@@ -205,43 +206,50 @@ namespace Microsoft.Quantum.Tests {
AssertOperationsEqualReferenced(3, CControlledActualCA(T, _), CControlledExpected(T, _));
}
- operation ApplyIfZeroTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfZero() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfZero(One, (ApplyToEach(H, _), _)), ApplyToEachA(I, _));
AssertOperationsEqualReferenced(2, ApplyIfZero(Zero, (ApplyToEach(H, _), _)), ApplyToEachA(H, _));
}
- operation ApplyIfOneTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfOne() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfOne(One, (ApplyToEach(H, _), _)), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfOne(Zero, (ApplyToEach(H, _), _)), ApplyToEachA(I, _));
}
-
- operation ApplyIfZeroCTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfZeroC() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfZeroC(One, (ApplyToEachC(H, _), _)), ApplyToEachA(I, _));
AssertOperationsEqualReferenced(2, ApplyIfZeroC(Zero, (ApplyToEachC(H, _), _)), ApplyToEachA(H, _));
}
- operation ApplyIfOneCTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfOneC() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfOneC(One, (ApplyToEachC(H, _), _)), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfOneC(Zero, (ApplyToEachC(H, _), _)), ApplyToEachA(I, _));
}
- operation ApplyIfZeroCATest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfZeroCA() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfZeroCA(One, (ApplyToEachCA(H, _), _)), ApplyToEachA(I, _));
AssertOperationsEqualReferenced(2, ApplyIfZeroCA(Zero, (ApplyToEachCA(H, _), _)), ApplyToEachA(H, _));
}
- operation ApplyIfOneCATest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfOneCA() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfOneCA(One, (ApplyToEachCA(H, _), _)), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfOneCA(Zero, (ApplyToEachCA(H, _), _)), ApplyToEachA(I, _));
}
- operation ApplyIfZeroATest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfZeroA() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfZeroA(One, (ApplyToEachA(H, _), _)), ApplyToEachA(I, _));
AssertOperationsEqualReferenced(2, ApplyIfZeroA(Zero, (ApplyToEachA(H, _), _)), ApplyToEachA(H, _));
}
- operation ApplyIfOneATest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfOneA() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfOneA(One, (ApplyToEachA(H, _), _)), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfOneA(Zero, (ApplyToEachA(H, _), _)), ApplyToEachA(I, _));
}
@@ -254,7 +262,8 @@ namespace Microsoft.Quantum.Tests {
);
}
- operation ApplyIfElseRTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfElseR() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfElseRCase(Zero, _), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfElseRCase(One, _), ApplyToEachA(X, _));
}
@@ -267,7 +276,8 @@ namespace Microsoft.Quantum.Tests {
);
}
- operation ApplyIfElseRATest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfElseRA() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfElseRACase(Zero, _), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfElseRACase(One, _), ApplyToEachA(X, _));
}
@@ -280,7 +290,8 @@ namespace Microsoft.Quantum.Tests {
);
}
- operation ApplyIfElseRCTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfElseRC() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfElseRCCase(Zero, _), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfElseRCCase(One, _), ApplyToEachA(X, _));
}
@@ -293,7 +304,8 @@ namespace Microsoft.Quantum.Tests {
);
}
- operation ApplyIfElseRCATest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfElseRCA() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfElseRCACase(Zero, _), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfElseRCACase(One, _), ApplyToEachA(X, _));
}
@@ -306,7 +318,8 @@ namespace Microsoft.Quantum.Tests {
);
}
- operation ApplyIfElseBTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfElseB() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfElseBCase(true, _), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfElseBCase(false, _), ApplyToEachA(X, _));
}
@@ -319,7 +332,8 @@ namespace Microsoft.Quantum.Tests {
);
}
- operation ApplyIfElseBATest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfElseBA() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfElseBACase(true, _), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfElseBACase(false, _), ApplyToEachA(X, _));
}
@@ -332,7 +346,8 @@ namespace Microsoft.Quantum.Tests {
);
}
- operation ApplyIfElseBCTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfElseBC() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfElseBCCase(true, _), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfElseBCCase(false, _), ApplyToEachA(X, _));
}
@@ -345,7 +360,8 @@ namespace Microsoft.Quantum.Tests {
);
}
- operation ApplyIfElseBCATest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyIfElseBCA() : Unit {
AssertOperationsEqualReferenced(2, ApplyIfElseBCACase(true, _), ApplyToEachA(H, _));
AssertOperationsEqualReferenced(2, ApplyIfElseBCACase(false, _), ApplyToEachA(X, _));
}
@@ -354,7 +370,8 @@ namespace Microsoft.Quantum.Tests {
X(qubits[1]);
}
- operation ApplyToElementTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestApplyToElement() : Unit {
AssertOperationsEqualReferenced(3,
ApplyToElement(X, 1, _),
ApplyXToSecondQubit
diff --git a/Standard/tests/CommonGateTests.qs b/Standard/tests/CommonGateTests.qs
index dbe41666f3f..946f759e836 100644
--- a/Standard/tests/CommonGateTests.qs
+++ b/Standard/tests/CommonGateTests.qs
@@ -17,26 +17,30 @@ namespace Microsoft.Quantum.Tests {
adjoint auto;
}
- operation CXTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestCX() : Unit {
let actual = ApplyCShorthandToRegister(CX, _);
let expected = ApplyControlledOpToRegister(X, _);
AssertOperationsEqualReferenced(2, actual, expected);
}
- operation CYTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestCY() : Unit {
let actual = ApplyCShorthandToRegister(CY, _);
let expected = ApplyControlledOpToRegister(Y, _);
AssertOperationsEqualReferenced(2, actual, expected);
}
- operation CZTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestCZ() : Unit {
let actual = ApplyCShorthandToRegister(CZ, _);
let expected = ApplyControlledOpToRegister(Z, _);
AssertOperationsEqualReferenced(2, actual, expected);
}
// Verify Fermionic SWAP gives the correct qubit values
- operation ApplyFermionicSWAPValueTest() : Unit {
+ @Test("QuantumSimulator")
+ operation CheckApplyFermionicSWAPValue() : Unit {
using ((left, right) = (Qubit(), Qubit())) {
// 00
ApplyFermionicSWAP(left, right);
@@ -69,7 +73,8 @@ namespace Microsoft.Quantum.Tests {
}
// Verify Fermionic SWAP gives the correct phase change
- operation ApplyFermionicSWAPPhaseTest() : Unit {
+ @Test("QuantumSimulator")
+ operation CheckApplyFermionicSWAPPhase() : Unit {
using ((left, right) = (Qubit(), Qubit())) {
// 00
VerifyFermionicSWAPPhaseHelper(Zero, left, right);
diff --git a/Standard/tests/ConversionTests.qs b/Standard/tests/ConversionTests.qs
index b60833f6fb1..328ad1eb322 100644
--- a/Standard/tests/ConversionTests.qs
+++ b/Standard/tests/ConversionTests.qs
@@ -5,14 +5,16 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Convert;
- function ResultArrayAsIntTest () : Unit {
+ @Test("QuantumSimulator")
+ function ResultArrayAsIntIsCorrect() : Unit {
EqualityFactI(ResultArrayAsInt([Zero, Zero]), 0, $"Expected [Zero, Zero] to be represented by 0.");
EqualityFactI(ResultArrayAsInt([One, Zero]), 1, $"Expected [One, Zero] to be represented by 1.");
EqualityFactI(ResultArrayAsInt([Zero, One]), 2, $"Expected [Zero, One] to be represented by 2.");
EqualityFactI(ResultArrayAsInt([One, One]), 3, $"Expected [One, One] to be represented by 3.");
}
- function BoolArrFromPositiveIntTest () : Unit {
+ @Test("QuantumSimulator")
+ function BoolArrFromPositiveIntIsCorrect() : Unit {
for (number in 0 .. 100) {
let bits = IntAsBoolArray(number, 9);
let inte = BoolArrayAsInt(bits);
diff --git a/Standard/tests/EnumerationTests.qs b/Standard/tests/EnumerationTests.qs
index 48e23694f9d..05c32f3e5ed 100644
--- a/Standard/tests/EnumerationTests.qs
+++ b/Standard/tests/EnumerationTests.qs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Math;
@@ -30,42 +30,71 @@ namespace Microsoft.Quantum.Tests {
return a * a;
}
-
- function ForAllTest () : Unit {
+ @Test("QuantumSimulator")
+ function ForAllIsCorrect() : Unit {
EqualityFactB(All(IsSingleDigit, [3, 4, 7, 8]), true, $"the elements [3, 4, 7, 8] were not found to be single digit numbers.");
EqualityFactB(All(IsSingleDigit, [3, 4, 7, 18]), false, $"the elements [3, 4, 7, 18] were found to be single digit numbers.");
}
-
-
- function ForAnyTest () : Unit {
+
+ @Test("QuantumSimulator")
+ function ForAnyIsCorrect() : Unit {
EqualityFactB(Any(IsEven, [3, 7, 99, -4]), true, $"the elements [3, 7, 99, -4] were not found to contain at least one even number.");
EqualityFactB(Any(IsEven, [3, 7, 99, -41]), false, $"the elements [3, 7, 99, -4] were not found to contain at least one even number.");
}
-
- function FoldTest () : Unit {
+ @Test("QuantumSimulator")
+ function FoldIsCorrect() : Unit {
let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
EqualityFactI(Fold(Add, 0, array), 55, $"folding the summation over [1..10] did not yield 55.");
}
-
- function MapTest () : Unit {
+ @Test("QuantumSimulator")
+ function MapIsCorrect() : Unit {
let array = [1, 2, 3, 4];
let squaredArray = Mapped(Squarer, array);
EqualityFactI(Fold(Add, 0, squaredArray), 30, $"the sum of the squares of [1, 2, 3, 4] was not found to be 30.");
}
- function ExtremaTest () : Unit {
+ @Test("QuantumSimulator")
+ function TestMappedOverNonEmptyRange() : Unit {
+ AllEqualityFactI(MappedOverRange(PlusI(_, 2), 1..5), [3, 4, 5, 6, 7], "MappedOverRange failed.");
+ }
+
+ @Test("QuantumSimulator")
+ function TestMappedOverReversedRange() : Unit {
+ AllEqualityFactI(MappedOverRange(TimesI(_, 2), 4..-2..-4), [8, 4, 0, -4, -8], "MappedOverRange failed.");
+ }
+
+ @Test("QuantumSimulator")
+ function TestMappedOverEmpty() : Unit {
+ AllEqualityFactI(MappedOverRange(TimesI(_, 2), 1..-1..2), new Int[0], "MappedOverRange failed.");
+ }
+
+ @Test("QuantumSimulator")
+ function TestFlatMapped() : Unit {
+ let numbers = FlatMapped(SequenceI(1, _), SequenceI(1, 5));
+ AllEqualityFactI(numbers, [1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5], "FlatMapped failed");
+ }
+
+ @Test("QuantumSimulator")
+ function TestFlattened() : Unit {
+ let numbers = Flattened(ConstantArray(3, SequenceI(1, 3)));
+ AllEqualityFactI(numbers, [1, 2, 3, 1, 2, 3, 1, 2, 3], "Flattened failed");
+ }
+
+ @Test("QuantumSimulator")
+ function ExtremaIsCorrect() : Unit {
let array = [-10, 10, 7, 0];
EqualityFactI(-10, Min(array), $"Min failed.");
EqualityFactI(10, Max(array), $"Max failed.");
}
- function IndexOfTest() : Unit {
+ @Test("QuantumSimulator")
+ function IndexOfIsCorrect() : Unit {
let array = [1, 3, 21, -7, 2, 19];
let actual = IndexOf(IsEven, array);
EqualityFactI(4, actual, $"Expected 4, got {actual}.");
diff --git a/Standard/tests/Logical/BooleanTests.qs b/Standard/tests/Logical/BooleanTests.qs
index 9900278fd75..ebc6f73855a 100644
--- a/Standard/tests/Logical/BooleanTests.qs
+++ b/Standard/tests/Logical/BooleanTests.qs
@@ -5,32 +5,37 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Logical;
open Microsoft.Quantum.Diagnostics;
- function NotTest() : Unit {
+ @Test("QuantumSimulator")
+ function NotIsCorrect() : Unit {
Fact(Not(false), "Not returned wrong output.");
}
- function AndTest() : Unit {
+ @Test("QuantumSimulator")
+ function AndIsCorrect() : Unit {
Fact(not And(false, false), "And returned wrong output.");
Fact(not And(false, true), "And returned wrong output.");
Fact(not And(true, false), "And returned wrong output.");
Fact(And(true, true), "And returned wrong output.");
}
- function OrTest() : Unit {
+ @Test("QuantumSimulator")
+ function OrIsCorrect() : Unit {
Fact(not Or(false, false), "Or returned wrong output.");
Fact(Or(false, true), "Or returned wrong output.");
Fact(Or(true, false), "Or returned wrong output.");
Fact(Or(true, true), "Or returned wrong output.");
}
- function XorTest() : Unit {
+ @Test("QuantumSimulator")
+ function XorIsCorrect() : Unit {
Fact(not Xor(false, false), "Xor returned wrong output.");
Fact(Xor(false, true), "Xor returned wrong output.");
Fact(Xor(true, false), "Xor returned wrong output.");
Fact(not Xor(true, true), "Xor returned wrong output.");
}
- function ConditionedTest() : Unit {
+ @Test("QuantumSimulator")
+ function ConditionedIsCorrect() : Unit {
EqualityFactI(Conditioned(true, 42, -1), 42, "Conditioned returned wrong output.");
EqualityFactL(Conditioned(false, 42L, -1L), -1L, "Conditioned returned wrong output.");
}
diff --git a/Standard/tests/Logical/ComparisonTests.qs b/Standard/tests/Logical/ComparisonTests.qs
new file mode 100644
index 00000000000..a426c729396
--- /dev/null
+++ b/Standard/tests/Logical/ComparisonTests.qs
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+namespace Microsoft.Quantum.Tests {
+ open Microsoft.Quantum.Logical;
+ open Microsoft.Quantum.Diagnostics;
+ open Microsoft.Quantum.Math;
+ open Microsoft.Quantum.Arrays;
+
+ @Test("QuantumSimulator")
+ function LexographicComparisonIsCorrect() : Unit {
+ let lexographicComparison = LexographicComparison(LessThanOrEqualD);
+ Fact(
+ lexographicComparison(
+ [1.1, 2.2], [1.1, 2.2, 3.3]
+ ),
+ "Shorter array should have occured first."
+ );
+ Fact(
+ lexographicComparison(
+ [0.7, 2.2], [1.1, 2.2]
+ ),
+ "Array with smaller first element should have occured first."
+ );
+ Fact(
+ lexographicComparison(
+ [1.1, 2.2], [1.1, 2.2]
+ ),
+ "Identical arrays should be marked as less than or equal."
+ );
+ Contradiction(
+ lexographicComparison(
+ [1.1, 2.7], [1.1, 2.2, 3.3]
+ ),
+ "Array with larger second element should have occured second."
+ );
+ }
+
+}
diff --git a/Standard/tests/Logical/PredicateTests.qs b/Standard/tests/Logical/PredicateTests.qs
index 5c970d97e46..b27b3b6936f 100644
--- a/Standard/tests/Logical/PredicateTests.qs
+++ b/Standard/tests/Logical/PredicateTests.qs
@@ -6,7 +6,8 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Math;
- function EqualTest() : Unit {
+ @Test("QuantumSimulator")
+ function EqualIsCorrect() : Unit {
Fact(EqualI(42, 42), "EqualI returned wrong output.");
Fact(not EqualI(42, 73), "EqualI returned wrong output.");
@@ -29,7 +30,8 @@ namespace Microsoft.Quantum.Tests {
Fact(not EqualCP(ComplexPolar(1.0, 2.0), ComplexPolar(1.0, 73.0)), "EqualCP returned wrong output.");
}
- function NotEqualTest() : Unit {
+ @Test("QuantumSimulator")
+ function NotEqualIsCorrect() : Unit {
Fact(not NotEqualI(42, 42), "NotEqualI returned wrong output.");
Fact(NotEqualI(42, 73), "NotEqualI returned wrong output.");
@@ -52,7 +54,8 @@ namespace Microsoft.Quantum.Tests {
Fact(NotEqualCP(ComplexPolar(1.0, 2.0), ComplexPolar(1.0, 73.0)), "NotEqualCP returned wrong output.");
}
- function GreaterThanTest() : Unit {
+ @Test("QuantumSimulator")
+ function GreaterThanIsCorrect() : Unit {
Fact(GreaterThanI(75, 32), "GreaterThanI returned wrong output.");
Fact(not GreaterThanI(-13, 32), "GreaterThanI returned wrong output.");
@@ -63,7 +66,8 @@ namespace Microsoft.Quantum.Tests {
Fact(not GreaterThanL(-13L, 32L), "GreaterThanL returned wrong output.");
}
- function LessThanTest() : Unit {
+ @Test("QuantumSimulator")
+ function LessThanIsCorrect() : Unit {
Fact(not LessThanI(75, 32), "LessThanI returned wrong output.");
Fact(LessThanI(-13, 32), "LessThanI returned wrong output.");
@@ -74,7 +78,8 @@ namespace Microsoft.Quantum.Tests {
Fact(LessThanL(-13L, 32L), "LessThanL returned wrong output.");
}
- function GreaterThanOrEqualTest() : Unit {
+ @Test("QuantumSimulator")
+ function GreaterThanOrEqualIsCorrect() : Unit {
Fact(GreaterThanOrEqualI(75, 75), "GreaterThanOrEqualI returned wrong output.");
Fact(not GreaterThanOrEqualI(-13, 32), "GreaterThanOrEqualI returned wrong output.");
@@ -85,7 +90,8 @@ namespace Microsoft.Quantum.Tests {
Fact(not GreaterThanOrEqualL(-13L, 32L), "GreaterThanOrEqualL returned wrong output.");
}
- function LessThanOrEqualTest() : Unit {
+ @Test("QuantumSimulator")
+ function LessThanOrEqualIsCorrect() : Unit {
Fact(LessThanOrEqualI(75, 75), "LessThanOrEqualI returned wrong output.");
Fact(not LessThanOrEqualI(32, -13), "LessThanOrEqualI returned wrong output.");
@@ -96,10 +102,10 @@ namespace Microsoft.Quantum.Tests {
Fact(not LessThanOrEqualL(32L, -13L), "LessThanOrEqualL returned wrong output.");
}
- function NearlyEqualDTest() : Unit {
+ @Test("QuantumSimulator")
+ function NearlyEqualDIsCorrect() : Unit {
Fact(NearlyEqualD(1.0, 1.0), "Exactly equal numbers marked as not nearly equal.");
Fact(NearlyEqualD(1.0, 1.0 + 1e-15), "Nearly equal numbers marked as not nearly equal.");
Fact(not NearlyEqualD(1.0, 1000.0), "Not nearly equal numbers marked as nearly equal.");
}
-
}
diff --git a/Standard/tests/Math/MathTests.qs b/Standard/tests/Math/MathTests.qs
index 3a8c27b1321..b4fd41dfb35 100644
--- a/Standard/tests/Math/MathTests.qs
+++ b/Standard/tests/Math/MathTests.qs
@@ -6,7 +6,8 @@ namespace Microsoft.Quantum.Canon {
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Arrays;
- function NativeFnsAreCallableTest () : Unit {
+ @Test("QuantumSimulator")
+ function NativeFnsAreCallable () : Unit {
let arg = PI() / 2.0;
NearEqualityFactD(Sin(arg), 1.0);
@@ -16,15 +17,15 @@ namespace Microsoft.Quantum.Canon {
NearEqualityFactD(ArcSin(arcArg), arg);
}
-
- function RealModTest () : Unit {
+ @Test("QuantumSimulator")
+ function RealModIsCorrect () : Unit {
NearEqualityFactD(RealMod(5.5 * PI(), 2.0 * PI(), 0.0), 1.5 * PI());
NearEqualityFactD(RealMod(0.5 * PI(), 2.0 * PI(), -PI() / 2.0), 0.5 * PI());
}
-
- function ArcHyperbolicFnsTest () : Unit {
+ @Test("QuantumSimulator")
+ function ArcHyperbolicFnsAreCorrect () : Unit {
// These tests were generated using NumPy's implementations
// of the inverse hyperbolic functions.
@@ -33,7 +34,6 @@ namespace Microsoft.Quantum.Canon {
NearEqualityFactD(ArcSinh(-0.7), -0.65266656608235574);
}
-
function ExtendedGreatestCommonDivisorITestHelper (a : Int, b : Int, gcd : Int) : Unit {
Message($"Testing {a}, {b}, {gcd} ");
@@ -43,14 +43,15 @@ namespace Microsoft.Quantum.Canon {
EqualityFactI(expected, actual, $"Expected absolute value of gcd to be {expected}, got {actual}");
}
-
- function ExtendedGreatestCommonDivisorITest () : Unit {
+ @Test("QuantumSimulator")
+ function ExtendedGreatestCommonDivisorIIsCorrect () : Unit {
let testTuples = [(1, 1, 1), (1, -1, 1), (-1, 1, 1), (-1, -1, 1), (5, 7, 1), (-5, 7, 1), (3, 15, 3)];
Ignore(Mapped(ExtendedGreatestCommonDivisorITestHelper, testTuples));
}
- function GreatestCommonDivisorLTest() : Unit {
+ @Test("QuantumSimulator")
+ function GreatestCommonDivisorLIsCorrect() : Unit {
EqualityFactL(
GreatestCommonDivisorL(
44958225298979240833230460209285719018635426448048959524915L,
@@ -60,24 +61,22 @@ namespace Microsoft.Quantum.Canon {
"GCD returned wrong result for BigInt inputs."
);
}
-
-
- function BitSizeTest () : Unit {
+ @Test("QuantumSimulator")
+ function BitSizeIsCorrect () : Unit {
EqualityFactI(BitSizeI(3), 2, $"BitSizeI(3) must be 2");
EqualityFactI(BitSizeI(7), 3, $"BitSizeI(7) must be 2");
}
-
- function ExpModTest () : Unit {
+ @Test("QuantumSimulator")
+ function ExpModIsCorrect () : Unit {
// this test is generated using Mathematica PowerMod function
let result = ExpModI(5, 4611686018427387903, 7);
EqualityFactI(result, 6, $"The result must be 6, got {result}");
}
-
-
+
function ContinuedFractionConvergentTestHelper (numerator : Int, denominator : Int) : Unit {
let bitSize = 2 * BitSizeI(denominator);
@@ -86,15 +85,14 @@ namespace Microsoft.Quantum.Canon {
EqualityFactB(AbsI(u) == numerator and AbsI(v) == denominator, true, $"The result must be ±{numerator}/±{denominator} got {u}/{v}");
}
-
function ContinuedFractionConvergentEdgeCaseTestHelper (numerator : Int, denominator : Int, bound : Int) : Unit {
let (num, denom) = (ContinuedFractionConvergentI(Fraction(numerator, denominator), bound))!;
EqualityFactB(AbsI(num) == numerator and AbsI(denom) == denominator, true, $"The result must be ±{numerator}/±{denominator} got {num}/{denom}");
}
-
- function ContinuedFractionConvergentTest () : Unit {
+ @Test("QuantumSimulator")
+ function ContinuedFractionConvergentIsCorrect () : Unit {
let testTuples = [(29, 47), (17, 37), (15, 67)];
Ignore(Mapped(ContinuedFractionConvergentTestHelper, testTuples));
@@ -102,8 +100,8 @@ namespace Microsoft.Quantum.Canon {
Ignore(Mapped(ContinuedFractionConvergentEdgeCaseTestHelper, edgeCaseTestTuples));
}
-
- function ComplexMathTest () : Unit {
+ @Test("QuantumSimulator")
+ function ComplexMathIsCorrect () : Unit {
mutable complexCases = [(0.123, 0.321), (0.123, -0.321), (-0.123, 0.321), (-0.123, -0.321)];
@@ -128,8 +126,8 @@ namespace Microsoft.Quantum.Canon {
}
}
-
- function PNormTest () : Unit {
+ @Test("QuantumSimulator")
+ function PNormIsCorrect () : Unit {
mutable testCases = [
(1.0, [-0.1, 0.2, 0.3], 0.6),
@@ -151,12 +149,10 @@ namespace Microsoft.Quantum.Canon {
}
}
- function SquaredNormTest() : Unit {
+ @Test("QuantumSimulator")
+ function SquaredNormIsCorrect() : Unit {
NearEqualityFactD(SquaredNorm([2.0]), 4.0);
NearEqualityFactD(SquaredNorm([1.0, 1.0]), 2.0);
NearEqualityFactD(SquaredNorm([3.0, 4.0]), 25.0);
}
-
}
-
-
diff --git a/Standard/tests/Math/OperatorFunctionTests.qs b/Standard/tests/Math/OperatorFunctionTests.qs
index 10c36d3eb85..f155ce01dfc 100644
--- a/Standard/tests/Math/OperatorFunctionTests.qs
+++ b/Standard/tests/Math/OperatorFunctionTests.qs
@@ -17,64 +17,67 @@ namespace Microsoft.Quantum.Tests {
function TWO_PI_4_C() : Complex { return ComplexPolarAsComplex(TWO_PI_4_CP()); }
function TWO_PI_4_CP() : ComplexPolar { return ComplexPolar(2.0, PI() / 4.0); }
- // FIXME: expected and actual are flipped uniformly in this file.
- // this has no effect other than making unit test failures slightly
- // harder to read.
-
- function NegationTest() : Unit {
- EqualityFactI(-42, NegationI(42), "NegationI returned wrong output.");
- NearEqualityFactD(-42.0, NegationD(42.0));
- EqualityFactL(-42L, NegationL(42L), "NegationI returned wrong output.");
- NearEqualityFactC(Complex(1.0, 2.0), NegationC(Complex(-1.0, -2.0)));
+ @Test("QuantumSimulator")
+ function NegationIsCorrect() : Unit {
+ EqualityFactI(NegationI(42), -42, "NegationI returned wrong output.");
+ NearEqualityFactD(NegationD(42.0), -42.0);
+ EqualityFactL(NegationL(42L), -42L, "NegationI returned wrong output.");
+ NearEqualityFactC(NegationC(Complex(-1.0, -2.0)), Complex(1.0, 2.0));
NearEqualityFactCP(
- ComplexPolar(1.0, PI() / 4.0),
- NegationCP(ComplexPolar(1.0, 5.0 * PI() / 4.0))
+ NegationCP(ComplexPolar(1.0, 5.0 * PI() / 4.0)),
+ ComplexPolar(1.0, PI() / 4.0)
);
}
- function PlusTest() : Unit {
- EqualityFactI(-40, PlusI(-72, 32), "PlusI returned wrong output.");
- NearEqualityFactD(-40.0, PlusD(-72.0, 32.0));
- EqualityFactL(-40L, PlusL(-72L, 32L), "PlusL returned wrong output.");
- NearEqualityFactC(TWO_C(), PlusC(ONE_C(), ONE_C()));
- NearEqualityFactCP(TWO_CP(), PlusCP(ONE_CP(), ONE_CP()));
+ @Test("QuantumSimulator")
+ function PlusIsCorrect() : Unit {
+ EqualityFactI(PlusI(-72, 32), -40, "PlusI returned wrong output.");
+ NearEqualityFactD(PlusD(-72.0, 32.0), -40.0);
+ EqualityFactL(PlusL(-72L, 32L), -40L, "PlusL returned wrong output.");
+ NearEqualityFactC(PlusC(ONE_C(), ONE_C()), TWO_C());
+ NearEqualityFactCP(PlusCP(ONE_CP(), ONE_CP()), TWO_CP());
}
- function MinusTest() : Unit {
- EqualityFactI(40, MinusI(72, 32), "MinusI returned wrong output.");
- NearEqualityFactD(40.0, MinusD(72.0, 32.0));
- EqualityFactL(40L, MinusL(72L, 32L), "MinusL returned wrong output.");
- NearEqualityFactC(ONE_C(), MinusC(TWO_C(), ONE_C()));
- NearEqualityFactCP(ONE_CP(), MinusCP(TWO_CP(), ONE_CP()));
+ @Test("QuantumSimulator")
+ function MinusIsCorrect() : Unit {
+ EqualityFactI(MinusI(72, 32), 40, "MinusI returned wrong output.");
+ NearEqualityFactD(MinusD(72.0, 32.0), 40.0);
+ EqualityFactL(MinusL(72L, 32L), 40L, "MinusL returned wrong output.");
+ NearEqualityFactC(MinusC(TWO_C(), ONE_C()), ONE_C());
+ NearEqualityFactCP(MinusCP(TWO_CP(), ONE_CP()), ONE_CP());
}
- function TimesTest() : Unit {
- EqualityFactI(40, TimesI(-10, -4), "TimesI returned wrong output.");
- NearEqualityFactD(40.0, TimesD(-10.0, -4.0));
- EqualityFactL(40L, TimesL(-10L, -4L), "TimesL returned wrong output.");
- NearEqualityFactC(TWO_C(), TimesC(TWO_C(), ONE_C()));
- NearEqualityFactCP(TWO_CP(), TimesCP(TWO_CP(), ONE_CP()));
+ @Test("QuantumSimulator")
+ function TimesIsCorrect() : Unit {
+ EqualityFactI(TimesI(-10, -4), 40, "TimesI returned wrong output.");
+ NearEqualityFactD(TimesD(-10.0, -4.0), 40.0);
+ EqualityFactL(TimesL(-10L, -4L), 40L, "TimesL returned wrong output.");
+ NearEqualityFactC(TimesC(TWO_C(), ONE_C()), TWO_C());
+ NearEqualityFactCP(TimesCP(TWO_CP(), ONE_CP()), TWO_CP());
}
- function DivdedByTest() : Unit {
- EqualityFactI(10, DividedByI(-40, -4), "DividedByI returned wrong output.");
- NearEqualityFactD(10.0, DividedByD(-40.0, -4.0));
- EqualityFactL(10L, DividedByL(-40L, -4L), "DividedByL returned wrong output.");
- NearEqualityFactC(PI_4_C(), DividedByC(TWO_PI_4_C(), TWO_C()));
- NearEqualityFactCP(PI_4_CP(), DividedByCP(TWO_PI_4_CP(), TWO_CP()));
+ @Test("QuantumSimulator")
+ function DividedByIsCorrect() : Unit {
+ EqualityFactI(DividedByI(-40, -4), 10, "DividedByI returned wrong output.");
+ NearEqualityFactD(DividedByD(-40.0, -4.0), 10.0);
+ EqualityFactL(DividedByL(-40L, -4L), 10L, "DividedByL returned wrong output.");
+ NearEqualityFactC(DividedByC(TWO_PI_4_C(), TWO_C()), PI_4_C());
+ NearEqualityFactCP(DividedByCP(TWO_PI_4_CP(), TWO_CP()), PI_4_CP());
}
- function ModTest() : Unit {
- EqualityFactI(2, ModI(17, 5), "ModI returned wrong output.");
- EqualityFactL(2L, ModL(17L, 5L), "ModL returned wrong output.");
+ @Test("QuantumSimulator")
+ function ModIsCorrect() : Unit {
+ EqualityFactI(ModI(17, 5), 2, "ModI returned wrong output.");
+ EqualityFactL(ModL(17L, 5L), 2L, "ModL returned wrong output.");
}
- function PowTest() : Unit {
- EqualityFactI(6561, PowI(3, 8), "PowI returned wrong output.");
- NearEqualityFactD(157.58648490814928441592231285347, PowD(2.0, 7.3));
- EqualityFactL(239072435685151324847153L, PowL(17L, 19), "PowL returned wrong output.");
- NearEqualityFactC(PI_2_C(), PowC(PI_4_C(), TWO_C()));
- NearEqualityFactCP(PI_2_CP(), PowCP(PI_4_CP(), TWO_CP()));
+ @Test("QuantumSimulator")
+ function PowIsCorrect() : Unit {
+ EqualityFactI(PowI(3, 8), 6561, "PowI returned wrong output.");
+ NearEqualityFactD(PowD(2.0, 7.3), 157.58648490814928441592231285347);
+ EqualityFactL(PowL(17L, 19), 239072435685151324847153L, "PowL returned wrong output.");
+ NearEqualityFactC(PowC(PI_4_C(), TWO_C()), PI_2_C());
+ NearEqualityFactCP(PowCP(PI_4_CP(), TWO_CP()), PI_2_CP());
}
}
diff --git a/Standard/tests/Measurement/ResetTests.qs b/Standard/tests/Measurement/ResetTests.qs
index 45056d785e2..aaf98e2cc60 100644
--- a/Standard/tests/Measurement/ResetTests.qs
+++ b/Standard/tests/Measurement/ResetTests.qs
@@ -6,7 +6,7 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Diagnostics;
- operation CheckSetToBasisState(desired : Result) : Unit {
+ operation CheckSetToBasisStateHelper(desired : Result) : Unit {
using (q = Qubit()) {
Ry(0.1234, q);
SetToBasisState(desired, q);
@@ -15,9 +15,10 @@ namespace Microsoft.Quantum.Tests {
}
}
- operation SetToBasisStateTest() : Unit {
+ @Test("QuantumSimulator")
+ operation CheckSetToBasisState() : Unit {
for (desired in [Zero, One]) {
- CheckSetToBasisState(desired);
+ CheckSetToBasisStateHelper(desired);
}
}
diff --git a/Standard/tests/MultiplexerTests.qs b/Standard/tests/MultiplexerTests.qs
index 9e166c30956..f23a680eb9a 100644
--- a/Standard/tests/MultiplexerTests.qs
+++ b/Standard/tests/MultiplexerTests.qs
@@ -147,8 +147,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation ApplyDiagonalUnitaryTest () : Unit {
+ @Diag.Test("QuantumSimulator")
+ operation TestApplyDiagonalUnitary() : Unit {
let maxQubits = 4;
@@ -331,8 +331,8 @@ namespace Microsoft.Quantum.Tests {
return result;
}
-
- operation MultiplexOperationsTest () : Unit {
+ @Diag.Test("QuantumSimulator")
+ operation TestMultiplexOperations() : Unit {
mutable result = Zero;
@@ -505,7 +505,8 @@ namespace Microsoft.Quantum.Tests {
}
}
- operation MultiplexOperationsFromGeneratorTest() : Unit{
+ @Diag.Test("QuantumSimulator")
+ operation TestMultiplexOperationsFromGenerator() : Unit{
body (...) {
mutable result = Zero;
diff --git a/Standard/tests/Optimization/UnivariateTests.qs b/Standard/tests/Optimization/UnivariateTests.qs
index 73301bcb343..d43d988e53e 100644
--- a/Standard/tests/Optimization/UnivariateTests.qs
+++ b/Standard/tests/Optimization/UnivariateTests.qs
@@ -10,8 +10,8 @@ namespace Microsoft.Quantum.Tests {
return PowD((x - minima), 2.0);
}
- // @Test("QuantumSimulator")
- function MinimizedParabolaTest() : Unit {
+ @Test("QuantumSimulator")
+ function MinimizedParabolaIsCorrect() : Unit {
let optimum = LocalUnivariateMinimum(ParabolaCase(3.14, _), (-7.0, +12.0), 1e-10);
NearEqualityFactD(optimum::Coordinate, 3.14);
NearEqualityFactD(optimum::Value, 0.0);
diff --git a/Standard/tests/PairTests.qs b/Standard/tests/PairTests.qs
index 0f70826bbcd..e4dca98a3e6 100644
--- a/Standard/tests/PairTests.qs
+++ b/Standard/tests/PairTests.qs
@@ -3,9 +3,10 @@
namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Canon;
+ open Microsoft.Quantum.Diagnostics;
-
- function PairTest () : Unit {
+ @Test("QuantumSimulator")
+ function PairIsCorrect() : Unit {
let pair = (12, PauliZ);
diff --git a/Standard/tests/PauliTests.qs b/Standard/tests/PauliTests.qs
index e2911973dec..a60e8447b31 100644
--- a/Standard/tests/PauliTests.qs
+++ b/Standard/tests/PauliTests.qs
@@ -5,9 +5,10 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Measurement;
-
-
- operation MeasureWithScratchTest () : Unit {
+ open Microsoft.Quantum.Diagnostics;
+
+ @Test("QuantumSimulator")
+ operation TestMeasureWithScratch() : Unit {
using (register = Qubit[2]) {
PrepareEntangledState([register[0]], [register[1]]);
diff --git a/Standard/tests/QFTTests.qs b/Standard/tests/QFTTests.qs
index 40be1c455fe..e0eeee11696 100644
--- a/Standard/tests/QFTTests.qs
+++ b/Standard/tests/QFTTests.qs
@@ -93,7 +93,8 @@ namespace Microsoft.Quantum.Tests {
/// # Summary
/// Compares QFT to the hard-coded implementations
- operation QFTTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestQFT() : Unit {
let testFunctions = [QFT1, QFT2, QFT3, QFT4];
for (i in IndexRange(testFunctions)) {
diff --git a/Standard/tests/QcvvTests.qs b/Standard/tests/QcvvTests.qs
index bb7a85ccced..cbc35f9bbe4 100644
--- a/Standard/tests/QcvvTests.qs
+++ b/Standard/tests/QcvvTests.qs
@@ -12,7 +12,8 @@ namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Measurement as Meas;
- operation ChoiStateTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestChoiState() : Unit {
using (register = Qubit[2]) {
PrepareChoiStateCA(NoOp, [register[0]], [register[1]]);
@@ -28,7 +29,8 @@ namespace Microsoft.Quantum.Tests {
Message("stage prepared");
}
- operation EstimateFrequencyTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestEstimateFrequency() : Unit {
let freq1 = EstimateFrequency(ApplyToEach(H, _), Meas.MeasureAllZ, 1, 1000);
EqualityWithinToleranceFact(freq1, 0.5, 0.1);
@@ -55,7 +57,8 @@ namespace Microsoft.Quantum.Tests {
EqualityWithinToleranceFact(expectation, actualFreq, tolerance);
}
- operation EstimateFrequencyBinomialTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestEstimateFrequencyBinomial() : Unit {
// If this is larger, tests fail less often, but more false negatives
// slip through.
let nStdDevs = 3.0;
@@ -98,7 +101,8 @@ namespace Microsoft.Quantum.Tests {
}
// Probabilistic test. Might fail occasionally
- operation RobustPhaseEstimationTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestRobustPhaseEstimation() : Unit {
let bitsPrecision = 10;
@@ -109,8 +113,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation PrepareQubitTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestPrepareQubit() : Unit {
using (qubit = Qubit()) {
let bases = [PauliI, PauliX, PauliY, PauliZ];
@@ -122,7 +126,8 @@ namespace Microsoft.Quantum.Tests {
}
}
- operation SingleQubitProcessTomographyMeasurementTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestSingleQubitProcessTomographyMeasurement() : Unit {
EqualityFactR(SingleQubitProcessTomographyMeasurement(PauliI, PauliI, H), Zero, $"Failed at âȘI | H | Iâ«.");
EqualityFactR(SingleQubitProcessTomographyMeasurement(PauliX, PauliI, H), Zero, $"Failed at âȘI | H | Xâ«.");
EqualityFactR(SingleQubitProcessTomographyMeasurement(PauliY, PauliI, H), Zero, $"Failed at âȘI | H | Yâ«.");
diff --git a/Standard/tests/QeccTests.qs b/Standard/tests/QeccTests.qs
index ed2670db7bb..8827115e78e 100644
--- a/Standard/tests/QeccTests.qs
+++ b/Standard/tests/QeccTests.qs
@@ -57,7 +57,8 @@ namespace Microsoft.Quantum.Tests {
/// # Summary
/// Ensures that the bit flip code can correct a single arbitrary
/// bit-flip ($X$) error.
- operation BitFlipTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestBitFlip() : Unit {
let code = BitFlipCode();
let fn = BitFlipRecoveryFn();
@@ -71,7 +72,8 @@ namespace Microsoft.Quantum.Tests {
/// # Summary
/// Ensures that the 5-qubit perfect code can correct an arbitrary
/// single-qubit error.
- operation FiveQubitCodeTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestFiveQubitCode() : Unit {
let code = FiveQubitCode();
let fn = FiveQubitCodeRecoveryFn();
@@ -83,7 +85,8 @@ namespace Microsoft.Quantum.Tests {
// TODO: split this test up into several smaller tests.
- operation FiveQubitTediousTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestFiveQubitTedious() : Unit {
let s = SyndromeMeasOp(MeasureStabilizerGenerators([[PauliX, PauliZ, PauliZ, PauliX, PauliI], [PauliI, PauliX, PauliZ, PauliZ, PauliX], [PauliX, PauliI, PauliX, PauliZ, PauliZ], [PauliZ, PauliX, PauliI, PauliX, PauliZ]], _, MeasureWithScratch));
@@ -164,8 +167,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation FiveQubitTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestFiveQubit() : Unit {
let s = SyndromeMeasOp(MeasureStabilizerGenerators([[PauliX, PauliZ, PauliZ, PauliX, PauliI], [PauliI, PauliX, PauliZ, PauliZ, PauliX], [PauliX, PauliI, PauliX, PauliZ, PauliZ], [PauliZ, PauliX, PauliI, PauliX, PauliZ]], _, MeasureWithScratch));
@@ -212,8 +215,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation SteaneCodeEncoderTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestSteaneCodeEncoder() : Unit {
using (aux = Qubit[7]) {
SteaneCodeEncoderImpl(aux[0 .. 0], aux[1 .. 6]);
@@ -246,8 +249,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation Pi4YInjectionTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestPi4YInjection() : Unit {
using (anc = Qubit[2]) {
@@ -266,8 +269,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation Pi4YInjectionAdjointTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestPi4YInjectionAdjoint() : Unit {
using (anc = Qubit[2]) {
@@ -290,7 +293,8 @@ namespace Microsoft.Quantum.Tests {
/// # Summary
/// Applies logical operators before and after the encoding circuit,
/// that as a whole acts as identity.
- operation KDLogicalOperatorTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestKDLogicalOperator() : Unit {
using (anc = Qubit[7]) {
X(anc[0]);
@@ -317,8 +321,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation KDSyndromeTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestKDSyndrome() : Unit {
using (anc = Qubit[7]) {
@@ -339,8 +343,8 @@ namespace Microsoft.Quantum.Tests {
}
}
-
- operation KnillDistillationNoErrorTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestKnillDistillationNoError() : Unit {
using (register = Qubit[15]) {
@@ -363,7 +367,8 @@ namespace Microsoft.Quantum.Tests {
/// Here we do not attempt to correct detected errors,
/// since corrections would make the output magic state
/// less accurate, compared to post-selection on zero syndrome.
- operation KDTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestKD() : Unit {
using (rm = Qubit[15]) {
ApplyToEach(Ry(PI() / 4.0, _), rm);
@@ -446,7 +451,8 @@ namespace Microsoft.Quantum.Tests {
/// # Summary
/// Ensures that the 7-qubit Steane code can correct an arbitrary
/// single-qubit error.
- operation SteaneCodeTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestSteaneCode() : Unit {
let code = SteaneCode();
let (fnX, fnZ) = SteaneCodeRecoveryFns();
diff --git a/Standard/tests/QuantumPhaseEstimationTests.qs b/Standard/tests/QuantumPhaseEstimationTests.qs
index 352839d20c7..e4c9f4e1f9f 100644
--- a/Standard/tests/QuantumPhaseEstimationTests.qs
+++ b/Standard/tests/QuantumPhaseEstimationTests.qs
@@ -14,7 +14,8 @@ namespace Microsoft.Quantum.Tests {
/// Assert that the QuantumPhaseEstimation operation for the T gate
/// return 0000 in the controlRegister when targetState is 0 and
/// return 0010 when the targetState is 1
- operation QuantumPhaseEstimationTest () : Unit {
+ @Test("QuantumSimulator")
+ operation TestQuantumPhaseEstimation() : Unit {
let oracle = DiscreteOracle(ApplyTOracle);
diff --git a/Standard/tests/QubitizationTests.qs b/Standard/tests/QubitizationTests.qs
index ef418797699..1e625c7da07 100644
--- a/Standard/tests/QubitizationTests.qs
+++ b/Standard/tests/QubitizationTests.qs
@@ -25,7 +25,8 @@ namespace Microsoft.Quantum.Tests {
}
// This checks that BlockEncodingByLCU encodes the correct Hamiltonian.
- operation BlockEncodingByLCUTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestBlockEncodingByLCU() : Unit {
body (...) {
let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper();
let LCU = BlockEncodingByLCU(statePreparation, selector);
@@ -48,7 +49,8 @@ namespace Microsoft.Quantum.Tests {
}
// This checks that BlockEncodingReflectionByLCU encodes the correct Hamiltonian.
- operation BlockEncodingReflectionByLCUTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestBlockEncodingReflectionByLCU() : Unit {
body (...) {
let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper();
let LCU = BlockEncodingReflectionByLCU(statePreparation, selector);
@@ -74,7 +76,8 @@ namespace Microsoft.Quantum.Tests {
}
// This checks that QuantumWalkByQubitization encodes the correct Hamiltonian.
- operation QuantumWalkByQubitizationTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestQuantumWalkByQubitization() : Unit {
body (...) {
let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper();
let LCU = QuantumWalkByQubitization(BlockEncodingReflectionByLCU(statePreparation, selector));
@@ -101,7 +104,8 @@ namespace Microsoft.Quantum.Tests {
// QubitizationPauliEvolutionSet.qs tests
// This encodes the Hamiltonian (cos^2(angle) I+sin^2(angle) X)/2.
- operation PauliBlockEncodingLCUTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestPauliBlockEncodingLCU() : Unit {
body (...) {
let angle = 0.123;
let cosSquared = Cos(angle) * Cos(angle);
@@ -135,7 +139,8 @@ namespace Microsoft.Quantum.Tests {
}
// Array.qs tests
- function RangeAsIntArrayTest() : Unit {
+ @Test("QuantumSimulator")
+ function TestRangeAsIntArray() : Unit {
mutable testCases = new (Int[], Range)[4];
let e = new Int[0];
set testCases w/= 0 <- ([1, 3, 5, 7], 1..2..8);
@@ -145,11 +150,12 @@ namespace Microsoft.Quantum.Tests {
for (idxTest in IndexRange(testCases)) {
let (expected, range) = testCases[idxTest];
let output = RangeAsIntArray(range);
- Ignore(Mapped(EqualityFactI(_, _, "Padded failed."), Zip(output, expected)));
+ Ignore(Mapped(EqualityFactI(_, _, "Padded failed."), Zipped(output, expected)));
}
}
- operation InPlaceMajorityTest() : Unit {
+ @Test("QuantumSimulator")
+ operation TestInPlaceMajority() : Unit {
body (...) {
// Majority function truth table: x;y;z | output
let testCases = [[false, false, false, false],
@@ -183,7 +189,8 @@ namespace Microsoft.Quantum.Tests {
}
}
- operation ApplyRippleCarryComparatorTest() : Unit{
+ @Test("QuantumSimulator")
+ operation TestApplyRippleCarryComparator() : Unit{
body (...) {
let nQubits = 4;
let intMax = 2^nQubits-1;
diff --git a/Standard/tests/Standard.Tests.csproj b/Standard/tests/Standard.Tests.csproj
index 5bf903caf46..0e9be961006 100644
--- a/Standard/tests/Standard.Tests.csproj
+++ b/Standard/tests/Standard.Tests.csproj
@@ -1,4 +1,4 @@
-
+
diff --git a/Standard/tests/StatePreparationTests.qs b/Standard/tests/StatePreparationTests.qs
index 4bc491db155..c236326b5c4 100644
--- a/Standard/tests/StatePreparationTests.qs
+++ b/Standard/tests/StatePreparationTests.qs
@@ -14,7 +14,6 @@ namespace Microsoft.Quantum.Tests {
// number of qubits, abs(amplitude), phase
newtype StatePreparationTestCase = (Int, Double[], Double[]);
-
@Diag.Test("QuantumSimulator")
operation TestStatePreparationPositiveCoefficients() : Unit {
@@ -39,35 +38,35 @@ namespace Microsoft.Quantum.Tests {
// Test missing coefficients
StatePreparationTestCase(3, [1.0986553, 0.359005, 0.465689, -0.467395, 0.419893, 0.118445], new Double[0])
];
-
+
// Loop over multiple qubit tests
for (testCase in testCases) {
let (nQubits, coefficientsAmplitude, coefficientsPhase) = testCase!;
let nCoefficients = Length(coefficientsAmplitude);
-
+
// Test negative coefficients. Should give same results as positive coefficients
using (qubits = Qubit[nQubits]) {
let qubitsLE = LittleEndian(qubits);
let op = StatePreparationPositiveCoefficients(coefficientsAmplitude);
op(qubitsLE);
let normalizedCoefficients = PNormalized(2.0, coefficientsAmplitude);
-
+
for (idxCoeff in IndexRange(coefficientsAmplitude)) {
let amp = normalizedCoefficients[idxCoeff];
let prob = amp * amp;
AssertProbInt(idxCoeff, prob, qubitsLE, tolerance);
}
-
+
ResetAll(qubits);
}
}
}
-
-
+
+
// Test phase factor on 1-qubit uniform superposition.
@Diag.Test("QuantumSimulator")
operation TestStatePreparationComplexCoefficientsQubitPhase() : Unit {
-
+
let tolerance = 1E-09;
let testCases = [
@@ -75,17 +74,17 @@ namespace Microsoft.Quantum.Tests {
StatePreparationTestCase(1, [1.0, 1.0], [0.01, -0.01]),
StatePreparationTestCase(1, [1.0, 1.0], [0.01, -0.05])
];
-
+
// Loop over tests
for (testCase in testCases) {
let (nQubits, coefficientsAmplitude, coefficientsPhase) = testCase!;
let nCoefficients = Length(coefficientsAmplitude);
-
+
using (qubits = Qubit[nQubits]) {
let qubitsLE = LittleEndian(qubits);
let coefficients = Mapped(ComplexPolar, Zip(coefficientsAmplitude, coefficientsPhase));
let normalizedCoefficients = PNormalized(2.0, coefficientsAmplitude);
-
+
// Test phase factor on uniform superposition
let phase = 0.5 * (coefficientsPhase[0] - coefficientsPhase[1]);
let amp = normalizedCoefficients[0];
@@ -99,12 +98,12 @@ namespace Microsoft.Quantum.Tests {
}
}
}
-
-
+
+
// Test probabilities and phases factor of multi-qubit uniform superposition.
@Diag.Test("QuantumSimulator")
operation TestStatePreparationComplexCoefficientsMultiQubitPhase() : Unit {
-
+
let tolerance = 1E-09;
let testCases = [
@@ -115,36 +114,36 @@ namespace Microsoft.Quantum.Tests {
StatePreparationTestCase(3, [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01]),
StatePreparationTestCase(3, [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], [1.0986553, 0.359005, 0.465689, -0.467395, 0.419893, 0.118445, 0.461883, 0.149609])
];
-
+
// Loop over tests
for (testCase in testCases) {
let (nQubits, coefficientsAmplitude, coefficientsPhase) = testCase!;
let nCoefficients = Length(coefficientsAmplitude);
-
+
using (qubits = Qubit[nQubits]) {
let qubitsLE = LittleEndian(qubits);
let coefficients = Mapped(ComplexPolar, Zip(coefficientsAmplitude, coefficientsPhase));
let normalizedCoefficients = PNormalized(2.0, coefficientsAmplitude);
-
+
// Test probability and phases of uniform superposition
let op = StatePreparationComplexCoefficients(coefficients);
-
+
using (control = Qubit[1]) {
-
+
// Test probability
H(control[0]);
Controlled op(control, qubitsLE);
X(control[0]);
Controlled (ApplyToEachCA(H, _))(control, qubitsLE!);
X(control[0]);
-
+
for ((idxCoeff, amp) in Enumerated(normalizedCoefficients)) {
let prob = amp * amp;
AssertProbInt(idxCoeff, prob, qubitsLE, tolerance);
}
-
+
ResetAll(control + qubits);
-
+
//Test phase
for (repeats in 0 .. nCoefficients / 2) {
H(control[0]);
@@ -162,12 +161,12 @@ namespace Microsoft.Quantum.Tests {
}
}
}
-
-
+
+
// Test probabilities and phases of arbitrary multi-qubit superposition.
@Diag.Test("QuantumSimulator")
operation TestStatePreparationComplexCoefficientsArbitraryMultiQubitPhase() : Unit {
-
+
let tolerance = 1E-09;
let testCases = [
@@ -175,37 +174,37 @@ namespace Microsoft.Quantum.Tests {
StatePreparationTestCase(2, [1.0986553, 0.359005, -0.123, 9.238], [0.419893, 0.118445, -0.467395, 0.419893]),
StatePreparationTestCase(3, [1.0986553, 0.359005, 0.465689, 0.467395, 0.419893, 0.118445, 0.123, 9.238], [1.0986553, 0.359005, 0.465689, -0.467395, 0.419893, 0.118445, 0.461883, 0.149609])
];
-
+
// Loop over tests
for (testCase in testCases) {
let (nQubits, coefficientsAmplitude, coefficientsPhase) = testCase!;
let nCoefficients = Length(coefficientsAmplitude);
-
+
using (qubits = Qubit[nQubits]) {
let qubitsLE = LittleEndian(qubits);
let coefficients = Mapped(ComplexPolar, Zip(coefficientsAmplitude, coefficientsPhase));
let normalizedCoefficients = PNormalized(2.0, coefficientsAmplitude);
-
+
// Test probability and phases of arbitrary superposition
let opComplex = StatePreparationComplexCoefficients(coefficients);
let opReal = StatePreparationPositiveCoefficients(coefficientsAmplitude);
-
+
using (control = Qubit[1]) {
-
+
// Test probability
H(control[0]);
Controlled opComplex(control, qubitsLE);
X(control[0]);
Controlled opReal(control, qubitsLE);
X(control[0]);
-
+
for ((idxCoeff, amp) in Enumerated(normalizedCoefficients)) {
let prob = amp * amp;
AssertProbInt(idxCoeff, prob, qubitsLE, tolerance);
}
-
+
ResetAll(control + qubits);
-
+
// Test phase
for (repeats in 0 .. nCoefficients / 2) {
H(control[0]);
diff --git a/Standard/tests/TypeConversionTests.qs b/Standard/tests/TypeConversionTests.qs
index 669d78d7f6d..5c6f7c07f4a 100644
--- a/Standard/tests/TypeConversionTests.qs
+++ b/Standard/tests/TypeConversionTests.qs
@@ -14,11 +14,13 @@ namespace Microsoft.Quantum.Tests {
return op(input);
}
- operation CallTest() : Unit {
+ @Test("ToffoliSimulator")
+ operation TestCall() : Unit {
EqualityFactI(Call(Square, 4), 16, "Call failed with Square.");
}
- operation ToOperationTest() : Unit {
+ @Test("ToffoliSimulator")
+ operation TestToOperation() : Unit {
let op = FunctionAsOperation(Square);
EqualityFactI(ApplyOp(op, 3), 9, "ToOperation failed with Square.");
}
diff --git a/Visualization/src/Visualization.csproj b/Visualization/src/Visualization.csproj
index cf3f41e5537..f148ebf7929 100644
--- a/Visualization/src/Visualization.csproj
+++ b/Visualization/src/Visualization.csproj
@@ -32,9 +32,9 @@
-
+
-
+
diff --git a/build.yml b/build.yml
index 10d43034934..2d78da0bab9 100644
--- a/build.yml
+++ b/build.yml
@@ -2,9 +2,14 @@
# Build configuration file to run build on azure-pipelines
#
name: $(Build.Major).$(Build.Minor).$(date:yyMM).$(DayOfMonth)$(rev:rr)
-trigger:
-- master
+
+trigger: none
+
+pr:
+- main
- feature/*
+- features/*
+- release/*
variables:
Build.Major: 0
diff --git a/sync.cmd b/sync.cmd
index b0b089f4319..396148cc7b2 100644
--- a/sync.cmd
+++ b/sync.cmd
@@ -3,7 +3,7 @@
:: the public repository (https://github.com/Microsoft/Quantum.git)
::
set branch=%1
-IF "%branch%" == "" SET branch=master
+IF "%branch%" == "" SET branch=main
git fetch origin
git fetch public || call :addPublic