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

Start to fix Attractors example #408

Merged
merged 2 commits into from
May 18, 2021
Merged

Start to fix Attractors example #408

merged 2 commits into from
May 18, 2021

Conversation

aaronayres35
Copy link
Contributor

@aaronayres35 aaronayres35 commented May 12, 2021

fixes starts process of fixing #404

Previously changing initial_point at all one got the traceback:

Exception occurred in traits notification handler for event object: TraitChangeEvent(object=<attractors.model.henon.Henon object at 0x7fcc0ae66e60>, name='initial_point', old=array([0.1, 0.1]), new=array(['0.13', '0.1'], dtype='<U4'))
Traceback (most recent call last):
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/traits/observation/_trait_event_notifier.py", line 122, in __call__
    self.dispatcher(handler, event)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/traits/observation/observe.py", line 26, in dispatch_same
    handler(event)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/traits/has_traits.py", line 328, in handler
    instance.trait_property_changed(property_name, old)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/traits/has_traits.py", line 927, in decorator
    self.__dict__[name] = result = function(self)
  File "envisage/examples/demo/plugins/tasks/attractors/model/henon.py", line 68, in _get_points
    point = array([y + 1 - self.a * x ** 2, self.b * x])
TypeError: must be str, not int

Inserting a print statement (print(type(point), point.dtype, point)) I saw that :

<class 'numpy.ndarray'> float64 [0.1 0.1]
<class 'numpy.ndarray'> <U4 ['0.13' '0.1']

so by changing a value on initial_point we ended up changing the dtype leading to problems. We always want floats.

Note even after this fix there are still other problems with the example

@aaronayres35
Copy link
Contributor Author

aaronayres35 commented May 12, 2021

Now, I can change initial_point without an error message. however, if I set the y value of inital_point to 14 and then drag the plot I get:

$ python envisage/examples/demo/plugins/tasks/run_attractor.py 
2021-05-12 10:32:04.824 Python[7752:139557] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
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])
/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/chaco/data_range_1d.py:285: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._high_setting != val:
/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/chaco/data_range_1d.py:292: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if val == 'auto':
/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/chaco/data_range_1d.py:298: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  elif val == 'track':
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 789, in _draw
    self._dispatch_draw(layer, bb, 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/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/enable/component.py", line 910, in _draw_underlay
    underlay.overlay(self, gc, view_bounds, mode)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/chaco/axis.py", line 225, in overlay
    self._draw_component(gc, view_bounds, mode, component)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/chaco/axis.py", line 250, in _draw_component
    self._compute_tick_positions(gc, component)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/chaco/axis.py", line 496, in _compute_tick_positions
    scale=scale), float64)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/chaco/ticks.py", line 84, in get_ticks
    interval, use_endpoints=False), float64)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/chaco/ticks.py", line 216, in auto_ticks
    ticks = arange( start, end + (tick_interval / 2.0), tick_interval )
ValueError: arange: cannot compute length
Abort trap: 6

perhaps this should be a separate issue/ perhaps a chaco issue?

I tried running with chaco master as I remember a similar looking issue that had been fixed recently, only to find the following error:

$ python envisage/examples/demo/plugins/tasks/run_attractor.py 
2021-05-12 10:34:29.178 Python[7908:142952] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
  File "envisage/examples/demo/plugins/tasks/run_attractor.py", line 26, in <module>
    main(sys.argv)
  File "envisage/examples/demo/plugins/tasks/run_attractor.py", line 16, in main
    app.run()
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/ui/tasks/tasks_application.py", line 178, in run
    self._create_windows()
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/ui/tasks/tasks_application.py", line 339, in _create_windows
    if not self._get_task_factory(task_id):
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/ui/tasks/tasks_application.py", line 362, in _get_task_factory
    for factory in self.task_factories:
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/extension_point.py", line 169, in get
    extensions = extension_registry.get_extensions(self.id)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/extension_registry.py", line 114, in get_extensions
    return self._get_extensions(extension_point_id)[:]
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/provider_extension_registry.py", line 103, in _get_extensions
    extensions = self._initialize_extensions(extension_point_id)
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/provider_extension_registry.py", line 289, in _initialize_extensions
    extensions.append(provider.get_extensions(extension_point_id)[:])
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/plugin.py", line 156, in get_extensions
    extensions = self._get_extensions_from_trait(trait_names[0])
  File "/Users/aayres/.edm/envs/envisage-test-3.6-pyqt5/lib/python3.6/site-packages/envisage/plugin.py", line 355, in _get_extensions_from_trait
    extensions = getattr(self, trait_name)
  File "envisage/examples/demo/plugins/tasks/attractors/attractors_plugin.py", line 47, in _tasks_default
    from attractors.visualize_2d_task import Visualize2dTask
  File "envisage/examples/demo/plugins/tasks/attractors/visualize_2d_task.py", line 10, in <module>
    from attractors.plot_2d_pane import Plot2dPane
  File "envisage/examples/demo/plugins/tasks/attractors/plot_2d_pane.py", line 2, in <module>
    from chaco.chaco_plot_editor import ChacoPlotItem
ModuleNotFoundError: No module named 'chaco.chaco_plot_editor'

since we removed chaco_plot_editor

EDIT: I've opened #409
These problems are probably better addressed in separate PRs, and this PR can be left small / easier to review

@aaronayres35 aaronayres35 changed the title [WIP] Fix Attractors example Start to fix Attractors example May 12, 2021
@aaronayres35 aaronayres35 requested a review from rahulporuri May 12, 2021 16:30
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.

@rahulporuri
Copy link
Contributor

It's necessary to replace ChacoPlotItem here before the chaco major release. Im surprised I didn't find this when I searched Enthought org on GitHub for users. Searching again.

@aaronayres35 aaronayres35 merged commit 1220468 into master May 18, 2021
@aaronayres35 aaronayres35 deleted the fix/attractors branch May 18, 2021 11:58
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.

2 participants