Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32816 > unrolled thread

Re: error

Started byDave Angel <d@davea.name>
First post2012-11-06 08:05 -0500
Last post2012-11-12 10:04 -0500
Articles 9 — 4 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: error Dave Angel <d@davea.name> - 2012-11-06 08:05 -0500
    Re: error woooee <woooee@gmail.com> - 2012-11-06 11:59 -0800
      Re: error Dave Angel <d@davea.name> - 2012-11-08 11:33 -0500
      Re: error Jerry Hill <malaclypse2@gmail.com> - 2012-11-08 11:41 -0500
      Re: error inshu chauhan <insideshoes@gmail.com> - 2012-11-09 11:53 +0100
      Re: error inshu chauhan <insideshoes@gmail.com> - 2012-11-09 12:47 +0100
      Re: error inshu chauhan <insideshoes@gmail.com> - 2012-11-09 14:59 +0100
      Re: error inshu chauhan <insideshoes@gmail.com> - 2012-11-09 15:08 +0100
      Re: error Dave Angel <d@davea.name> - 2012-11-12 10:04 -0500

#32816 — Re: error

FromDave Angel <d@davea.name>
Date2012-11-06 08:05 -0500
SubjectRe: error
Message-ID<mailman.3320.1352207175.27098.python-list@python.org>
On 11/06/2012 07:31 AM, inshu chauhan wrote:
> I am getting this error while running my programme.. :
>
> error: index is out of range

Please paste the whole error, including the traceback.  It'll show you
the line that had the error, as well as the calling sequence that got
you there.

>
>  I cannot find a valid reason for it in my prog can somebody suggest what
> may be possible reasons for this error..
>
> The part of the code is :
>
> def addpoints (data, points, ix, iy): # makes a list of relevant points
>     if 0 < ix < data.width and 0 < iy < data.height:
>         point = data[ix, iy]

Tell us the type of the parameters.  Perhaps data is of type Zanzibar, 
and the first subscript is the height, and the second is the width? 
Show us your class definition, since data is obviously not a built-in
collection.

>         if point != (0.0, 0.0, 0.0):
>             points.append(point)
>     return points
>
> for dx in xrange(-mask_size2, mask_size2 + 1):
>         for dy in xrange(-mask_size2, mask_size2 + 1):

What is the meaning and value of mask_size2 ?  Is it a negative int?

>             ix, iy = x + dx, y + dy
>             addpoints(data, points, ix , iy )
>
>

BTW, this function's initial comment is incorrect.  It doesn't make a
list, it appends to one passed in.  And there's no point in returning
that list, since it has already been modified.  By good convention, a
simple function either returns a result or modifies its parameter, it
shouldn't do both.  Obviously there are exceptions for complex
functions, but even then, for a single collection, it should either be
modified in place, or created and returned, not both.

-- 

DaveA

[toc] | [next] | [standalone]


#32839

Fromwoooee <woooee@gmail.com>
Date2012-11-06 11:59 -0800
Message-ID<78f26f00-2c91-47b3-aef0-3eaeb8ae6f91@u4g2000pbo.googlegroups.com>
In reply to#32816
From this line, "data" appears to be a class
    if 0 < ix < data.width and 0 < iy < data.height:
From this line, "data" appears to be a list, although a two
dimensional list would be accessed as data[ix][iy]
        point = data[ix, iy]

Also, returning a list from a function is a matter of preference.
Some people argue that it should be returned to make it obvious.  If
you do not know the difference between what is mutable and what is not
mutable, then return everything until you do.

[toc] | [prev] | [next] | [standalone]


#32960

FromDave Angel <d@davea.name>
Date2012-11-08 11:33 -0500
Message-ID<mailman.3448.1352392459.27098.python-list@python.org>
In reply to#32839
On 11/08/2012 08:47 AM, inshu chauhan wrote:
> Actually data is neither a zanzibar nor a class nor a list.. its a yml
> image. with pixels
> I am trying to access pixels of a 3D image through this programme..
> 


