enthought / chaco

Chaco is a Python package for building interactive and custom 2-D plots.
http://docs.enthought.com/chaco/
Other
292 stars 99 forks source link

PanTool test generates numpy warnings #854

Closed corranwebster closed 1 year ago

corranwebster commented 1 year ago

Problem Description

Running the test on Python 3.8 with recent NumPy gives warnings like the following:

test_restrict_to_data_with_empty_source (chaco.tools.tests.test_pan_tool.PanToolTestCase) ... /home/runner/.edm/envs/chaco-test-3.8-null/lib/python3.8/site-packages/chaco/data_range_1d.py:293: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._high_setting != val:
/home/runner/.edm/envs/chaco-test-3.8-null/lib/python3.8/site-packages/traits/trait_types.py:4244: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  return trait_type_instance.validate(obj, name, value)
/home/runner/.edm/envs/chaco-test-3.8-null/lib/python3.8/site-packages/chaco/data_range_1d.py:300: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if val == "auto":
/home/runner/.edm/envs/chaco-test-3.8-null/lib/python3.8/site-packages/chaco/data_range_1d.py:307: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  elif val == "track":

Reproduction Steps:

Run the tests for Python 3.8 and null toolkit using edmtool, for example.

Expected behavior:

No warnings

OS, Python version: Python 3.8, all OS

corranwebster commented 1 year ago

At first glance it looks like something is passing an array (probably with shape (1,1)) instead of a scalar.

corranwebster commented 1 year ago

Converting warnings to errors gives:

======================================================================
ERROR: test_restrict_to_data_with_empty_source (chaco.tools.tests.test_pan_tool.PanToolTestCase)
----------------------------------------------------------------------
numpy.core._exceptions._UFuncInputCastingError: Cannot cast ufunc 'not_equal' input 1 from dtype('<U4') to dtype('float64') with casting rule 'same_kind'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/cwebster/src/clean/chaco/chaco/tools/tests/test_pan_tool.py", line 41, in test_restrict_to_data_with_empty_source
    self.mouse_move(interactor=tool, x=1.0, y=1.0)
  File "/Users/cwebster/.edm/envs/chaco-test-3.8-null/lib/python3.8/site-packages/enable/testing.py", line 369, in mouse_move
    self._mouse_event_dispatch(interactor, event, "mouse_move")
  File "/Users/cwebster/.edm/envs/chaco-test-3.8-null/lib/python3.8/site-packages/enable/testing.py", line 647, in _mouse_event_dispatch
    interactor.dispatch(event, suffix)
  File "/Users/cwebster/.edm/envs/chaco-test-3.8-null/lib/python3.8/site-packages/enable/base_tool.py", line 137, in dispatch
    self._dispatch_stateful_event(event, suffix)
  File "/Users/cwebster/.edm/envs/chaco-test-3.8-null/lib/python3.8/site-packages/enable/base_tool.py", line 145, in _dispatch_stateful_event
    handler(event)
  File "/Users/cwebster/src/clean/chaco/chaco/tools/pan_tool.py", line 235, in panning_mouse_move
    mapper.range.set_bounds(newlow, newhigh)
  File "/Users/cwebster/src/clean/chaco/chaco/data_range_1d.py", line 166, in set_bounds
    result_high = self._do_set_high_setting(high, fire_event=False)
  File "/Users/cwebster/src/clean/chaco/chaco/data_range_1d.py", line 293, in _do_set_high_setting
    if self._high_setting != val:
FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison