Skip to content

Commit 00d8700

Browse files
committed
Revert "Operator > and < for int and float #362"
This reverts commit 3a2792c.
1 parent 7938e0a commit 00d8700

4 files changed

Lines changed: 7 additions & 166 deletions

File tree

src/NumSharp.Core/NumSharp.Core.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
<PackageOutputPath>../../packages</PackageOutputPath>
1010
<Description>NumSharp is the fundamental library for scientific computing with .NET providing a similar API to python's numpy scientific library. NumSharp has full N-D, broadcasting and axis support. If you want to use .NET to get started with machine learning, NumSharp will be your best tool.</Description>
1111
<PackageProjectUrl>https://github.com/SciSharp</PackageProjectUrl>
12-
<Copyright>2020 © SciSharp STACK Team</Copyright>
12+
<Copyright>2019 © SciSharp STACK Team</Copyright>
1313
<RepositoryUrl>https://github.com/SciSharp/NumSharp</RepositoryUrl>
14-
<PackageReleaseNotes></PackageReleaseNotes>
15-
<AssemblyVersion>0.20.6</AssemblyVersion>
16-
<FileVersion>0.20.6</FileVersion>
14+
<PackageReleaseNotes>Rewrite of the NDArray's getter mechanism. Added np.nonzero, np.maximum, np.minimum, np.all, np.any. np.clip: Added @out argument. Added NPTypeCode.Float as an alias to NPTypeCode.Single.</PackageReleaseNotes>
15+
<AssemblyVersion>0.20.5</AssemblyVersion>
16+
<FileVersion>0.20.5</FileVersion>
1717
<RepositoryType>git</RepositoryType>
1818
<PackageTags>Numpy, NumSharp, MachineLearning, Math, Scientific, Numeric, Mathlab, SciSharp</PackageTags>
1919
<PackageLicenseUrl></PackageLicenseUrl>
@@ -23,7 +23,7 @@
2323
<Product>NumSharp</Product>
2424
<Company>SciSharp STACK</Company>
2525
<RootNamespace>NumSharp</RootNamespace>
26-
<Version>0.20.6</Version>
26+
<Version>0.20.5</Version>
2727
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>
2828
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
2929
<AssemblyOriginatorKeyFile>Open.snk</AssemblyOriginatorKeyFile>

