Removing pending warnings from tests (#101)
This commit is contained in:
Родитель
85d18f42fd
Коммит
864821e65b
|
@ -188,7 +188,7 @@ namespace Microsoft.Quantum.Canon {
|
|||
/// Please use @"Microsoft.Quantum.Arithmetic.MultiplyAndAddByModularInteger".
|
||||
operation ModularAddProductLE (constMultiplier : Int, modulus : Int, multiplier : LittleEndian, summand : LittleEndian) : Unit {
|
||||
body (...) {
|
||||
_Renamed("Microsoft.Quantum.Canon.ModularIncrementPhaseLE", "Microsoft.Quantum.Arithmetic.MultiplyAndAddByModularInteger");
|
||||
_Renamed("Microsoft.Quantum.Canon.ModularAddProductLE", "Microsoft.Quantum.Arithmetic.MultiplyAndAddByModularInteger");
|
||||
MultiplyAndAddByModularInteger(constMultiplier, modulus, multiplier, summand);
|
||||
}
|
||||
adjoint auto;
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace Microsoft.Quantum.Canon {
|
|||
/// - Microsoft.Quantum.Canon.ApplyQuantumFourierTransformBE
|
||||
operation QFT(qs : BigEndian) : Unit {
|
||||
body (...) {
|
||||
ApplyQuantumFourierTransformBE(qs);
|
||||
ApplyQuantumFourierTransform(BigEndianAsLittleEndian(qs));
|
||||
}
|
||||
|
||||
adjoint invert;
|
||||
|
|
|
@ -25,12 +25,12 @@ namespace Microsoft.Quantum.Tests {
|
|||
}
|
||||
|
||||
|
||||
operation IntegerIncrementLETestHelper (summand1 : Int, summand2 : Int, numberOfQubits : Int) : Unit {
|
||||
operation IncrementByIntegerTestHelper (summand1 : Int, summand2 : Int, numberOfQubits : Int) : Unit {
|
||||
|
||||
using (register = Qubit[numberOfQubits]) {
|
||||
let registerLE = LittleEndian(register);
|
||||
ApplyXorInPlace(summand1, registerLE);
|
||||
IntegerIncrementLE(summand2, registerLE);
|
||||
IncrementByInteger(summand2, registerLE);
|
||||
let expected = ModulusI(summand1 + summand2, 2 ^ numberOfQubits);
|
||||
let actual = MeasureInteger(registerLE);
|
||||
EqualityFactI(expected, actual, $"Expected {expected}, got {actual}");
|
||||
|
@ -39,40 +39,40 @@ namespace Microsoft.Quantum.Tests {
|
|||
|
||||
|
||||
/// # Summary
|
||||
/// Exhaustively tests Microsoft.Quantum.Canon.IntegerIncrementLE
|
||||
/// Exhaustively tests Microsoft.Quantum.Artihmetic.IncrementByInteger
|
||||
/// on 4 qubits
|
||||
operation IntegerIncrementLETest () : Unit {
|
||||
operation IncrementByIntegerTest () : Unit {
|
||||
|
||||
let numberOfQubits = 4;
|
||||
|
||||
for (summand1 in 0 .. 2 ^ numberOfQubits - 1) {
|
||||
|
||||
for (summand2 in -2 ^ numberOfQubits .. 2 ^ numberOfQubits) {
|
||||
IntegerIncrementLETestHelper(summand1, summand2, numberOfQubits);
|
||||
IncrementByIntegerTestHelper(summand1, summand2, numberOfQubits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
operation ModularIncrementLETestHelper (summand1 : Int, summand2 : Int, modulus : Int, numberOfQubits : Int) : Unit {
|
||||
operation IncrementByModularIntegerHelper (summand1 : Int, summand2 : Int, modulus : Int, numberOfQubits : Int) : Unit {
|
||||
|
||||
using (register = Qubit[numberOfQubits]) {
|
||||
let registerLE = LittleEndian(register);
|
||||
ApplyXorInPlace(summand1, registerLE);
|
||||
ModularIncrementLE(summand2, modulus, registerLE);
|
||||
IncrementByModularInteger(summand2, modulus, registerLE);
|
||||
let expected = ModulusI(summand1 + summand2, modulus);
|
||||
let actual = MeasureInteger(registerLE);
|
||||
EqualityFactI(expected, actual, $"Expected {expected}, got {actual}");
|
||||
|
||||
using (controls = Qubit[2]) {
|
||||
ApplyXorInPlace(summand1, registerLE);
|
||||
Controlled ModularIncrementLE(controls, (summand2, modulus, registerLE));
|
||||
Controlled IncrementByModularInteger(controls, (summand2, modulus, registerLE));
|
||||
let actual2 = MeasureInteger(registerLE);
|
||||
EqualityFactI(summand1, actual2, $"Expected {summand1}, got {actual2}");
|
||||
|
||||
// now set all controls to 1
|
||||
ApplyXorInPlace(summand1, registerLE);
|
||||
(ControlledOnInt(0, ModularIncrementLE(summand2, modulus, _)))(controls, registerLE);
|
||||
(ControlledOnInt(0, IncrementByModularInteger(summand2, modulus, _)))(controls, registerLE);
|
||||
let actual3 = MeasureInteger(registerLE);
|
||||
EqualityFactI(expected, actual3, $"Expected {expected}, got {actual3}");
|
||||
// restore controls back to |0⟩
|
||||
|
@ -82,9 +82,9 @@ namespace Microsoft.Quantum.Tests {
|
|||
|
||||
|
||||
/// # Summary
|
||||
/// Exhaustively tests Microsoft.Quantum.Canon.ModularIncrementLE
|
||||
/// Exhaustively tests Microsoft.Quantum.Arithmetic.IncrementByModularInteger
|
||||
/// on 4 qubits with modulus 13
|
||||
operation ModularIncrementLETest () : Unit {
|
||||
operation IncrementByModularIntegerTest () : Unit {
|
||||
|
||||
let numberOfQubits = 4;
|
||||
let modulus = 13;
|
||||
|
@ -92,20 +92,20 @@ namespace Microsoft.Quantum.Tests {
|
|||
for (summand1 in 0 .. modulus - 1) {
|
||||
|
||||
for (summand2 in 0 .. modulus - 1) {
|
||||
ModularIncrementLETestHelper(summand1, summand2, modulus, numberOfQubits);
|
||||
IncrementByModularIntegerHelper(summand1, summand2, modulus, numberOfQubits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
operation ModularAddProductLETestHelper (summand : Int, multiplier1 : Int, multiplier2 : Int, modulus : Int, numberOfQubits : Int) : Unit {
|
||||
operation MultiplyAndAddByModularIntegerTestHelper (summand : Int, multiplier1 : Int, multiplier2 : Int, modulus : Int, numberOfQubits : Int) : Unit {
|
||||
|
||||
using (register = Qubit[numberOfQubits * 2]) {
|
||||
let summandLE = LittleEndian(register[0 .. numberOfQubits - 1]);
|
||||
let multiplierLE = LittleEndian(register[numberOfQubits .. 2 * numberOfQubits - 1]);
|
||||
ApplyXorInPlace(summand, summandLE);
|
||||
ApplyXorInPlace(multiplier1, multiplierLE);
|
||||
ModularAddProductLE(multiplier2, modulus, multiplierLE, summandLE);
|
||||
MultiplyAndAddByModularInteger(multiplier2, modulus, multiplierLE, summandLE);
|
||||
let expected = ModulusI(summand + multiplier1 * multiplier2, modulus);
|
||||
let actual = MeasureInteger(summandLE);
|
||||
let actualMult = MeasureInteger(multiplierLE);
|
||||
|
@ -118,7 +118,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
/// # Summary
|
||||
/// Exhaustively tests Microsoft.Quantum.Canon.ModularAddProductLE
|
||||
/// on 4 qubits with modulus 13
|
||||
operation ModularAddProductLETest () : Unit {
|
||||
operation MultiplyAndAddByModularIntegerTest () : Unit {
|
||||
|
||||
let numberOfQubits = 4;
|
||||
let modulus = 13;
|
||||
|
@ -128,21 +128,21 @@ namespace Microsoft.Quantum.Tests {
|
|||
for (multiplier1 in 0 .. modulus - 1) {
|
||||
|
||||
for (multiplier2 in 0 .. modulus - 1) {
|
||||
ModularAddProductLETestHelper(summand, multiplier1, multiplier2, modulus, numberOfQubits);
|
||||
MultiplyAndAddByModularIntegerTestHelper(summand, multiplier1, multiplier2, modulus, numberOfQubits);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
operation ModularMultiplyByConstantLETestHelper (multiplier1 : Int, multiplier2 : Int, modulus : Int, numberOfQubits : Int) : Unit {
|
||||
operation MultiplyByModularIntegerTestHelper (multiplier1 : Int, multiplier2 : Int, modulus : Int, numberOfQubits : Int) : Unit {
|
||||
|
||||
using (register = Qubit[numberOfQubits]) {
|
||||
|
||||
if (IsCoprimeI(multiplier2, modulus)) {
|
||||
let multiplierLE = LittleEndian(register);
|
||||
ApplyXorInPlace(multiplier1, multiplierLE);
|
||||
ModularMultiplyByConstantLE(multiplier2, modulus, multiplierLE);
|
||||
MultiplyByModularInteger(multiplier2, modulus, multiplierLE);
|
||||
let expected = ModulusI(multiplier1 * multiplier2, modulus);
|
||||
let actualMult = MeasureInteger(multiplierLE);
|
||||
EqualityFactI(expected, actualMult, $"Expected {expected}, got {actualMult}");
|
||||
|
@ -154,7 +154,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
/// # Summary
|
||||
/// Exhaustively tests Microsoft.Quantum.Canon.ModularMultiplyByConstantLE
|
||||
/// on 4 qubits with modulus 13
|
||||
operation ModularMultiplyByConstantLETest () : Unit {
|
||||
operation MultiplyByModularIntegerTest () : Unit {
|
||||
|
||||
let numberOfQubits = 4;
|
||||
let modulus = 13;
|
||||
|
@ -162,7 +162,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
for (multiplier1 in 0 .. modulus - 1) {
|
||||
|
||||
for (multiplier2 in 0 .. modulus - 1) {
|
||||
ModularMultiplyByConstantLETestHelper(multiplier1, multiplier2, modulus, numberOfQubits);
|
||||
MultiplyByModularIntegerTestHelper(multiplier1, multiplier2, modulus, numberOfQubits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
function FilterTest () : Unit {
|
||||
|
||||
let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let evenArray = Filter(IsEven, array);
|
||||
let evenArray = Filtered(IsEven, array);
|
||||
EqualityFactB(All(IsEven, evenArray), true, $"the even elements of [1..10] were not correctly filtered.");
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
|
||||
function AssertBoolArrayEqualTestShouldFail () : Unit {
|
||||
|
||||
AssertBoolArrayEqual([true, false], [false, true], $"OK");
|
||||
AllEqualityFactB([true, false], [false, true], $"OK");
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,8 +92,6 @@ namespace Microsoft.Quantum.Tests {
|
|||
Exp([PauliX], theta, [qubits[3]]);
|
||||
AssertProbInt(5, 1.0 - prob, LittleEndian(qubits), tolerance);
|
||||
AssertProbInt(13, prob, LittleEndian(qubits), tolerance);
|
||||
AssertProbIntBE(10, 1.0 - prob, BigEndian(qubits), tolerance);
|
||||
AssertProbIntBE(11, prob, BigEndian(qubits), tolerance);
|
||||
ResetAll(qubits);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
namespace Microsoft.Quantum.Tests {
|
||||
open Microsoft.Quantum.Convert;
|
||||
open Microsoft.Quantum.Intrinsic;
|
||||
open Microsoft.Quantum.Canon;
|
||||
open Microsoft.Quantum.ErrorCorrection;
|
||||
|
@ -175,7 +176,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
Ry(PI() / 2.5, anc[0]);
|
||||
FiveQubitCodeEncoderImpl([anc[0]], anc[1 .. 4]);
|
||||
let syn = s!(LogicalRegister(anc));
|
||||
let a = ResultAsInt(syn!);
|
||||
let a = ResultArrayAsInt(syn!);
|
||||
EqualityFactI(a, 0, $"syndrome failure");
|
||||
let (encode, decode, syndMeas) = (FiveQubitCode())!;
|
||||
let recovery = FiveQubitCodeRecoveryFn();
|
||||
|
@ -185,7 +186,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
let syndrome = syndMeas!(LogicalRegister(anc));
|
||||
let recoveryOp = recovery!(syndrome);
|
||||
ApplyPauli(recoveryOp, anc);
|
||||
let ans = ResultAsInt((syndMeas!(LogicalRegister(anc)))!);
|
||||
let ans = ResultArrayAsInt((syndMeas!(LogicalRegister(anc)))!);
|
||||
EqualityFactI(ans, 0, $"Correction failure");
|
||||
}
|
||||
|
||||
|
@ -194,7 +195,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
let syndrome = syndMeas!(LogicalRegister(anc));
|
||||
let recoveryOp = recovery!(syndrome);
|
||||
ApplyPauli(recoveryOp, anc);
|
||||
let ans = ResultAsInt((syndMeas!(LogicalRegister(anc)))!);
|
||||
let ans = ResultArrayAsInt((syndMeas!(LogicalRegister(anc)))!);
|
||||
EqualityFactI(ans, 0, $"Correction failure");
|
||||
}
|
||||
|
||||
|
@ -203,7 +204,7 @@ namespace Microsoft.Quantum.Tests {
|
|||
let syndrome = syndMeas!(LogicalRegister(anc));
|
||||
let recoveryOp = recovery!(syndrome);
|
||||
ApplyPauli(recoveryOp, anc);
|
||||
let ans = ResultAsInt((syndMeas!(LogicalRegister(anc)))!);
|
||||
let ans = ResultArrayAsInt((syndMeas!(LogicalRegister(anc)))!);
|
||||
EqualityFactI(ans, 0, $"Correction failure");
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче