[issue39864] IndexError gives wrong axis info

2020-03-05 Thread Ningyi Du


Ningyi Du  added the comment:

I believe it's a bug. The axis 0 is misleading.  However, it is a problem
for numpy developers. Thank you for your time.

On Thu, Mar 5, 2020, 10:42 AM Peter Otten  wrote:

>
> Peter Otten <__pete...@web.de> added the comment:
>
> This is not a bug (and if it were you would have to report to numpy, not
> cpython).
>
> Consider:
>
> >>> import numpy
> >>> a = numpy.zeros((2,2,2))
> >>> a[0,2]
> Traceback (most recent call last):
>   File "", line 1, in 
> IndexError: index 2 is out of bounds for axis 1 with size 2
>
> This is probably the message you expect. However, if you write
> >>> a[0][2]
> Traceback (most recent call last):
>   File "", line 1, in 
> IndexError: index 2 is out of bounds for axis 0 with size 2
>
> you split the operation into two steps, and the second axis of a is
> effectively the first axis of a[0].
>
> --
> nosy: +peter.otten -steven.daprano
>
> ___
> Python tracker 
> 
> ___
>

--
title: IndexError  gives wrong axis info -> IndexError gives wrong axis info

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39864] IndexError gives wrong axis info

2020-03-05 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

This is not a bug (and if it were you would have to report to numpy, not 
cpython).

Consider:

>>> import numpy
>>> a = numpy.zeros((2,2,2))
>>> a[0,2]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: index 2 is out of bounds for axis 1 with size 2

This is probably the message you expect. However, if you write
>>> a[0][2]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: index 2 is out of bounds for axis 0 with size 2

you split the operation into two steps, and the second axis of a is effectively 
the first axis of a[0].

--
nosy: +peter.otten -steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39864] IndexError gives wrong axis info

2020-03-05 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

This is a numpy issue, you will need to report it to the numpy developers. But 
first you need to check that it really is a bug. What makes you think it is a 
bug? In your example, index 3 looks out of bounds to me. Remember that indexes 
start at 0, not 1.

In any case, this has nothing to do with us, numpy is an independent project, 
you will need to report it to them.

--
nosy: +steven.daprano
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39864] IndexError gives wrong axis info

2020-03-05 Thread Ningyi Du


Ningyi Du  added the comment:

This is a simple test:

test=np.zeros((2,3,4))
print(test[1][3][1])

IndexErrorTraceback (most recent call last)
 in 
  1 test=np.zeros((2,3,4))
> 2 print(test[1][3][1])

IndexError: index 3 is out of bounds for axis 0 with size 3

--
nosy:  -xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39864] IndexError gives wrong axis info

2020-03-05 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Please include a sample script to reproduce the program along with a 
description of why you think it's an error in CPython. This seems to be a 
custom exception raised by a library.

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39864] IndexError gives wrong axis info

2020-03-05 Thread Ningyi Du


New submission from Ningyi Du :

IndexError: index 11 is out of bounds for axis 0 with size 11

The actual error is not with axis 0, but axis 3.

error message:
168 if iJ>=9:
169 print(iE,iE0,iEtemp,iJ,li,lf,mlf+lf)
--> 170 SS[iEtemp][iJ][li][lf][mlf+lf]= 
FF(jf,mf,lf,mlf,ji,mi,li,J)*SJ[iCh][jCh]
171 
172 sumSJ1 += np.abs(SJ0[iCh][jCh])**2

IndexError: index 11 is out of bounds for axis 0 with size 11

--
messages: 363433
nosy: ningyidu
priority: normal
severity: normal
status: open
title: IndexError  gives wrong axis info

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com