Skip to content

Commit

Permalink
Remove T : unmanaged constraint from DataFrameColumn.BinaryOperatio…
Browse files Browse the repository at this point in the history
…ns (dotnet#2801)

* Remove T : unmanaged constraint from DataFrameColumn.BinaryOperations

* Address feedback

* Rename the value version of the APIs

* sq

* Fix build

* Address feedback

* Remove Value from the APIs

* sq

* Address feedback
  • Loading branch information
Prashanth Govindarajan authored Dec 12, 2019
1 parent 303ba62 commit dc4f9b0
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 157 deletions.
8 changes: 8 additions & 0 deletions src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ public PrimitiveDataFrameColumn<bool> ElementwiseEquals(string value)

public override PrimitiveDataFrameColumn<bool> ElementwiseEquals<T>(T value)
{
if (value is DataFrameColumn column)
{
return ElementwiseEquals(column);
}
return ElementwiseEquals(value.ToString());
}

Expand Down Expand Up @@ -532,6 +536,10 @@ public PrimitiveDataFrameColumn<bool> ElementwiseNotEquals(string value)

public override PrimitiveDataFrameColumn<bool> ElementwiseNotEquals<T>(T value)
{
if (value is DataFrameColumn column)
{
return ElementwiseNotEquals(column);
}
return ElementwiseNotEquals(value.ToString());
}

Expand Down
16 changes: 0 additions & 16 deletions src/Microsoft.Data.Analysis/DataFrameColumn.BinaryOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public virtual DataFrameColumn Add(DataFrameColumn column, bool inPlace = false)
/// Performs an element wise addition on each value in the column
/// </summary>
public virtual DataFrameColumn Add<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -30,7 +29,6 @@ public virtual DataFrameColumn Add<T>(T value, bool inPlace = false)
/// Performs a reversed element wise addition on each value in the column
/// </summary>
public virtual DataFrameColumn ReverseAdd<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -44,7 +42,6 @@ public virtual DataFrameColumn Subtract(DataFrameColumn column, bool inPlace = f
/// Performs an element wise subtraction on each value in the column
/// </summary>
public virtual DataFrameColumn Subtract<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -53,7 +50,6 @@ public virtual DataFrameColumn Subtract<T>(T value, bool inPlace = false)
/// Performs a reversed element wise subtraction on each value in the column
/// </summary>
public virtual DataFrameColumn ReverseSubtract<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -67,7 +63,6 @@ public virtual DataFrameColumn Multiply(DataFrameColumn column, bool inPlace = f
/// Performs an element wise multiplication on each value in the column
/// </summary>
public virtual DataFrameColumn Multiply<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -76,7 +71,6 @@ public virtual DataFrameColumn Multiply<T>(T value, bool inPlace = false)
/// Performs a reversed element wise multiplication on each value in the column
/// </summary>
public virtual DataFrameColumn ReverseMultiply<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -90,7 +84,6 @@ public virtual DataFrameColumn Divide(DataFrameColumn column, bool inPlace = fal
/// Performs an element wise division on each value in the column
/// </summary>
public virtual DataFrameColumn Divide<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -99,7 +92,6 @@ public virtual DataFrameColumn Divide<T>(T value, bool inPlace = false)
/// Performs a reversed element wise division on each value in the column
/// </summary>
public virtual DataFrameColumn ReverseDivide<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -113,7 +105,6 @@ public virtual DataFrameColumn Modulo(DataFrameColumn column, bool inPlace = fal
/// Performs an element wise modulus operation on each value in the column
/// </summary>
public virtual DataFrameColumn Modulo<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -122,7 +113,6 @@ public virtual DataFrameColumn Modulo<T>(T value, bool inPlace = false)
/// Performs a reversed element wise modulus operation on each value in the column
/// </summary>
public virtual DataFrameColumn ReverseModulo<T>(T value, bool inPlace = false)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -215,7 +205,6 @@ public virtual PrimitiveDataFrameColumn<bool> ElementwiseEquals(DataFrameColumn
/// Performs an element wise equals on each value in the column
/// </summary>
public virtual PrimitiveDataFrameColumn<bool> ElementwiseEquals<T>(T value)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -229,7 +218,6 @@ public virtual PrimitiveDataFrameColumn<bool> ElementwiseNotEquals(DataFrameColu
/// Performs an element wise not-equals on each value in the column
/// </summary>
public virtual PrimitiveDataFrameColumn<bool> ElementwiseNotEquals<T>(T value)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -243,7 +231,6 @@ public virtual PrimitiveDataFrameColumn<bool> ElementwiseGreaterThanOrEqual(Data
/// Performs an element wise greater than or equal on each value in the column
/// </summary>
public virtual PrimitiveDataFrameColumn<bool> ElementwiseGreaterThanOrEqual<T>(T value)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -257,7 +244,6 @@ public virtual PrimitiveDataFrameColumn<bool> ElementwiseLessThanOrEqual(DataFra
/// Performs an element wise less than or equal on each value in the column
/// </summary>
public virtual PrimitiveDataFrameColumn<bool> ElementwiseLessThanOrEqual<T>(T value)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -271,7 +257,6 @@ public virtual PrimitiveDataFrameColumn<bool> ElementwiseGreaterThan(DataFrameCo
/// Performs an element wise greater than on each value in the column
/// </summary>
public virtual PrimitiveDataFrameColumn<bool> ElementwiseGreaterThan<T>(T value)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand All @@ -285,7 +270,6 @@ public virtual PrimitiveDataFrameColumn<bool> ElementwiseLessThan(DataFrameColum
/// Performs an element wise less than on each value in the column
/// </summary>
public virtual PrimitiveDataFrameColumn<bool> ElementwiseLessThan<T>(T value)
where T : unmanaged
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ namespace Microsoft.Data.Analysis
/// <#=method.GetColumnSpecificMethodComments()#>
/// </summary>
public virtual DataFrameColumn <#=method.MethodName#><T>(T value, bool inPlace = false)
where T : unmanaged
<# } #>
<# } #>
<# if (method.MethodType == MethodType.ComparisonScalar) { #>
/// <summary>
/// <#=method.GetColumnSpecificMethodComments()#>
/// </summary>
public virtual PrimitiveDataFrameColumn<bool> <#=method.MethodName#><T>(T value)
where T : unmanaged
<# } #>
<# if (method.MethodType == MethodType.Binary) {#>
public virtual DataFrameColumn <#=method.MethodName#>(DataFrameColumn column, bool inPlace = false)
Expand Down Expand Up @@ -67,7 +65,6 @@ namespace Microsoft.Data.Analysis
/// <#=method.GetColumnSpecificReverseMethodComments()#>
/// </summary>
public virtual DataFrameColumn Reverse<#=method.MethodName#><T>(T value, bool inPlace = false)
where T : unmanaged
<# } #>
{
throw new NotImplementedException();
Expand Down
3 changes: 0 additions & 3 deletions src/Microsoft.Data.Analysis/DecimalConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
namespace Microsoft.Data.Analysis
{
internal interface IDecimalConverter<T>
where T : struct
{
decimal GetDecimal(T value);
}
internal static class DecimalConverter<T>
where T : struct
{
public static IDecimalConverter<T> Instance { get; } = DecimalConverter.GetDecimalConverter<T>();
}
internal static class DecimalConverter
{
public static IDecimalConverter<T> GetDecimalConverter<T>()
where T : struct
{
if (typeof(T) == typeof(bool))
{
Expand Down
3 changes: 0 additions & 3 deletions src/Microsoft.Data.Analysis/DoubleConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
namespace Microsoft.Data.Analysis
{
internal interface IDoubleConverter<T>
where T : struct
{
double GetDouble(T value);
}
internal static class DoubleConverter<T>
where T : struct
{
public static IDoubleConverter<T> Instance { get; } = DoubleConverter.GetDoubleConverter<T>();
}
internal static class DoubleConverter
{
public static IDoubleConverter<T> GetDoubleConverter<T>()
where T : struct
{
if (typeof(T) == typeof(bool))
{
Expand Down
Loading

0 comments on commit dc4f9b0

Please sign in to comment.