chaco icon indicating copy to clipboard operation
chaco copied to clipboard

Audit and Pin down return types of methods across chaco

Open aaronayres35 opened this issue 4 years ago • 5 comments

Problem Description See comment: https://github.com/enthought/chaco/pull/636#issuecomment-816879211

There are many places in chaco where we aren't super consistent about the type being returned by specific methods and this has led to a variety of bugs / issues such as: #255, #272, #289, #550, (possibly) #542

Expected behavior:

The return types should be consistent as defined on the relevant interface or base class to prevent bugs in strange edge cases.

aaronayres35 avatar Apr 13 '21 12:04 aaronayres35

Also, the hittest method on BaseXYPlot returning tuples bothers me a bit

aaronayres35 avatar May 03 '21 20:05 aaronayres35

There exist map_data_array methods on all the Mapper classes, but they are not used anywhere in the code base. I imagine their original intention was precisely such a distinction, in that map_data takes float->float, and map_data_array array->array. But most map_data implementations are vectorized, aside from edge cases, so they can do array->array directly.

We should possibly remove the map_data_array methods? The majority of them currently just call self.map_data() anyway. If we keep them we should draw a line in the sand about what returns what. That I imagine could be a hard pill to try to force users to swallow...

As I am investigating this more I become more and more unsure of what the right way to go about this is.. 🤔

aaronayres35 avatar May 03 '21 20:05 aaronayres35

Running list of special handling because of discrepancies on input/return types:

  • https://github.com/enthought/chaco/blob/8065abbcaeb274407385cf6fff400cc47081d29f/chaco/tools/lasso_selection.py#L323-L327
  • https://github.com/enthought/chaco/blob/8065abbcaeb274407385cf6fff400cc47081d29f/chaco/base_xy_plot.py#L443-L446
  • https://github.com/enthought/chaco/blob/8065abbcaeb274407385cf6fff400cc47081d29f/chaco/color_bar.py#L156-L157
  • https://github.com/enthought/chaco/blob/3259e05a73be3e7ef51a0397ff629a9341907b07/chaco/scatterplot.py#L341-L343
  • https://github.com/enthought/chaco/blob/048508394718e88da22c525caae9a3b3e5736a51/chaco/lasso_overlay.py#L69-L70

aaronayres35 avatar May 05 '21 18:05 aaronayres35

ref: https://github.com/enthought/chaco/blob/master/docs/source/user_manual/basic_elements/plot_renderers.rst#screen-and-data-mapping

aaronayres35 avatar May 13 '21 18:05 aaronayres35

ref: #486

aaronayres35 avatar Oct 20 '21 12:10 aaronayres35