From 889e4671d6ec00f1ebf0b3f56ea89ab45196766e Mon Sep 17 00:00:00 2001 From: Anipik Date: Mon, 4 Feb 2019 15:22:01 -0800 Subject: [PATCH 1/3] fix netfx tests --- test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs | 3 +++ test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs b/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs index c7abf45ed5..c0da4c0a04 100644 --- a/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs +++ b/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs @@ -136,6 +136,9 @@ void TestOldSavingAndLoading() void TestCommandLine() { var env = new MLContext(); + IHostEnvironment environment = env; + environment.ComponentCatalog.RegisterAssembly(typeof(TensorFlowTransformer).Assembly); + Assert.Equal(Maml.Main(new[] { @"showschema loader=Text{col=a:R4:0-3 col=b:R4:0-3} xf=TFTransform{inputs=a inputs=b outputs=c modellocation={model_matmul/frozen_saved_model.pb}}" }), (int)0); } diff --git a/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs b/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs index 290a42b9a9..f79c0e71b1 100644 --- a/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs +++ b/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs @@ -325,9 +325,13 @@ public void WhiteningWorkout() Done(); } - [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.NotFullFramework))] // Tracked by https://github.com/dotnet/machinelearning/issues/2104 + [Fact] public void TestWhiteningCommandLine() { + MLContext env = new MLContext(); + IHostEnvironment environment = env; + environment.ComponentCatalog.RegisterAssembly(typeof(VectorWhiteningTransformer).Assembly); + Assert.Equal(Maml.Main(new[] { @"showschema loader=Text{col=A:R4:0-10} xf=whitening{col=B:A} in=f:\2.txt" }), (int)0); } From f13586652832ed1aba887d0e15f7fe0d1aca1c51 Mon Sep 17 00:00:00 2001 From: Anipik Date: Mon, 4 Feb 2019 16:59:02 -0800 Subject: [PATCH 2/3] optimise the declaration --- test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs | 3 +-- test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs b/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs index c0da4c0a04..ef30d08303 100644 --- a/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs +++ b/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs @@ -135,8 +135,7 @@ void TestOldSavingAndLoading() [ConditionalFact(typeof(Environment), nameof(Environment.Is64BitProcess))] // x86 output differs from Baseline void TestCommandLine() { - var env = new MLContext(); - IHostEnvironment environment = env; + IHostEnvironment environment = new MLContext(); environment.ComponentCatalog.RegisterAssembly(typeof(TensorFlowTransformer).Assembly); Assert.Equal(Maml.Main(new[] { @"showschema loader=Text{col=a:R4:0-3 col=b:R4:0-3} xf=TFTransform{inputs=a inputs=b outputs=c modellocation={model_matmul/frozen_saved_model.pb}}" }), (int)0); diff --git a/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs b/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs index f79c0e71b1..688867ca94 100644 --- a/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs +++ b/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs @@ -328,8 +328,7 @@ public void WhiteningWorkout() [Fact] public void TestWhiteningCommandLine() { - MLContext env = new MLContext(); - IHostEnvironment environment = env; + IHostEnvironment environment = new MLContext(); environment.ComponentCatalog.RegisterAssembly(typeof(VectorWhiteningTransformer).Assembly); Assert.Equal(Maml.Main(new[] { @"showschema loader=Text{col=A:R4:0-10} xf=whitening{col=B:A} in=f:\2.txt" }), (int)0); From bb8472af761c2c77f8507f5583665a5cb199fd21 Mon Sep 17 00:00:00 2001 From: Anipik Date: Tue, 5 Feb 2019 11:38:22 -0800 Subject: [PATCH 3/3] using typeof and removing unnecessary environment --- test/Microsoft.ML.OnnxTransformTest/OnnxTransformTests.cs | 1 - test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs | 5 ++--- test/Microsoft.ML.Tests/TermEstimatorTests.cs | 1 - .../Transformers/CopyColumnEstimatorTests.cs | 1 - test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs | 6 +++--- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/test/Microsoft.ML.OnnxTransformTest/OnnxTransformTests.cs b/test/Microsoft.ML.OnnxTransformTest/OnnxTransformTests.cs index 17a83041db..db06562a02 100644 --- a/test/Microsoft.ML.OnnxTransformTest/OnnxTransformTests.cs +++ b/test/Microsoft.ML.OnnxTransformTest/OnnxTransformTests.cs @@ -245,7 +245,6 @@ public void OnnxStatic() [OnnxFact] void TestCommandLine() { - var env = new MLContext(); var x = Maml.Main(new[] { @"showschema loader=Text{col=data_0:R4:0-150527} xf=Onnx{InputColumns={data_0} OutputColumns={softmaxout_1} model={squeezenet/00000001/model.onnx}}" }); Assert.Equal(0, x); } diff --git a/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs b/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs index ef30d08303..e86eba2144 100644 --- a/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs +++ b/test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs @@ -135,9 +135,8 @@ void TestOldSavingAndLoading() [ConditionalFact(typeof(Environment), nameof(Environment.Is64BitProcess))] // x86 output differs from Baseline void TestCommandLine() { - IHostEnvironment environment = new MLContext(); - environment.ComponentCatalog.RegisterAssembly(typeof(TensorFlowTransformer).Assembly); - + // typeof helps to load the TensorFlowTransformer type. + Type type = typeof(TensorFlowTransformer); Assert.Equal(Maml.Main(new[] { @"showschema loader=Text{col=a:R4:0-3 col=b:R4:0-3} xf=TFTransform{inputs=a inputs=b outputs=c modellocation={model_matmul/frozen_saved_model.pb}}" }), (int)0); } diff --git a/test/Microsoft.ML.Tests/TermEstimatorTests.cs b/test/Microsoft.ML.Tests/TermEstimatorTests.cs index 2e43973321..fe82a9613b 100644 --- a/test/Microsoft.ML.Tests/TermEstimatorTests.cs +++ b/test/Microsoft.ML.Tests/TermEstimatorTests.cs @@ -154,7 +154,6 @@ void TestMetadataCopy() [Fact] void TestCommandLine() { - var env = new MLContext(); Assert.Equal(0, Maml.Main(new[] { @"showschema loader=Text{col=A:R4:0} xf=Term{col=B:A} in=f:\2.txt" })); } diff --git a/test/Microsoft.ML.Tests/Transformers/CopyColumnEstimatorTests.cs b/test/Microsoft.ML.Tests/Transformers/CopyColumnEstimatorTests.cs index e14960e18d..4e0ba743b5 100644 --- a/test/Microsoft.ML.Tests/Transformers/CopyColumnEstimatorTests.cs +++ b/test/Microsoft.ML.Tests/Transformers/CopyColumnEstimatorTests.cs @@ -153,7 +153,6 @@ void TestMetadataCopy() [Fact] void TestCommandLine() { - var env = new MLContext(); Assert.Equal(Maml.Main(new[] { @"showschema loader=Text{col=A:R4:0} xf=copy{col=B:A} in=f:\1.txt" }), (int)0); } diff --git a/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs b/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs index 688867ca94..ca7aaf131d 100644 --- a/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs +++ b/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Immutable; using System.IO; using Microsoft.Data.DataView; @@ -328,9 +329,8 @@ public void WhiteningWorkout() [Fact] public void TestWhiteningCommandLine() { - IHostEnvironment environment = new MLContext(); - environment.ComponentCatalog.RegisterAssembly(typeof(VectorWhiteningTransformer).Assembly); - + // typeof helps to load the VectorWhiteningTransformer type. + Type type = typeof(VectorWhiteningTransformer); Assert.Equal(Maml.Main(new[] { @"showschema loader=Text{col=A:R4:0-10} xf=whitening{col=B:A} in=f:\2.txt" }), (int)0); }