Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace DvDateTimeZone, DvDateTime, DvTimeSpan with .NET standard types. #693

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bc530e9
Replace date/time types with .NET standard types.
codemzs Aug 19, 2018
e0d66b0
rename DateTimeZone to DateTimeOffset.
codemzs Aug 19, 2018
54145da
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 27, 2018
e55c780
PR feedback.
codemzs Aug 27, 2018
53a84d1
PR feedback.
codemzs Aug 27, 2018
b7d4c6b
PR feedback.
codemzs Aug 27, 2018
844da7c
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 28, 2018
dbaac06
IDV test.
codemzs Aug 28, 2018
53b4e57
add test for parquet loader.
codemzs Aug 28, 2018
ae9aede
Merge branch 'parquettest' of https://github.com/codemzs/machinelearn…
codemzs Aug 28, 2018
48b4c08
Update parquet tests.
codemzs Aug 28, 2018
7f55c59
fix build.
codemzs Aug 28, 2018
71f8701
PR feedback.
codemzs Aug 28, 2018
1ccc263
clean up.
codemzs Aug 29, 2018
1672739
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 29, 2018
5231b51
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 30, 2018
0a1ba05
PR feedback.
codemzs Aug 30, 2018
0560602
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 30, 2018
401fa64
rebuild.
codemzs Aug 30, 2018
c3a5a2d
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 31, 2018
74a652c
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Sep 4, 2018
7cc7d9a
merge parquet test.
codemzs Sep 4, 2018
a42861c
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Sep 7, 2018
ea943d6
merge master.
codemzs Sep 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Api/ApiUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static OpCode GetAssignmentOpCode(Type t)
t == typeof(DvBool) || t == typeof(DvText) || t == typeof(string) || t.IsArray ||
(t.IsGenericType && t.GetGenericTypeDefinition() == typeof(VBuffer<>)) ||
(t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) ||
t == typeof(DvDateTime) || t == typeof(DvDateTimeZone) || t == typeof(DvTimeSpan) || t == typeof(UInt128))
t == typeof(DateTime) || t == typeof(DateTimeOffset) || t == typeof(TimeSpan) || t == typeof(UInt128))
{
return OpCodes.Stobj;
}
Expand Down
47 changes: 19 additions & 28 deletions src/Microsoft.ML.Core/Data/ColumnType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,47 +120,38 @@ public bool IsBool
}

/// <summary>
/// Whether this type is the standard timespan type.
/// Whether this type is the standard <see cref="TimeSpan"/> type.
/// </summary>
public bool IsTimeSpan
{
get
{
if (!(this is TimeSpanType))
return false;
// TimeSpanType is a singleton.
Contracts.Assert(this == TimeSpanType.Instance);
return true;
Contracts.Assert((this == TimeSpanType.Instance) == (this is TimeSpanType));
return this is TimeSpanType;
}
}

/// <summary>
/// Whether this type is a DvDateTime.
/// Whether this type is a <see cref="DateTime"/>.
/// </summary>
public bool IsDateTime
{
get
{
if (!(this is DateTimeType))
return false;
// DateTimeType is a singleton.
Contracts.Assert(this == DateTimeType.Instance);
return true;
Contracts.Assert((this == DateTimeType.Instance) == (this is DateTimeType));
return this is DateTimeType;
}
}

/// <summary>
/// Whether this type is a DvDateTimeZone.
/// Whether this type is a <see cref="DateTimeOffset"/>
/// </summary>
public bool IsDateTimeZone
{
get
{
if (!(this is DateTimeZoneType))
return false;
// DateTimeZoneType is a singleton.
Contracts.Assert(this == DateTimeZoneType.Instance);
return true;
Contracts.Assert((this == DateTimeOffsetType.Instance) == (this is DateTimeOffsetType));
return this is DateTimeOffsetType;
}
}

Expand Down Expand Up @@ -319,7 +310,7 @@ public static PrimitiveType FromKind(DataKind kind)
if (kind == DataKind.DT)
return DateTimeType.Instance;
if (kind == DataKind.DZ)
return DateTimeZoneType.Instance;
return DateTimeOffsetType.Instance;
return NumberType.FromKind(kind);
}
}
Expand Down Expand Up @@ -605,7 +596,7 @@ public static DateTimeType Instance
}

private DateTimeType()
: base(typeof(DvDateTime), DataKind.DT)
: base(typeof(DateTime), DataKind.DT)
{
}

Expand All @@ -623,29 +614,29 @@ public override string ToString()
}
}

public sealed class DateTimeZoneType : PrimitiveType
public sealed class DateTimeOffsetType : PrimitiveType
{
private static volatile DateTimeZoneType _instance;
public static DateTimeZoneType Instance
private static volatile DateTimeOffsetType _instance;
public static DateTimeOffsetType Instance
{
get
{
if (_instance == null)
Interlocked.CompareExchange(ref _instance, new DateTimeZoneType(), null);
Interlocked.CompareExchange(ref _instance, new DateTimeOffsetType(), null);
return _instance;
}
}

private DateTimeZoneType()
: base(typeof(DvDateTimeZone), DataKind.DZ)
private DateTimeOffsetType()
: base(typeof(DateTimeOffset), DataKind.DZ)
{
}

public override bool Equals(ColumnType other)
{
if (other == this)
return true;
Contracts.Assert(!(other is DateTimeZoneType));
Contracts.Assert(!(other is DateTimeOffsetType));
return false;
}

Expand All @@ -672,7 +663,7 @@ public static TimeSpanType Instance
}

private TimeSpanType()
: base(typeof(DvTimeSpan), DataKind.TS)
: base(typeof(TimeSpan), DataKind.TS)
{
}

Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.ML.Core/Data/DataKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ public static Type ToType(this DataKind kind)
case DataKind.BL:
return typeof(DvBool);
case DataKind.TS:
return typeof(DvTimeSpan);
return typeof(TimeSpan);
case DataKind.DT:
return typeof(DvDateTime);
return typeof(DateTime);
case DataKind.DZ:
return typeof(DvDateTimeZone);
return typeof(DateTimeOffset);
case DataKind.UG:
return typeof(UInt128);
}
Expand Down Expand Up @@ -209,11 +209,11 @@ public static bool TryGetDataKind(this Type type, out DataKind kind)
kind = DataKind.TX;
else if (type == typeof(DvBool) || type == typeof(bool) || type == typeof(bool?))
kind = DataKind.BL;
else if (type == typeof(DvTimeSpan))
else if (type == typeof(TimeSpan))
kind = DataKind.TS;
else if (type == typeof(DvDateTime))
else if (type == typeof(DateTime))
kind = DataKind.DT;
else if (type == typeof(DvDateTimeZone))
else if (type == typeof(DateTimeOffset))
kind = DataKind.DZ;
else if (type == typeof(UInt128))
kind = DataKind.UG;
Expand Down
Loading