diff --git a/src/Microsoft.ML.Data/Dirty/PredictionUtils.cs b/src/Microsoft.ML.Data/Dirty/PredictionUtils.cs index 653a05fbb7..6ade2b5e1d 100644 --- a/src/Microsoft.ML.Data/Dirty/PredictionUtils.cs +++ b/src/Microsoft.ML.Data/Dirty/PredictionUtils.cs @@ -16,7 +16,8 @@ namespace Microsoft.ML.Internal.Internallearn /// /// Various utilities /// - public static class PredictionUtil + [BestFriend] + internal static class PredictionUtil { /// /// generic method for parsing arguments using CommandLine. If there's a problem, it throws an InvalidOperationException, with a message giving usage. @@ -152,16 +153,4 @@ public static char SepCharFromString(string s) } } } - - /// - /// A generic reverse Comparer (for use in Array.Sort) - /// - public sealed class ReverseComparer : IComparer - where T : IComparable - { - public int Compare(T x, T y) - { - return -x.CompareTo(y); - } - } } \ No newline at end of file diff --git a/src/Microsoft.ML.Data/Dirty/PredictorInterfaces.cs b/src/Microsoft.ML.Data/Dirty/PredictorInterfaces.cs index e4d83f8adc..1b956ed2d0 100644 --- a/src/Microsoft.ML.Data/Dirty/PredictorInterfaces.cs +++ b/src/Microsoft.ML.Data/Dirty/PredictorInterfaces.cs @@ -11,12 +11,6 @@ namespace Microsoft.ML.Internal.Internallearn { - - /// - /// Signature for loading from a file name. - /// - public delegate void SignaturePredictorFromFile(string fileName); - /// /// A generic interface for models that can average parameters from multiple instance of self /// @@ -146,7 +140,8 @@ internal interface ICanSaveInSourceCode /// /// Signature for trainers that produce predictors that in turn can be use to score features. /// - public delegate void SignatureFeatureScorerTrainer(); + [BestFriend] + internal delegate void SignatureFeatureScorerTrainer(); /// /// Interface implemented by components that can assign weights to features. diff --git a/src/Microsoft.ML.Data/Training/EarlyStoppingCriteria.cs b/src/Microsoft.ML.Data/Training/EarlyStoppingCriteria.cs index 6a53a5d2ce..0481f51280 100644 --- a/src/Microsoft.ML.Data/Training/EarlyStoppingCriteria.cs +++ b/src/Microsoft.ML.Data/Training/EarlyStoppingCriteria.cs @@ -23,7 +23,7 @@ namespace Microsoft.ML.Internal.Internallearn { - public delegate void SignatureEarlyStoppingCriterion(bool lowerIsBetter); + internal delegate void SignatureEarlyStoppingCriterion(bool lowerIsBetter); // These criteria will be used in FastTree and NeuralNets. public interface IEarlyStoppingCriterion diff --git a/src/Microsoft.ML.Data/Utilities/SlotDropper.cs b/src/Microsoft.ML.Data/Utilities/SlotDropper.cs index c01adb761d..b720ebf703 100644 --- a/src/Microsoft.ML.Data/Utilities/SlotDropper.cs +++ b/src/Microsoft.ML.Data/Utilities/SlotDropper.cs @@ -12,7 +12,8 @@ namespace Microsoft.ML.Internal.Internallearn /// /// Drops slots from a fixed or variable sized column based on slot ranges. /// - public sealed class SlotDropper + [BestFriend] + internal sealed class SlotDropper { private readonly int[] _lengthReduction; diff --git a/src/Microsoft.ML.Data/Utilities/TypeUtils.cs b/src/Microsoft.ML.Data/Utilities/TypeUtils.cs deleted file mode 100644 index eb91b97100..0000000000 --- a/src/Microsoft.ML.Data/Utilities/TypeUtils.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// 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.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Microsoft.ML.Internal.Utilities; - -namespace Microsoft.ML.Internal.Internallearn -{ - public static class TypeUtils - { - /// - /// Returns a pretty representation of the type. - /// - public static string PrettyName(Type type) - { - Contracts.AssertValue(type, "type"); - StringBuilder sb = new StringBuilder(); - BuildPrettyName(type, sb); - return sb.ToString(); - } - - private static void BuildPrettyName(Type type, StringBuilder sb) - { - // Arrays - if (type.IsArray) - { - // Store the original and walk to get the non-array element type. - Type origType = type; - while (type.IsArray) - type = type.GetElementType(); - BuildPrettyName(type, sb); - // Rewalk to get the [] items in indexing order. - type = origType; - while (type.IsArray) - { - sb.Append('['); - for (int i = 1; i < type.GetArrayRank(); ++i) - sb.Append(','); - sb.Append(']'); - type = type.GetElementType(); - } - return; - } - // Output the names of generic parameters. - if (type.IsGenericParameter) - { - Contracts.Assert(type.FullName == null); - sb.Append(type.Name); - return; - } - // Get excluding the namespace and any possible following type-array. - string name = type.FullName ?? type.Name; - Match m = Regex.Match(type.FullName, @"^(?:\w+\.)*([^\[]+)"); - Contracts.Assert(m.Success); - Contracts.Assert(m.Groups.Count == 2); - string[] subNames = m.Groups[1].Value.Split('+'); - // Get the generic type arguments, if there are any. - Type[] genTypes = type.IsGenericType ? type.GetGenericArguments() : null; - int iGenTypes = 0; - - for (int i = 0; i < subNames.Length; ++i) - { - if (i > 0) - sb.Append('.'); - string subName = subNames[i]; - if (!subName.Contains('`')) - { - sb.Append(subName); - continue; - } - string[] subparts = subName.Split('`'); - Contracts.Assert(subparts.Length == 2); - Contracts.Assert(type.IsGenericType); - sb.Append(subparts[0]); - sb.Append('<'); - int numGenerics = int.Parse(subparts[1]); - Contracts.Assert(iGenTypes + numGenerics <= Utils.Size(genTypes)); - while (numGenerics-- > 0) - { - Type parameter = genTypes[iGenTypes++]; - // Leave generic parameters as blank. - if (!parameter.IsGenericParameter) - BuildPrettyName(parameter, sb); - if (numGenerics > 0) - sb.Append(','); - } - sb.Append('>'); - } - Contracts.Assert(iGenTypes == Utils.Size(genTypes)); - } - } -}