taborlab / FlowCal

Python Flow Cytometry Calibration Library
MIT License
48 stars 23 forks source link

Matplotlib error is_decade #360

Open MHunt-tools opened 6 months ago

MHunt-tools commented 6 months ago

Flowcal plot functions are not working for clean install of FlowCal. Seems like matplotlib has deprecated the is_decade function for ticker. Full traceback is as follows:

FlowCal.plot.hist1d(s, channel='FL1-H') Traceback (most recent call last): File "", line 1, in File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/FlowCal/plot.py", line 1285, in hist1d plt.xlim((edges[0], edges[-1])) File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/matplotlib/pyplot.py", line 1961, in xlim ret = ax.set_xlim(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 3664, in set_xlim return self.xaxis._set_lim(left, right, emit=emit, auto=auto) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/matplotlib/axis.py", line 1243, in _set_lim self.set_view_interval(v0, v1, ignore=True) File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/matplotlib/axis.py", line 2272, in setter setattr(getattr(self.axes, lim_name), attr_name, (vmin, vmax)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 849, in viewLim self._unstale_viewLim() File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 844, in _unstale_viewLim self.autoscale_view({f"scale{name}": scale File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 2936, in autoscale_view handle_single_axis( File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 2932, in handle_single_axis x0, x1 = locator.view_limits(x0, x1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/MaxwellHunt/opt/anaconda3/envs/flowc/lib/python3.12/site-packages/FlowCal/plot.py", line 648, in view_limits if not matplotlib.ticker.is_decade(abs(vmin), b): ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'matplotlib.ticker' has no attribute 'is_decade'. Did you mean: '_is_decade'?

Suggested update to is_decade following https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.8.0.html: instead of ticker.is_decade; use y = numpy.log(x)/numpy.log(base); numpy.isclose(y, numpy.round(y))

castillohair commented 6 months ago

@MHunt-tools thanks for submitting this. If you want, you could make a branch starting from develop with your proposed solution and, after testing it, submit a pull request. This website explains the workflow we have used to work with FlowCal.

@JS3xton what would be the process to approve a bug/deprecation fix these days? I would think that just making sure the plots are generated as before would suffice for this particular case, but it's been a while since I've worked with FlowCal's code.

Thanks.

JS3xton commented 6 months ago

Thanks for pointing this out, Max.

The last release process was very tedious--I'd like to automate some of the testing if possible, e.g., with GitHub Actions. There are also several other outstanding deprecation issues that should probably be resolved--and it's probably time to officially drop support for Python 2. I don't expect any of this to happen quickly, though, so yeah, Max I'd rely on your own fork in the short term.

MHunt-tools commented 6 months ago

Hey all, thanks for looking into this! I updated the plot script and tested with the example data (minor updates in those processing scripts as well). Pull request has been submitted!