You want us to keep guessing?  And without supplying any new
information?  There's no such thing as a yml image in Python, though
there might be some library that supports such a thing with some class
structure.  And you just might have downloaded it from the
http://www.ymlgroup.com/obscurehiddenlocation/downloads site, and
imported  it using  from notzanzibar import DataType.

Then you'd have instantiated it in some code like
  data = DataType(filename)

and then the type of data would be notzanzibar.DataType  and the docs
would be probably available somewhere on www.invalid.com/docs

The only new guess:

A 3D image would presumably have 3 subscripts, and you're only supplying
two.



If you want help, be explicit:

1) what version of CPython are you using, and on what OS?
2) what web site did you download some extra library from ?
3) what import statement did you use ?
4) How are all those global variables initialized ?
5) What command did you use to start the script ?  Did you run it from
command.com, or from some IDE ?
5) Exactly what error message did you get, including the traceback ?
6) What have you done to try to figure out your own error?




-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#32961

FromJerry Hill <malaclypse2@gmail.com>
Date2012-11-08 11:41 -0500
Message-ID<mailman.3450.1352392886.27098.python-list@python.org>
In reply to#32839
On Thu, Nov 8, 2012 at 8:47 AM, inshu chauhan <insideshoes@gmail.com> wrote:
> Actually data is neither a zanzibar nor a class nor a list.. its a yml
> image. with pixels
> I am trying to access pixels of a 3D image through this programme..

When you're having trouble debugging a program, and decide to turn to
a mailing list for help, it can be hard to know what information
people are going to need to help you. The easiest way to know that
people have enough information to help debug your program is to
provide a short, self contained, example of your code that
demonstrates the problem that you're having.

See http://sscce.org/ for more on why it's helpful, and how to turn a
long program into sample code that will let us help you.

-- 
Jerry

[toc] | [prev] | [next] | [standalone]


#33011

Frominshu chauhan <insideshoes@gmail.com>
Date2012-11-09 11:53 +0100
Message-ID<mailman.3487.1352458445.27098.python-list@python.org>
In reply to#32839

[Multipart message — attachments visible in raw view] — view raw

http://www.ymlgroup.com/obscurehiddenlocation/downloads site, and
> imported  it using  from notzanzibar import DataType.
>

No i haven't downloaded it.. and this site is not opening...

>
> Then you'd have instantiated it in some code like
>   data = DataType(filename)
>
> and then the type of data would be notzanzibar.DataType  and the docs
> would be probably available somewhere on www.invalid.com/docs
>

This site is also blocked here.

>
> The only new guess:
>
> A 3D image would presumably have 3 subscripts, and you're only supplying
> two.
>

Yes a 3D image has 3 subscripts but m trying to access all three through
using only  2 subsscripts i.e X and Y


>
> If you want help, be explicit:
>
> 1) what version of CPython are you using, and on what OS?
>

I am using 2.7.3 on windows 7

2) what web site did you download some extra library from ?
>

The only extra libary i am using is Opencv , downloaded from
http://sourceforge.net/projects/opencvlibrary/



> 3) what import statement did you use ?
>

import cv

4) How are all those global variables initialized ?
>
see attached file

> 5) What command did you use to start the script ?  Did you run it from
> command.com, or from some IDE ?
>

Yes I am running it through IDLE GUI


> 5) Exactly what error message did you get, including the traceback ?
>

 Traceback (most recent call last):
  File "Z:\modules\Masking_an_image_dynamically.py", line 155, in <module>
    AccessPixels(data)
  File "Z:\modules\.py", line 147, in AccessPixels
    CreateMask(data, x, y)
  File "Z:\modules\new_classification.py", line 110, in CreateMask
    point = data[iy, ix ]
error: index is out of range

The line numbers here and the file attached may be different because I have
removed a lot of print statements which I was using to debug the error..



> 6) What have you done to try to figure out your own error?
>

I have trying print out variables and Indices at each step..


