Describe the bug
Too many indices are deleted when number of points is reduced in BarPlot. This leads to an index error.
To Reproduce
from kivy_garden.graph import Graph, BarPlot
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.app import App
class TestApp(App):
plot = None
def build(self):
b = BoxLayout(orientation='vertical')
graph = Graph(xmin=-50, xmax=50, ymin=-1, ymax=1)
self.plot = BarPlot()
graph.add_plot(self.plot)
self.plot.points = [(0, -0.2), (10, 0.6), (15, 1.0)]
b.add_widget(graph)
button = Button(text='Hello world', font_size=14)
button.bind(on_press=self.replot)
b.add_widget(button)
return b
def replot(self, inst):
self.plot.points = [(-1, 0.5)]
TestApp().run()
Expected behavior
When clicking the button, the plot should show one bar.
Logs/output
Traceback (most recent call last):
File "kivy_graph_error_in_delete.py", line 25, in <module>
TestApp().run()
File "/home/davidkleiven/.local/lib/python3.7/site-packages/kivy/app.py", line 855, in run
runTouchApp()
File "/home/davidkleiven/.local/lib/python3.7/site-packages/kivy/base.py", line 504, in runTouchApp
EventLoop.window.mainloop()
File "/home/davidkleiven/.local/lib/python3.7/site-packages/kivy/core/window/window_sdl2.py", line 747, in mainloop
self._mainloop()
File "/home/davidkleiven/.local/lib/python3.7/site-packages/kivy/core/window/window_sdl2.py", line 479, in _mainloop
EventLoop.idle()
File "/home/davidkleiven/.local/lib/python3.7/site-packages/kivy/base.py", line 339, in idle
Clock.tick()
File "/home/davidkleiven/.local/lib/python3.7/site-packages/kivy/clock.py", line 591, in tick
self._process_events()
File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
File "/home/davidkleiven/Documents/graph/kivy_garden/graph/__init__.py", line 1454, in draw
vert[idx + 4] = x1
IndexError: list assignment index out of range
Platform (please complete the following information):
OS: Linux Fedora
Python version 3.6
I have a proposed solution in PR #19. @matham Can you have one more look at this? Are you sure that the code deletes the correct amount of elements?
Describe the bug Too many indices are deleted when number of points is reduced in BarPlot. This leads to an index error.
To Reproduce
Expected behavior When clicking the button, the plot should show one bar.
Logs/output
Platform (please complete the following information):
I have a proposed solution in PR #19. @matham Can you have one more look at this? Are you sure that the code deletes the correct amount of elements?