[Idle-dev] [ idlefork-Bugs-558687 ] Printing arrays misses elements

noreply@sourceforge.net noreply@sourceforge.net
Thu, 20 Jun 2002 04:54:39 -0700


Bugs item #558687, was opened at 2002-05-21 14:10
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=109579&aid=558687&group_id=9579

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Williams (mikewilliams)
Assigned to: Nobody/Anonymous (nobody)
Summary: Printing arrays misses elements

Initial Comment:
IDLEfork seems to be missing out an inconsistent 
number of the final few elements of a Numeric 
array when asked to print them. This has been 
replicated on both Linux and Solaris with 
Python2.2.1 and IDLEfork 0.8.1

Consider the following code snippet (problem 
exhibited both if run from module or typed at 
shell):

from Numeric import *   #Import Numeric (an array  
                          #library)
xx = zeros(100, Float)  #Create an empty array of  
                          #100 floats
for i in range(100):    
    xx[i] = i           #Put numbers 0 to 99 in 
the                          #array
print xx                #Print the array (see the  
                          #problem?)
print xx[99]            #Although xx[99] does 
exist!

This problem doesn't seem to occur much below 100 
element arrays (although see, e.g. 87), but seems 
to get more severe above it. See, for example 
102-108 (not 109 or 110), 150, 200, 1000 (which 
prints the first 947 elements!). I could not find 
a corellation between window width and the number 
of elements that were printed (which appears to be 
constant). Ther seems to be some reluctance to 
start a new line when printing until there are 
sufficient elements to put on it.

This is a medium severity problem, especially for 
interactive work.

----------------------------------------------------------------------

>Comment By: Michael Williams (mikewilliams)
Date: 2002-06-20 11:54

Message:
Logged In: YES 
user_id=258804

OK. Tested again to convince myself I wasn't daydreaming and
the problem is definitely there. Here's the output of a
short IDLEfork session:

>>> from Numeric import *
>>> xx = zeros(100, Float)
>>> for i in range(100):
	xx[i] = i

	
>>> print xx
[  0.   1.   2.   3.   4.   5.   6.   7.   8.   9.  10. 
11.  12.  13.  14.
       15.  16.  17.  18.  19.  20.  21.  22.  23.  24. 
25.  26.  27.  28.
       29.  30.  31.  32.  33.  34.  35.  36.  37.  38. 
39.  40.  41.  42.
       43.  44.  45.  46.  47.  48.  49.  50.  51.  52. 
53.  54.  55.  56.
       57.  58.  59.  60.  61.  62.  63.  64.  65.  66. 
67.  68.  69.  70.
       71.  72.  73.  74.  75.  76.  77.  78.  79.  80. 
81.  82.  83.  84.
       85.  86.  87.  88.  89.  90.  91.  92.  93.  94. 
95.  96.  97.  98.]
>>> xx
array([  0.,   1.,   2.,   3.,   4.,   5.,   6.,   7.,  
8.,   9.,  10.,  11.,  12.,
               13.,  14.,  15.,  16.,  17.,  18.,  19., 
20.,  21.,  22.,  23.,
               24.,  25.,  26.,  27.,  28.,  29.,  30., 
31.,  32.,  33.,  34.,
               35.,  36.,  37.,  38.,  39.,  40.,  41., 
42.,  43.,  44.,  45.,
               46.,  47.,  48.,  49.,  50.,  51.,  52., 
53.,  54.,  55.,  56.,
               57.,  58.,  59.,  60.,  61.,  62.,  63., 
64.,  65.,  66.,  67.,
               68.,  69.,  70.,  71.,  72.,  73.,  74., 
75.,  76.,  77.,  78.,
               79.,  80.,  81.,  82.,  83.,  84.,  85., 
86.,  87.,  88.,  89.,
               90.,  91.,  92.,  93.,  94.,  95.,  96., 
97.,  98.,  99.])

Sorry if line-wrapping hasn't worked! Anyway, the moral of
the story is if you "print xx" the problem is exhibited but
if you just "xx" it isn't. Does this suggest the likely
origin of the problem?

I checked with the regular Python intrerpreter (both through
the old IDLE and from the command line) and this definitely
isn't a problem there. Doing "print str(xx)" instead of
"print xx" makes no difference; this enironment doesn't
exhibit the problem.

By the way, this is all with the latest Numeric which is
version 21.0. Is this the same version you're using Bruce?
If it would be useful I could try and replicate the problem
with earlier Numerics.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-19 12:33

Message:
Logged In: YES 
user_id=6380

Without looking at any code, I venture that this is more
likely a bug in Numeric rather than in idle(fork).  If you
don't see this when using the regular python interpreter,
that could be because in IDLE, str() is used to print
numeric objects, while in the regular interpreter an
internal print handler may be used. To verify that theory,
you could use "print str(xx)" in a regular interpreter. If
that has the same problem, please submit the bug report to
the Numeric folks (and report back here in either case).

----------------------------------------------------------------------

Comment By: Bruce Sherwood (bsherwood)
Date: 2002-06-19 01:50

Message:
Logged In: YES 
user_id=34881

I'm using idlefork-0.8.1 for daily work. I cannot reproduce 
this problem; the test routine gives the correct output on 
RedHat Linux 7.2. This is with a version of Numeric from a 
few months ago.


----------------------------------------------------------------------

Comment By: Michael Williams (mikewilliams)
Date: 2002-05-21 14:36

Message:
Logged In: YES 
user_id=258804

This does not occur in the IDLE distributed with the 
Python source.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=109579&aid=558687&group_id=9579