Zero Piraeus : Where are you ?

[toc] | [prev] | [next] | [standalone]


#33017

Frominshu chauhan <insideshoes@gmail.com>
Date2012-11-09 12:47 +0100
Message-ID<mailman.3488.1352461657.27098.python-list@python.org>
In reply to#32839

[Multipart message — attachments visible in raw view] — view raw

I attached a wrong file...Right file is attached here


On Fri, Nov 9, 2012 at 11:53 AM, inshu chauhan <insideshoes@gmail.com>wrote:

>
>
>
>
> http://www.ymlgroup.com/obscurehiddenlocation/downloads site, and
>> imported  it using  from notzanzibar import DataType.
>>
>
> No i haven't downloaded it.. and this site is not opening...
>
>>
>> Then you'd have instantiated it in some code like
>>   data = DataType(filename)
>>
>> and then the type of data would be notzanzibar.DataType  and the docs
>> would be probably available somewhere on www.invalid.com/docs
>>
>
> This site is also blocked here.
>
>>
>> The only new guess:
>>
>> A 3D image would presumably have 3 subscripts, and you're only supplying
>> two.
>>
>
> Yes a 3D image has 3 subscripts but m trying to access all three through
> using only  2 subsscripts i.e X and Y
>
>
>>
>> If you want help, be explicit:
>>
>> 1) what version of CPython are you using, and on what OS?
>>
>
> I am using 2.7.3 on windows 7
>
> 2) what web site did you download some extra library from ?
>>
>
> The only extra libary i am using is Opencv , downloaded from
> http://sourceforge.net/projects/opencvlibrary/
>
>
>
>> 3) what import statement did you use ?
>>
>
> import cv
>
> 4) How are all those global variables initialized ?
>>
> see attached file
>
>> 5) What command did you use to start the script ?  Did you run it from
>> command.com, or from some IDE ?
>>
>
> Yes I am running it through IDLE GUI
>
>
>> 5) Exactly what error message did you get, including the traceback ?
>>
>
>  Traceback (most recent call last):
>   File "Z:\modules\Masking_an_image_dynamically.py", line 155, in <module>
>     AccessPixels(data)
>   File "Z:\modules\.py", line 147, in AccessPixels
>     CreateMask(data, x, y)
>   File "Z:\modules\new_classification.py", line 110, in CreateMask
>     point = data[iy, ix ]
>
> error: index is out of range
>
> The line numbers here and the file attached may be different because I
> have removed a lot of print statements which I was using to debug the
> error..
>
>
>
>> 6) What have you done to try to figure out your own error?
>>
>
> I have trying print out variables and Indices at each step..
>
>
> Zero Piraeus : Where are you ?
>
>
>

[toc] | [prev] | [next] | [standalone]


#33024

Frominshu chauhan <insideshoes@gmail.com>
Date2012-11-09 14:59 +0100
Message-ID<mailman.3491.1352469568.27098.python-list@python.org>
In reply to#32839

[Multipart message — attachments visible in raw view] — view raw

Please Ignore the above two files attached,,, See this one


On Fri, Nov 9, 2012 at 12:47 PM, inshu chauhan <insideshoes@gmail.com>wrote:

> I attached a wrong file...Right file is attached here
>
>
> On Fri, Nov 9, 2012 at 11:53 AM, inshu chauhan <insideshoes@gmail.com>wrote:
>
>>
>>
>>
>>
>> http://www.ymlgroup.com/obscurehiddenlocation/downloads site, and
>>> imported  it using  from notzanzibar import DataType.
>>>
>>
>> No i haven't downloaded it.. and this site is not opening...
>>
>>>
>>> Then you'd have instantiated it in some code like
>>>   data = DataType(filename)
>>>
>>> and then the type of data would be notzanzibar.DataType  and the docs
>>> would be probably available somewhere on www.invalid.com/docs
>>>
>>
>> This site is also blocked here.
>>
>>>
>>> The only new guess:
>>>
>>> A 3D image would presumably have 3 subscripts, and you're only supplying
>>> two.
>>>
>>
>> Yes a 3D image has 3 subscripts but m trying to access all three through
>> using only  2 subsscripts i.e X and Y
>>
>>
>>>
>>> If you want help, be explicit:
>>>
>>> 1) what version of CPython are you using, and on what OS?
>>>
>>
>> I am using 2.7.3 on windows 7
>>
>> 2) what web site did you download some extra library from ?
>>>
>>
>> The only extra libary i am using is Opencv , downloaded from
>> http://sourceforge.net/projects/opencvlibrary/
>>
>>
>>
>>> 3) what import statement did you use ?
>>>
>>
>> import cv
>>
>> 4) How are all those global variables initialized ?
>>>
>> see attached file
>>
>>> 5) What command did you use to start the script ?  Did you run it from
>>> command.com, or from some IDE ?
>>>
>>
>> Yes I am running it through IDLE GUI
>>
>>
>>> 5) Exactly what error message did you get, including the traceback ?
>>>
>>
>>  Traceback (most recent call last):
>>   File "Z:\modules\Masking_an_image_dynamically.py", line 155, in <module>
>>     AccessPixels(data)
>>   File "Z:\modules\.py", line 147, in AccessPixels
>>     CreateMask(data, x, y)
>>   File "Z:\modules\new_classification.py", line 110, in CreateMask
>>     point = data[iy, ix ]
>>
>> error: index is out of range
>>
>> The line numbers here and the file attached may be different because I
>> have removed a lot of print statements which I was using to debug the
>> error..
>>
>>
>>
>>> 6) What have you done to try to figure out your own error?
>>>
>>
>> I have trying print out variables and Indices at each step..
>>
>>
>> Zero Piraeus : Where are you ?
>>
>>
>>
>

[toc] | [prev] | [next] | [standalone]


#33026

Frominshu chauhan <insideshoes@gmail.com>
Date2012-11-09 15:08 +0100
Message-ID<mailman.3493.1352470116.27098.python-list@python.org>
In reply to#32839

[Multipart message — attachments visible in raw view] — view raw

Actually this one.. and its the last..


On Fri, Nov 9, 2012 at 2:59 PM, inshu chauhan <insideshoes@gmail.com> wrote:

> Please Ignore the above two files attached,,, See this one
>
>
> On Fri, Nov 9, 2012 at 12:47 PM, inshu chauhan <insideshoes@gmail.com>wrote:
>
>> I attached a wrong file...Right file is attached here
>>
>>
>> On Fri, Nov 9, 2012 at 11:53 AM, inshu chauhan <insideshoes@gmail.com>wrote:
>>
>>>
>>>
>>>
>>>
>>> http://www.ymlgroup.com/obscurehiddenlocation/downloads site, and
>>>> imported  it using  from notzanzibar import DataType.
>>>>
>>>
>>> No i haven't downloaded it.. and this site is not opening...
>>>
>>>>
>>>> Then you'd have instantiated it in some code like
>>>>   data = DataType(filename)
>>>>
>>>> and then the type of data would be notzanzibar.DataType  and the docs
>>>> would be probably available somewhere on www.invalid.com/docs
>>>>
>>>
>>> This site is also blocked here.
>>>
>>>>
>>>> The only new guess:
>>>>
>>>> A 3D image would presumably have 3 subscripts, and you're only supplying
>>>> two.
>>>>
>>>
>>> Yes a 3D image has 3 subscripts but m trying to access all three through
>>> using only  2 subsscripts i.e X and Y
>>>
>>>
>>>>
>>>> If you want help, be explicit:
>>>>
>>>> 1) what version of CPython are you using, and on what OS?
>>>>
>>>
>>> I am using 2.7.3 on windows 7
>>>
>>> 2) what web site did you download some extra library from ?
>>>>
>>>
>>> The only extra libary i am using is Opencv , downloaded from
>>> http://sourceforge.net/projects/opencvlibrary/
>>>
>>>
>>>
>>>> 3) what import statement did you use ?
>>>>
>>>
>>> import cv
>>>
>>> 4) How are all those global variables initialized ?
>>>>
>>> see attached file
>>>
>>>> 5) What command did you use to start the script ?  Did you run it from
>>>> command.com, or from some IDE ?
>>>>
>>>
>>> Yes I am running it through IDLE GUI
>>>
>>>
>>>> 5) Exactly what error message did you get, including the traceback ?
>>>>
>>>
>>>  Traceback (most recent call last):
>>>   File "Z:\modules\Masking_an_image_dynamically.py", line 155, in
>>> <module>
>>>     AccessPixels(data)
>>>   File "Z:\modules\.py", line 147, in AccessPixels
>>>     CreateMask(data, x, y)
>>>   File "Z:\modules\new_classification.py", line 110, in CreateMask
>>>     point = data[iy, ix ]
>>>
>>> error: index is out of range
>>>
>>> The line numbers here and the file attached may be different because I
>>> have removed a lot of print statements which I was using to debug the
>>> error..
>>>
>>>
>>>
>>>> 6) What have you done to try to figure out your own error?
>>>>
>>>
>>> I have trying print out variables and Indices at each step..
>>>
>>>
>>> Zero Piraeus : Where are you ?
>>>
>>>
>>>
>>
>

[toc] | [prev] | [next] | [standalone]


#33184

FromDave Angel <d@davea.name>
Date2012-11-12 10:04 -0500
Message-ID<mailman.3587.1352732676.27098.python-list@python.org>
In reply to#32839
On 11/09/2012 09:08 AM, inshu chauhan wrote:
> Actually this one.. and its the last..
> 
> <snip>
>>>>>
>>>>
>>>> The only extra libary i am using is Opencv , downloaded from
>>>> http://sourceforge.net/projects/opencvlibrary/
>>>>
>>>>

and numpy.

>>>>
>>>>> 3) what import statement did you use ?
>>>>>
>>>>
>>>> import cv
>>>>
<snip>
>>>>
>>>>> 5) Exactly what error message did you get, including the traceback ?
>>>>>
>>>>
>>>>  Traceback (most recent call last):
>>>>   File "Z:\modules\Masking_an_image_dynamically.py", line 155, in
>>>> <module>
>>>>     AccessPixels(data)
>>>>   File "Z:\modules\.py", line 147, in AccessPixels
>>>>     CreateMask(data, x, y)
>>>>   File "Z:\modules\new_classification.py", line 110, in CreateMask
>>>>     point = data[iy, ix ]
>>>>
>>>> error: index is out of range
>>>>
>>>> The line numbers here and the file attached may be different because I
>>>> have removed a lot of print statements which I was using to debug the
>>>> error..
>>>>

More than that is wrong.  The file names are different.  If I guess from
your source file that all this code is in your own script,
"Masking_an_image_dynamically.py"   then two of the filenames in the
traceback indicate big problems.

Further, on the same assumption, the function CreateMask has no such
line as    'point = data[iy, ix]

I did spend some time with the website
http://sourceforge.net/projects/opencvlibrary/

but all I see is C++ docs, and since it's enormous, I didn't think I'm
likely to find out anything directly from there.  The particular thing I
was looking for was whether rows or columns are specified first when
treating 'data" as a list of lists.    In other words, I look at the two
lines:

CreateMask(data, x, y)
and
point = data[iy, ix]

and try to figure out which one is unreasonable.  Find out the
convention used in the module, and stay consistent with it.  In
Photoshop. an 8x10 is a portrait layout, while 10x8 is landscape.  In
other words, row number is first.  But i have no idea what Opencv uses.

Since I've not used either Opencv nor numpy, somebody else had better
jump in after you post the traceback that matches your source file.
Perhaps it's IDLE that's getting confused.  Have you tried running it
from a cmd.exe prompt, and pasting from that cmd window into a message?



-- 

DaveA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web