There seems to be a bug in the np.meshgrid() function. It has something to do with the way the unmanaged memory is handeld but I havent tried to understand the details.
Why hidden ? Well, lets say we have the following code:
var meshAB = np.meshgrid(np.arange(3), np.arange(3));
meshAB.Item1 seems to be ok, but meshAB.Item2 hides a nasty problem.
Strangely enough, when one makes a clone of Item2, the cloned values are OK! This is also my quick fix for now.
So to summary, the code below:
var meshAB = np.meshgrid(np.arange(3), np.arange(3));
Console.WriteLine("meshAB.Item1.flatten(): " + meshAB.Item1.flatten().ToString());
Console.WriteLine("meshAB.Item2.flatten(): " + meshAB.Item2.flatten().ToString());
NDArray a = meshAB.Item1.Clone();
NDArray b = meshAB.Item2.Clone();
Console.WriteLine("a.flatten(): " +a.flatten().ToString());
Console.WriteLine("b.flatten(): " +b.flatten().ToString());
There seems to be a bug in the
np.meshgrid()
function. It has something to do with the way the unmanaged memory is handeld but I havent tried to understand the details.Why hidden ? Well, lets say we have the following code:
meshAB.Item1
seems to be ok, butmeshAB.Item2
hides a nasty problem. Strangely enough, when one makes a clone of Item2, the cloned values are OK! This is also my quick fix for now.So to summary, the code below:
Will output:
The bug is nasty because in inspector we also see ok values which is not true. Here is an image:![image](https://user-images.githubusercontent.com/61494668/80100219-f6ff1e00-856f-11ea-8da8-91caf7e164af.png)