src/NumSharp.Core/Operations/Elementwise/NDArray.Greater.cs

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,7 @@
1-
using System;
2-
using System.Diagnostics.CodeAnalysis;
3-
using System.Runtime.CompilerServices;
4-
using NumSharp.Backends;
5-
using NumSharp.Generic;
6-
using NumSharp.Utilities;
7-
8-
namespace NumSharp
1+
namespace NumSharp
92
{
103
public partial class NDArray
114
{
12-
[MethodImpl((MethodImplOptions)768)]
13-
[SuppressMessage("ReSharper", "JoinDeclarationAndInitializer")]
14-
[SuppressMessage("ReSharper", "CompareOfFloatsByEqualityOperator")]
15-
public static unsafe NumSharp.Generic.NDArray<bool> operator >(NDArray lhs, NDArray rhs)
16-
{
17-
if(lhs.typecode == NPTypeCode.Int32 && rhs.typecode == NPTypeCode.Int32)
18-
{
19-
if (lhs.Shape.IsScalar && rhs.Shape.IsScalar)
20-
return NDArray.Scalar<bool>(*(int*)lhs.Address > *(int*)rhs.Address).MakeGeneric<bool>();
21-
22-
(Shape BroadcastedLeftShape, Shape BroadcastedRightShape) = DefaultEngine.Broadcast(lhs.Shape, rhs.Shape);
23-
var lhs_address = (int*)lhs.Address;
24-
var rhs_address = (int*)rhs.Address;
25-
var ret = new NDArray<bool>(new Shape(BroadcastedLeftShape.dimensions), true);
26-
Shape retShape = ret.Shape;
27-
28-
//iterate
29-
var ret_address = (bool*)ret.Address;
30-
var incr = new NDCoordinatesIncrementor(BroadcastedLeftShape.dimensions); //doesn't matter which side it is.
31-
int[] current = incr.Index;
32-
do
33-
{
34-
*(ret_address + retShape.GetOffset(current)) = (*(lhs_address + BroadcastedLeftShape.GetOffset(current))) > *(rhs_address + BroadcastedRightShape.GetOffset(current));
35-
} while (incr.Next() != null);
36-
37-
return ret;
38-
}
39-
else if (lhs.typecode == NPTypeCode.Float && rhs.typecode == NPTypeCode.Float)
40-
{
41-
if (lhs.Shape.IsScalar && rhs.Shape.IsScalar)
42-
return NDArray.Scalar<bool>(*(float*)lhs.Address > *(float*)rhs.Address).MakeGeneric<bool>();
43-
44-
(Shape BroadcastedLeftShape, Shape BroadcastedRightShape) = DefaultEngine.Broadcast(lhs.Shape, rhs.Shape);
45-
var lhs_address = (float*)lhs.Address;
46-
var rhs_address = (float*)rhs.Address;
47-
var ret = new NDArray<bool>(new Shape(BroadcastedLeftShape.dimensions), true);
48-
Shape retShape = ret.Shape;
49-
50-
//iterate
51-
var ret_address = (bool*)ret.Address;
52-
var incr = new NDCoordinatesIncrementor(BroadcastedLeftShape.dimensions); //doesn't matter which side it is.
53-
int[] current = incr.Index;
54-
do
55-
{
56-
*(ret_address + retShape.GetOffset(current)) = (*(lhs_address + BroadcastedLeftShape.GetOffset(current))) > *(rhs_address + BroadcastedRightShape.GetOffset(current));
57-
} while (incr.Next() != null);
58-
59-
return ret;
60-
}
61-
else
62-
{
63-
throw new NotImplementedException($"{lhs.typecode} > {rhs.typecode}");
64-
}
65-
}
66-
675
public static NumSharp.Generic.NDArray<bool> operator >(NDArray np, int obj)
686
{
697
return (np > (System.Object)obj);

src/NumSharp.Core/Operations/Elementwise/NDArray.Lower.cs

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,7 @@
1-
using System;
2-
using NumSharp.Backends;
3-
using NumSharp.Generic;
4-
using NumSharp.Utilities;
5-
6-
namespace NumSharp
1+
namespace NumSharp
72
{
83
public partial class NDArray
94
{
10-
public static unsafe NumSharp.Generic.NDArray<bool> operator <(NDArray lhs, NDArray rhs)
11-
{
12-
if (lhs.typecode == NPTypeCode.Int32 && rhs.typecode == NPTypeCode.Int32)
13-
{
14-
if (lhs.Shape.IsScalar && rhs.Shape.IsScalar)
15-
return NDArray.Scalar<bool>(*(int*)lhs.Address < *(int*)rhs.Address).MakeGeneric<bool>();
16-
17-
(Shape BroadcastedLeftShape, Shape BroadcastedRightShape) = DefaultEngine.Broadcast(lhs.Shape, rhs.Shape);
18-
var lhs_address = (int*)lhs.Address;
19-
var rhs_address = (int*)rhs.Address;
20-
var ret = new NDArray<bool>(new Shape(BroadcastedLeftShape.dimensions), true);
21-
Shape retShape = ret.Shape;
22-
23-
//iterate
24-
var ret_address = (bool*)ret.Address;
25-
var incr = new NDCoordinatesIncrementor(BroadcastedLeftShape.dimensions); //doesn't matter which side it is.
26-
int[] current = incr.Index;
27-
do
28-
{
29-
*(ret_address + retShape.GetOffset(current)) = (*(lhs_address + BroadcastedLeftShape.GetOffset(current))) < *(rhs_address + BroadcastedRightShape.GetOffset(current));
30-
} while (incr.Next() != null);
31-
32-
return ret;
33-
}
34-
else if (lhs.typecode == NPTypeCode.Float && rhs.typecode == NPTypeCode.Float)
35-
{
36-
if (lhs.Shape.IsScalar && rhs.Shape.IsScalar)
37-
return NDArray.Scalar<bool>(*(float*)lhs.Address < *(float*)rhs.Address).MakeGeneric<bool>();
38-
39-
(Shape BroadcastedLeftShape, Shape BroadcastedRightShape) = DefaultEngine.Broadcast(lhs.Shape, rhs.Shape);
40-
var lhs_address = (float*)lhs.Address;
41-
var rhs_address = (float*)rhs.Address;
42-
var ret = new NDArray<bool>(new Shape(BroadcastedLeftShape.dimensions), true);
43-
Shape retShape = ret.Shape;
44-
45-
//iterate
46-
var ret_address = (bool*)ret.Address;
47-
var incr = new NDCoordinatesIncrementor(BroadcastedLeftShape.dimensions); //doesn't matter which side it is.
48-
int[] current = incr.Index;
49-
do
50-
{
51-
*(ret_address + retShape.GetOffset(current)) = (*(lhs_address + BroadcastedLeftShape.GetOffset(current))) < *(rhs_address + BroadcastedRightShape.GetOffset(current));
52-
} while (incr.Next() != null);
53-
54-
return ret;
55-
}
56-
else
57-
{
58-
throw new NotImplementedException($"{lhs.typecode} < {rhs.typecode}");
59-
}
60-
}
61-
625
public static NumSharp.Generic.NDArray<bool> operator <(NDArray np, int obj)
636
{
647
return (np < (System.Object)obj);

test/NumSharp.UnitTest/Operations/NDArray.GRATER.Test.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)