SciSharp / NumSharp

High Performance Computation for N-D Tensors in .NET, similar API to NumPy.
https://github.com/SciSharp
Apache License 2.0
1.34k stars 188 forks source link

Debug.Assert(...) causes tests to stop the entire process #448

Open Nucs opened 3 years ago

bojake commented 1 year ago

The problem with this test is that the values array is not being broadcast/broadened properly. The assert expects the values array to match the size of the indices array. In this test case, though, the selector ("np < 3") is choosing 2 elements out of the 6 and the result is applying "-2" (which is another bug, btw). Changing the result value to "-2.0" gets past another bug but then you see where the actual bug in the SetIndiceND method resides. Before SetIndicesND can be called the "values" must be made to match the expected buffer size through implicit broadening.

If you give "-2" as the value then the framework thinks you are setting the "size" of the NDArray for values instead of setting an actual value array of INTs. Oops.