johannesring / scitools

Automatically exported from code.google.com/p/scitools
Other
0 stars 0 forks source link

scitools.aplotter.plot() crashes and burns on valid input #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. from scitools.aplotter import plot
2. l1 = [16, 33, 50] ; l2 = [36.94805848, 59.48372445, 63.57076211]
3. aplotter.plot(l1, l2)

What is the expected output? What do you see instead?
I expect an ASCII plot.
Instead, I get 
Traceback (most recent call last):
    ... lines in my program which you really don't care about ...
  File "/usr/lib64/python2.7/site-packages/scitools/aplotter.py", line 573, in plot
    r = p.plot_double(args[0],args[1],**limit_flags)
  File "/usr/lib64/python2.7/site-packages/scitools/aplotter.py", line 501, in plot_double
    self.plot_labels(output_buffer, plot_data)
  File "/usr/lib64/python2.7/site-packages/scitools/aplotter.py", line 345, in plot_labels
    output_buffer[min_x_coord+i][y_zero_coord-1] = c
IndexError: list assignment index out of range

What version of the product are you using? On what operating system?
python-scitools-0.9.0-2.1.4
On Slackware 64 1.4.1

Please provide any additional information below.
(1) A similar bug has been reported in 
    https://code.google.com/p/scitools/issues/detail?id=27
(2) On my particular data, adding
            if y_zero_coord <= -len(output_buffer[0]):
                        y_zero_coord = -len(output_buffer[0]) + 1
    right after line 330:
        y_zero_coord = self.get_coord(0, plot_data.min_y, plot_data.y_step)
    kludges around the problem, but I'm pretty sure that's not The Right Thing
    to do.
(3) y_zero_coord gets set to -20, and then subtracting 1 from that gives -21,
    which is an invalid list index in this case.

Original issue reported on code.google.com by zli...@ns.sympatico.ca on 12 Feb 2015 at 9:09

GoogleCodeExporter commented 9 years ago
A fix is now available in the source repository.

Original comment by johannes...@gmail.com on 24 Feb 2015 at 12:01