DynamicGravitySystems / DGP

Dynamic Gravity Processor
http://dgp.readthedocs.io/en/develop/
Apache License 2.0
7 stars 4 forks source link

BUG: Fixed several bugs in patch movement with no labels #47

Closed cbertinato closed 6 years ago

cbertinato commented 6 years ago

Annotation object attributes were referenced when a patch was moved with no label set, which resulted in an AttributeError because the label variable was of NoneType when not set. (Issue #46)

bradyzp commented 6 years ago

One more issue caused by zooming in/out and changing ylims on the plot. _move_patch_label isn't checking for attr['label'] validity.

Debug:

Traceback (most recent call last):
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\backends\backend_qt5.py", line 313, in mouseReleaseEvent
    guiEvent=event)
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\backend_bases.py", line 1940, in button_release_event
    self.callbacks.process(s, event)
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\cbook.py", line 554, in process
    proxy(*args, **kwargs)
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\cbook.py", line 416, in __call__
    return mtd(*args, **kwargs)
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\backend_bases.py", line 3102, in release_zoom
    self._zoom_mode, twinx, twiny)
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\axes\_base.py", line 3569, in _set_view_from_bbox
    self.set_ylim((y0, y1))
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\axes\_base.py", line 3203, in set_ylim
    self.callbacks.process('ylim_changed', self)
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\cbook.py", line 554, in process
    proxy(*args, **kwargs)
  File "C:\Dev\DGS\DGP\venv\lib\site-packages\matplotlib\cbook.py", line 416, in __call__
    return mtd(*args, **kwargs)
  File "C:\Dev\DGS\DGP\dgp\lib\plotter.py", line 605, in _on_ylim_changed
    self._move_patch_label(attr)
  File "C:\Dev\DGS\DGP\dgp\lib\plotter.py", line 230, in _move_patch_label
    attr['label'].set_position((cx, cy))
AttributeError: 'NoneType' object has no attribute 'set_position'