From 1f234b989c42150760847164521c80b45d5e6561 Mon Sep 17 00:00:00 2001 From: Christopher Granade Date: Fri, 6 Dec 2019 16:27:54 -0800 Subject: [PATCH 1/3] Add placeholder for QML unit tests. --- Chemistry/src/DataModel/DataModel.csproj | 2 +- Chemistry/src/Jupyter/Jupyter.csproj | 2 +- Chemistry/src/Runtime/Runtime.csproj | 2 +- .../tests/ChemistryTests/QSharpTests.csproj | 4 +-- .../tests/DataModelTests/CSharpTests.csproj | 6 ++--- .../tests/SamplesTests/SamplesTests.csproj | 6 ++--- .../tests/SystemTests/SystemTests.csproj | 4 +-- .../src/DataModel/DataModel.csproj | 2 +- MachineLearning/src/Runtime/Runtime.csproj | 2 +- MachineLearning/tests/InputEncodingTests.qs | 25 +++++++++++++++++++ .../tests/MachineLearningTests.csproj | 4 +-- Numerics/src/Numerics.csproj | 2 +- Numerics/tests/NumericsTests.csproj | 4 +-- Standard/src/Standard.csproj | 2 +- Standard/tests/Standard.Tests.csproj | 4 +-- 15 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 MachineLearning/tests/InputEncodingTests.qs diff --git a/Chemistry/src/DataModel/DataModel.csproj b/Chemistry/src/DataModel/DataModel.csproj index 4e1f891c5b3..a0f7a2db3ab 100644 --- a/Chemistry/src/DataModel/DataModel.csproj +++ b/Chemistry/src/DataModel/DataModel.csproj @@ -35,7 +35,7 @@ - + diff --git a/Chemistry/src/Jupyter/Jupyter.csproj b/Chemistry/src/Jupyter/Jupyter.csproj index 05d9aa2329a..5993652baef 100644 --- a/Chemistry/src/Jupyter/Jupyter.csproj +++ b/Chemistry/src/Jupyter/Jupyter.csproj @@ -26,7 +26,7 @@ - + diff --git a/Chemistry/src/Runtime/Runtime.csproj b/Chemistry/src/Runtime/Runtime.csproj index e95a5c76452..4eee1e92205 100644 --- a/Chemistry/src/Runtime/Runtime.csproj +++ b/Chemistry/src/Runtime/Runtime.csproj @@ -15,7 +15,7 @@ - + diff --git a/Chemistry/tests/ChemistryTests/QSharpTests.csproj b/Chemistry/tests/ChemistryTests/QSharpTests.csproj index 96c76d44343..e3ccd565594 100644 --- a/Chemistry/tests/ChemistryTests/QSharpTests.csproj +++ b/Chemistry/tests/ChemistryTests/QSharpTests.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/Chemistry/tests/DataModelTests/CSharpTests.csproj b/Chemistry/tests/DataModelTests/CSharpTests.csproj index 754a219c1fc..c3243e55cba 100644 --- a/Chemistry/tests/DataModelTests/CSharpTests.csproj +++ b/Chemistry/tests/DataModelTests/CSharpTests.csproj @@ -24,9 +24,9 @@ - - - + + + diff --git a/Chemistry/tests/SamplesTests/SamplesTests.csproj b/Chemistry/tests/SamplesTests/SamplesTests.csproj index 206c9c3b679..ecf44796b07 100644 --- a/Chemistry/tests/SamplesTests/SamplesTests.csproj +++ b/Chemistry/tests/SamplesTests/SamplesTests.csproj @@ -18,9 +18,9 @@ - - - + + + diff --git a/Chemistry/tests/SystemTests/SystemTests.csproj b/Chemistry/tests/SystemTests/SystemTests.csproj index 8bcec6ef3cd..638b7bfa7cd 100644 --- a/Chemistry/tests/SystemTests/SystemTests.csproj +++ b/Chemistry/tests/SystemTests/SystemTests.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/MachineLearning/src/DataModel/DataModel.csproj b/MachineLearning/src/DataModel/DataModel.csproj index fc1d86492a9..24297486e72 100644 --- a/MachineLearning/src/DataModel/DataModel.csproj +++ b/MachineLearning/src/DataModel/DataModel.csproj @@ -32,7 +32,7 @@ - + diff --git a/MachineLearning/src/Runtime/Runtime.csproj b/MachineLearning/src/Runtime/Runtime.csproj index 5e1fb341f6c..c3da71b95ce 100644 --- a/MachineLearning/src/Runtime/Runtime.csproj +++ b/MachineLearning/src/Runtime/Runtime.csproj @@ -10,7 +10,7 @@ - + diff --git a/MachineLearning/tests/InputEncodingTests.qs b/MachineLearning/tests/InputEncodingTests.qs new file mode 100644 index 00000000000..d0ffb466345 --- /dev/null +++ b/MachineLearning/tests/InputEncodingTests.qs @@ -0,0 +1,25 @@ +namespace Microsoft.Quantum.MachineLearning.Tests { + open Microsoft.Quantum.Arrays; + open Microsoft.Quantum.Math; + open Microsoft.Quantum.Arithmetic; + open Microsoft.Quantum.Preparation; + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Canon; + open Microsoft.Quantum.Diagnostics; + open Microsoft.Quantum.MachineLearning; + + operation _ApplyToBareRegister(op : (LittleEndian => Unit is Adj), register : Qubit[]) : Unit is Adj { + op(LittleEndian(register)); + } + + @Test("QuantumSimulator") + operation CheckInputEncoderWithPositiveInputs() : Unit { + let coefficients = [0.1, 0.2, 0.3, 0.4]; + let encoder = InputEncoder(coefficients); + AssertOperationsEqualReferenced(2, + _ApplyToBareRegister(PrepareArbitraryState(Mapped(ComplexPolar(_, 0.0), coefficients), _), _), + _ApplyToBareRegister(encoder, _) + ); + } + +} diff --git a/MachineLearning/tests/MachineLearningTests.csproj b/MachineLearning/tests/MachineLearningTests.csproj index 40057467b84..e8620296bed 100644 --- a/MachineLearning/tests/MachineLearningTests.csproj +++ b/MachineLearning/tests/MachineLearningTests.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/Numerics/src/Numerics.csproj b/Numerics/src/Numerics.csproj index 2ae8d804e74..61d5bf1c417 100644 --- a/Numerics/src/Numerics.csproj +++ b/Numerics/src/Numerics.csproj @@ -30,7 +30,7 @@ - + diff --git a/Numerics/tests/NumericsTests.csproj b/Numerics/tests/NumericsTests.csproj index c729aaa91ba..4a7b29edfa4 100644 --- a/Numerics/tests/NumericsTests.csproj +++ b/Numerics/tests/NumericsTests.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/Standard/src/Standard.csproj b/Standard/src/Standard.csproj index d1e16215f06..ad5987d5a62 100644 --- a/Standard/src/Standard.csproj +++ b/Standard/src/Standard.csproj @@ -30,7 +30,7 @@ - + diff --git a/Standard/tests/Standard.Tests.csproj b/Standard/tests/Standard.Tests.csproj index 59a589b773b..c05bed8b8ca 100644 --- a/Standard/tests/Standard.Tests.csproj +++ b/Standard/tests/Standard.Tests.csproj @@ -20,8 +20,8 @@ - - + + From fb20cac69466fb8fb37c58b7f1c6e260c4c824cb Mon Sep 17 00:00:00 2001 From: Christopher Granade Date: Fri, 6 Dec 2019 16:30:37 -0800 Subject: [PATCH 2/3] Add copyright header. --- MachineLearning/tests/InputEncodingTests.qs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MachineLearning/tests/InputEncodingTests.qs b/MachineLearning/tests/InputEncodingTests.qs index d0ffb466345..692901bb343 100644 --- a/MachineLearning/tests/InputEncodingTests.qs +++ b/MachineLearning/tests/InputEncodingTests.qs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + namespace Microsoft.Quantum.MachineLearning.Tests { open Microsoft.Quantum.Arrays; open Microsoft.Quantum.Math; From e4b3d30129a38e89bc4e8349b0350e931da3f1a8 Mon Sep 17 00:00:00 2001 From: Christopher Granade Date: Fri, 6 Dec 2019 16:50:50 -0800 Subject: [PATCH 3/3] Trigger build on feature work. --- build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/build.yml b/build.yml index f6146c89972..2be88668e74 100644 --- a/build.yml +++ b/build.yml @@ -4,6 +4,7 @@ name: $(Build.Major).$(Build.Minor).$(date:yyMM).$(DayOfMonth)$(rev:rr) trigger: - master +- feature/* variables: Build.Major: 0