Quansight-Labs / numpy.net

A port of NumPy to .Net
BSD 3-Clause "New" or "Revised" License
128 stars 14 forks source link

Converting rotated array to bytes, throws IndexOutOfRangeException #53

Closed Taz145 closed 1 year ago

Taz145 commented 1 year ago

Possibly related to https://github.com/Quansight-Labs/numpy.net/issues/52

var arr1 = np.arange(24).reshape((2,3,4));
arr1 = np.rot90(arr1);
arr1.tobytes();

The above section will throw an IndexOutOfRangeException.

Full Error details:

Message: 
System.IndexOutOfRangeException : Index was outside the bounds of the array.

  Stack Trace: 
MemoryAccess.GetByte(Int32[] Array, Int64 byte_index)
MemCopy.MemCpyInt32ToUBytes(VoidPtr Dest, Int64 DestOffset, VoidPtr Src, Int64 SrcOffset, Int64 totalBytesToCopy)
MemCopy.MemCpyToUBytes(VoidPtr Dest, Int64 DestOffset, VoidPtr Src, Int64 SrcOffset, Int64 totalBytesToCopy)
MemCopy.MemCpy(VoidPtr Dest, Int64 DestOffset, VoidPtr Src, Int64 SrcOffset, Int64 totalBytesToCopy)
numpyAPI.MemCpy(VoidPtr Dest, Int64 DestOffset, VoidPtr Src, Int64 SrcOffset, Int64 Length)
NpyCoreApi.GetBytes(ndarray arr, Byte[] bytes, NPY_ORDER order)
ndarray.ToString(NPY_ORDER order)
ndarray.tobytes(NPY_ORDER order)

Copying the array before converting to bytes does still work as a temporary workaround for the issue.

KevinBaselinesw commented 1 year ago

0.9.85.1 should fix this problem