Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of ChacoPlotItem in attractors example #416

Merged
merged 8 commits into from
Jun 1, 2021

Conversation

aaronayres35
Copy link
Contributor

@aaronayres35 aaronayres35 commented May 18, 2021

closes #409
part of #404

This PR removes the use of ChacoPlotItem which has recently been removed on chaco master and will be unavailable with the next release of chaco.

@rahulporuri rahulporuri self-requested a review May 19, 2021 13:12
@aaronayres35
Copy link
Contributor Author

aaronayres35 commented May 19, 2021

In regards to #404, the example currently "works" but it is lacking safeguards so a user can easily crash things...
For example, launch the app and and immediately set B=2. The Henon Map plot will disappear and the traceback in terminal is:

/Users/aayres/Desktop/envisage/envisage/examples/demo/plugins/tasks/attractors/model/henon.py:68: RuntimeWarning: overflow encountered in double_scalars
  point = array([y + 1 - self.a * x ** 2, self.b * x])

(At least the full application doesn't crash)

Alternatively, select Lorenz Map from the drop down, then set Time stop = 1000. The application will crash and you will see:

$ python run_attractor.py 
2021-05-19 08:48:09.827 Python[47176:955260] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/enable/qt4/base_window.py", line 243, in paintEvent
    self.handler.paintEvent(event)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/enable/qt4/base_window.py", line 78, in paintEvent
    self._enable_window._paint(event)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/enable/abstract_window.py", line 542, in _paint
    self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/enable/component.py", line 418, in draw
    self._draw(gc, view_bounds, mode)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/enable/component.py", line 799, in _draw
    self._dispatch_draw(layer, gc, view_bounds, mode)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/enable/container.py", line 280, in _dispatch_draw
    component._dispatch_draw(layer, gc, new_bounds, mode)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/enable/component.py", line 817, in _dispatch_draw
    handler(gc, view_bounds, mode)
  File "/Users/aayres/Desktop/chaco/chaco/base_xy_plot.py", line 477, in _draw_plot
    self._draw_component(gc, view_bounds, mode)
  File "/Users/aayres/Desktop/chaco/chaco/base_xy_plot.py", line 484, in _draw_component
    self._render(gc, pts)
  File "/Users/aayres/Desktop/chaco/chaco/lineplot.py", line 371, in _render
    render(gc, points, self.orientation)
  File "/Users/aayres/Desktop/chaco/chaco/lineplot.py", line 382, in _render_normal
    gc.stroke_path()
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/kiva/agg/agg.py", line 1360, in stroke_path
    return _agg.GraphicsContextArray_stroke_path(self, *args)
OverflowError: Exceeded cell block limit
Abort trap: 6

Ideally we would restrict these values to non-breaking ranges. Also the latter traceback I believe is a known issue.
Seems related to enthought/chaco#474

@observe("active_model")
def _update_plot_new_model(self, event):
if event.old:
self.plot.delplot(event.old.name)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old active_model's name is the old title that was used as the name for the previous plot.

I do think this naming is a little confusing, as title is not actually used as a title... In fact, prior to this PR it was not actually used at all! I found it convenient for naming plots so they could be easily deleted when we switch models.

Note that if we do not delete the old plot when we change model, things appear to work perfectly fine initially, however if you change models a few times eventually you see the

OverflowError: Exceeded cell block limit
Abort trap: 6

crash as mentioned in another comment. Deleting old plots prevents this

@aaronayres35 aaronayres35 changed the title [WIP] Remove use of ChacoPlotItem in attractors example Remove use of ChacoPlotItem in attractors example May 19, 2021
Copy link
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aaronayres35 aaronayres35 merged commit bae1be5 into master Jun 1, 2021
@aaronayres35 aaronayres35 deleted the draft-fix-attractors branch June 1, 2021 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove use of ChacoPlotItem in attractors example
2 participants