Closed rlabs-oss closed 2 years ago
Thanks for reporting this. Could you tell me which versions of matplotlib and python you are using? Thanks Mike
I removed line 288 and it worked - not the best work around,
Versions are matplotlib 3.5.1 and python 3.8.10,
After pip install rayoptics:
$ pip list --local Package Version
anytree 2.8.0 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 attrs 21.2.0 backcall 0.2.0 bleach 4.1.0 certifi 2021.10.8 cffi 1.15.0 charset-normalizer 2.0.9 cycler 0.11.0 debugpy 1.5.1 decorator 5.1.0 defusedxml 0.7.1 entrypoints 0.3 et-xmlfile 1.1.0 fonttools 4.28.4 idna 3.3 importlib-resources 5.4.0 ipykernel 6.6.0 ipython 7.30.1 ipython-genutils 0.2.0 ipywidgets 7.6.5 jedi 0.18.1 Jinja2 3.0.3 json-tricks 3.15.5 jsonschema 4.3.0 jupyter-client 7.1.0 jupyter-core 4.9.1 jupyterlab-pygments 0.1.2 jupyterlab-widgets 1.0.2 kiwisolver 1.3.2 MarkupSafe 2.0.1 matplotlib 3.5.1 matplotlib-inline 0.1.3 mistune 0.8.4 nbclient 0.5.9 nbconvert 6.3.0 nbformat 5.1.3 nest-asyncio 1.5.4 notebook 6.4.6 numpy 1.21.4 openpyxl 3.0.9 opticalglass 0.7.6 packaging 21.3 pandas 1.3.5 pandocfilters 1.5.0 parso 0.8.3 pexpect 4.8.0 pickleshare 0.7.5 Pillow 8.4.0 pip 21.3.1 pkg_resources 0.0.0 prometheus-client 0.12.0 prompt-toolkit 3.0.24 ptyprocess 0.7.0 pycparser 2.21 Pygments 2.10.0 pyparsing 3.0.6 PyQt5 5.12.3 PyQt5-sip 12.9.0 pyrsistent 0.18.0 python-dateutil 2.8.2 pytz 2021.3 pyzmq 22.3.0 QDarkStyle 3.0.3 qtconsole 5.2.2 QtPy 1.11.3 rayoptics 0.7.4 requests 2.26.0 scipy 1.7.3 Send2Trash 1.8.0 setuptools 44.0.0 six 1.16.0 terminado 0.12.1 testpath 0.5.0 tornado 6.1 traitlets 5.1.1 transforms3d 0.3.1 urllib3 1.26.7 wcwidth 0.2.5 webencodings 0.5.1 widgetsnbextension 3.5.2 xlrd 2.0.1 zipp 3.6.0
BR -Mike
Thanks for that. It looks like the more recent versions of matplotlib have removed the _pixel_ratio property in favor of a device_pixel_ratio property. Probably the better temporary fix at your end is to duplicate the linked issue that you found in your original report. So looks like this:
if hasattr(pm, 'setDevicePixelRatio'):
try: # older mpl < 3.5.0
pm.setDevicePixelRatio(self.canvas._dpi_ratio)
except AttributeError:
pm.setDevicePixelRatio(self.canvas.device_pixel_ratio)
I think this should work. I'll have to see how much other stuff is broken by matplotlib 3.5 :-}
Talking of not breaking things - I was attempting to find out if "it was safe via optical modeling" to remove the secondary hyperbolic mirror in an Ritchey Chretién scope replacing it with a camera rather than physically breaking a new rc scope to find out the hard way. Curiosity normally wins but I'll use it for a while as is before (breaking)/modifying it.
https://matplotlib.org/3.5.0/users/prev_whats_new/whats_new_3.5.0.html
I have a Jupyter notebook in my ray-optics-notebooks repo that run thru the different forms of 2 mirror telescopes. It uses a function called ritchey_chretien to calculate the conic constants given the paraxial model (pm
).
Using ray-optics with iPython or Jupyter doesn't rely on the Qt integration, so that's sometimes an option if your trying to work around issues with the app.
Thank you for your help much appreciated.
After $python3 -m venv venv $source venv/bin/activate $pip install pip --upgrade $pip install rayoptics And $rayoptics
I get the following error: ... /rayoptics/qtgui/plotview.py", line 288, in get_icon pm.setDevicePixelRatio(fig.canvas._dpi_ratio) AttributeError: 'PlotCanvas' object has no attribute '_dpi_ratio'
Maybe this is a related fix https://github.com/rgerum/pylustrator/commit/23ecf6718051b9d20227e97b25e490f3ff741deb