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

Matplotlib error is_decade #360

Open
MHunt-tools opened this issue Feb 22, 2024 · 3 comments
Open

Matplotlib error is_decade #360

MHunt-tools opened this issue Feb 22, 2024 · 3 comments

Comments

@MHunt-tools
Copy link

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
Copy link
Collaborator

castillohair commented Feb 27, 2024

@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
Copy link
Contributor

JS3xton commented Feb 29, 2024

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
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants