Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33734 > unrolled thread
| Started by | Dave Angel <d@davea.name> |
|---|---|
| First post | 2012-11-21 08:32 -0500 |
| Last post | 2012-11-21 08:32 -0500 |
| Articles | 1 — 1 participant |
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.
Re: Index Error Dave Angel <d@davea.name> - 2012-11-21 08:32 -0500
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-11-21 08:32 -0500 |
| Subject | Re: Index Error |
| Message-ID | <mailman.152.1353504762.29569.python-list@python.org> |
>
> <snip>
>
>>
>> Back to an earlier comment. I asked if N was ever bigger than x or
>> bigger than y, and you said never. But your ComputeClasses will have
>> such a case the very first time around, when cx==0, cy==0, and
>> ring_number == 1.
>>
>
> I doubt this , M confused..
>
I'll paste an excerpt of the last source I've seen from you:
"""
def GenerateRing(x,y, N): Generates square rings around a point in data
which has 300 columns(x) and 3000 rows(y)
indices = []
for i in xrange(-N, N):
indices.append((x+i, y-N))
indices.append((x+N, y+i))
indices.append((x-i, y+N))
indices.append((x-N, y-i))
return indices
def ComputeClasses(data):
radius = .5
points = []
for cy in xrange(0, data.height):
for cx in xrange(0, data.width):
if data[cy,cx] == (0.0,0.0,0.0):
continue
else :
centre = data[cy, cx]
points.append(centre)
change = True
while change:
for ring_number in xrange(1, 100):
change = False
new_indices = GenerateRing(cx, cy, ring_number)
"""
When that GenerateRing() is first called, cy will be zero, cx the same,
and ring_number will be 1.
So some of the tuples in the returned list will have negative ints. You
don't check for that either.
I still think that data.height and data.width aren't the right limits to
be using.
--
DaveA
Back to top | Article view | comp.lang.python
csiph-web