Skip to content

Commit

Permalink
fix namespace issue in CSharpGenerator and some refactoring (#339)
Browse files Browse the repository at this point in the history
fix namespace issue and refactoring
  • Loading branch information
Ivanidzo4ka authored Jun 12, 2018
1 parent 45ced36 commit 1fc3069
Show file tree
Hide file tree
Showing 12 changed files with 978 additions and 1,011 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class Arguments : IPartitionedPathParserFactory
{
[Argument(ArgumentType.Multiple, HelpText = "Column definitions used to override the Partitioned Path Parser. Expected with the format name:type:numeric-source, e.g. col=MyFeature:R4:1",
ShortName = "col", SortOrder = 1)]
public Microsoft.ML.Runtime.Data.PartitionedFileLoader.Column[] Columns;
public PartitionedFileLoader.Column[] Columns;

[Argument(ArgumentType.AtMostOnce, HelpText = "Data type of each column.")]
public DataKind Type = DataKind.Text;
Expand Down
5 changes: 2 additions & 3 deletions src/Microsoft.ML.PipelineInference/TransformInference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ML;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.EntryPoints;
Expand Down Expand Up @@ -712,7 +711,7 @@ public override IEnumerable<SuggestedTransform> Apply(IntermediateColumn[] colum
{
Name = columnNameQuoted.ToString(),
Source = columnNameQuoted.ToString(),
ResultType = ML.Transforms.DataKind.R4
ResultType = ML.Data.DataKind.R4
});
}

Expand All @@ -721,7 +720,7 @@ public override IEnumerable<SuggestedTransform> Apply(IntermediateColumn[] colum
ch.Info("Suggested conversion to numeric for boolean features.");
var args = new SubComponent<IDataTransform, SignatureDataTransform>("Convert",
new[] { $"{columnArgument}type=R4" });
var epInput = new ML.Transforms.ColumnTypeConverter { Column = epColumns.ToArray(), ResultType = ML.Transforms.DataKind.R4 };
var epInput = new ML.Transforms.ColumnTypeConverter { Column = epColumns.ToArray(), ResultType = ML.Data.DataKind.R4 };
ColumnRoutingStructure.AnnotatedName[] columnsSource =
epColumns.Select(c => new ColumnRoutingStructure.AnnotatedName { IsNumeric = false, Name = c.Name }).ToArray();
ColumnRoutingStructure.AnnotatedName[] columnsDest =
Expand Down
363 changes: 177 additions & 186 deletions src/Microsoft.ML/CSharpApi.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Reflection;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Internal.Tools;
using Microsoft.ML.Runtime.Internal.Utilities;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -67,13 +68,7 @@ public static JObject BuildAllManifests(IExceptionContext ectx, ModuleCatalog ca
{
var jField = new JObject();
jField[FieldNames.Name] = fieldInfo.Name;
var type = fieldInfo.PropertyType;
// Dive inside Optional.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Optional<>))
type = type.GetGenericArguments()[0];
// Dive inside Nullable.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
type = type.GetGenericArguments()[0];
var type = CSharpGeneratorUtils.ExtractOptionalOrNullableType(fieldInfo.PropertyType);
// Dive inside Var.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Var<>))
type = type.GetGenericArguments()[0];
Expand Down Expand Up @@ -308,14 +303,7 @@ private static JToken BuildTypeToken(IExceptionContext ectx, FieldInfo fieldInfo
jo[FieldNames.ItemType] = typeString;
return jo;
}

// Dive inside Optional.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Optional<>))
type = type.GetGenericArguments()[0];

// Dive inside Nullable.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
type = type.GetGenericArguments()[0];
type = CSharpGeneratorUtils.ExtractOptionalOrNullableType(type);

// Dive inside Var.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Var<>))
Expand Down
Loading

0 comments on commit 1fc3069

Please sign in to comment.