[Suggest] make Ndarray == closer to numpy
ChengYen-Tang opened this issue · 2 comments
ChengYen-Tang commented
There is no Equals method for ndarray in numpy, so I think in numpy.net if you want to compare ndarray instence, you should use Equals instead of ==.
ndarray a1 = new ndarray();
ndarray a2 = new ndarray();
a. Compare elements in two ndarrays
ndarray result = a1 == a2;
b. Compare instance of two objects
bool result = a1.Equals(a2);
c. Check ndarray is null
bool result = a1 is null;
bool result = a1 is not null; //need C# 7.0 or later
--Solution--
1. set <LangVersion>latest</LangVersion> in csproj
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version#c-language-version-reference
2. bool result = !(a1 is null);
If you accept my proposal, but you are not free, I can assist you.
KevinBaselinesw commented
== is a special .NET case. If you override that, you also have to override != and that creates other problems in the code.
Try using np.equals() and np.array_equal() instead.
Also, I already overide ndarray.Equals()
ChengYen-Tang commented
