[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#899159: [numpy/grave] Incorrect Memory offset in numpy.uint8 arrays



Package: python3-numpy
Version: 1:1.14.3-2
Severity: grave
X-Debbugs-CC: debian-science@lists.debian.org

Dear Numpy maintainers,

As a student/researcher, I cannot bear any library that *SILENTLY*
produces totally wrong result. This time numpy just triggered me,
and I wish you can understand that after examing the minimal
repro code:

    import numpy as np
    print(np.__path__, np.__version__)
    N = 257
    
	# integer: good
    x = np.zeros((N, N), dtype=np.int)
    for i in range(N):
        for j in range(N):
            x[i,j] = max(i, j)
    print(x)
    
	# uint8: fatal
    x = np.zeros((N, N), dtype=np.uint8)
    for i in range(N):
        for j in range(N):
            x[i,j] = max(i, j)
    print(x)

Output:

    ['/usr/lib/python3/dist-packages/numpy'] 1.14.3
    [[  0   1   2 ... 254 255 256]
     [  1   1   2 ... 254 255 256]
     [  2   2   2 ... 254 255 256]
     ...
     [254 254 254 ... 254 255 256]
     [255 255 255 ... 255 255 256]
     [256 256 256 ... 256 256 256]]
    [[  0   1   2 ... 254 255   0]
     [  1   1   2 ... 254 255   0]
     [  2   2   2 ... 254 255   0]
     ...
     [254 254 254 ... 254 255   0]
     [255 255 255 ... 255 255   0]
     [  0   0   0 ...   0   0   0]]

It means that the memory offset calculation for numpy.uint8
array is totally incorrect!

This is producible by Debian's numpy package and that from Pypi.

Attachment: signature.asc
Description: PGP signature


Reply to: