From 44df27f24d593864e3c88ee7cb0df6a2d2e555a7 Mon Sep 17 00:00:00 2001 From: Srujan Saggam Date: Wed, 15 May 2019 22:13:23 -0700 Subject: [PATCH] added culture independent parsing --- src/Microsoft.ML.AutoML/Utils/MLNetUtils/Conversions.cs | 3 ++- src/Microsoft.ML.AutoML/Utils/SweepableParamAttributes.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.ML.AutoML/Utils/MLNetUtils/Conversions.cs b/src/Microsoft.ML.AutoML/Utils/MLNetUtils/Conversions.cs index b8cf657ad9..2c533535ce 100644 --- a/src/Microsoft.ML.AutoML/Utils/MLNetUtils/Conversions.cs +++ b/src/Microsoft.ML.AutoML/Utils/MLNetUtils/Conversions.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Globalization; namespace Microsoft.ML.AutoML { @@ -25,7 +26,7 @@ public static bool TryParse(in TX src, out R4 dst) dst = R4.NaN; return true; } - if (float.TryParse(str, out dst)) + if (float.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out dst)) { return true; } diff --git a/src/Microsoft.ML.AutoML/Utils/SweepableParamAttributes.cs b/src/Microsoft.ML.AutoML/Utils/SweepableParamAttributes.cs index b575e8bc80..ae7945d21e 100644 --- a/src/Microsoft.ML.AutoML/Utils/SweepableParamAttributes.cs +++ b/src/Microsoft.ML.AutoML/Utils/SweepableParamAttributes.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Globalization; using System.Linq; using System.Text; @@ -144,7 +145,7 @@ public SweepableFloatParam(float min, float max, float stepSize = -1, int numSte public override void SetUsingValueText(string valueText) { - RawValue = float.Parse(valueText); + RawValue = float.Parse(valueText, CultureInfo.InvariantCulture); } public override SweepableParam Clone() =>