ete icon indicating copy to clipboard operation
ete copied to clipboard

Errors with t.show()

Open csx202201 opened this issue 3 years ago • 5 comments

ete3 version 3.1.2 with PyQt5==5.15.6 Type error:

Traceback (most recent call last): File "C:\Users\ETE3_tree.py", line 88, in t.show(tree_style=ts) File "C:\Users\venv\lib\site-packages\ete3\coretype\tree.py", line 1363, in show drawer.show_tree(self, layout=layout, File "C:\Users\venv\lib\site-packages\ete3\treeview\drawer.py", line 82, in show_tree mainapp = _GUI(scene) File "C:\Users\venv\lib\site-packages\ete3\treeview\qt4_gui.py", line 172, in init splitter.setSizes([self.scene.sceneRect().width(), 10]) TypeError: index 0 has type 'float' but 'int' is expected

What's the problem with this?

Thank you!

csx202201 avatar Jan 29 '22 12:01 csx202201

I find a similar (and probably related?) error happens when calling Tree.render. Using linux Conda, Python 3.10.2, ete3 3.1.2, pyQt5 5.15.6:

import ete3
tree = ete3.Tree()
tree.render('test.svg')

the result is:

Traceback (most recent call last):
  File "/home/wdumm/gctree/gctree/test.py", line 3, in <module>
    tree.render('test.svg')
  File "/home/wdumm/miniconda3/envs/gctree5/lib/python3.10/site-packages/ete3/coretype/tree.py", line 1392, in render
    return drawer.render_tree(self, file_name, w=w, h=h,
  File "/home/wdumm/miniconda3/envs/gctree5/lib/python3.10/site-packages/ete3/treeview/drawer.py", line 113, in render_tree
    x_scale, y_scale = save(scene, imgName, w=w, h=h, units=units, dpi=dpi)
  File "/home/wdumm/miniconda3/envs/gctree5/lib/python3.10/site-packages/ete3/treeview/main.py", line 685, in save
    svg.setSize(QSize(w, h))
TypeError: arguments did not match any overloaded call:
  QSize(): too many arguments
  QSize(int, int): argument 1 has unexpected type 'float'
  QSize(QSize): argument 1 has unexpected type 'float'

willdumm avatar Feb 02 '22 21:02 willdumm

Update: This issue continues to pop up occasionally. The thing that consistently fixes it is downgrading to python 3.9.7.

For instance, the test in my last comment runs as expected when the environment is set up using:

conda create -n ete python=3.9
conda activate ete
conda install -c conda-forge ete3

... but fails when I omit python=3.9.

I've attached environment files for both a working and broken (etenoworks) conda environment. Since GH doesn't support yml files I changed the extension to .txt. eteworks.yml.txt etenoworks.yml.txt

I also tested in a venv environment to try newer versions of packages. Here's truncated output from pip freeze in a working venv environment:

python==3.9.10
ete3==3.1.2
fonttools==4.29.1
numpy==1.22.1
packaging==21.3
pandas==1.4.0
PyQt5==5.15.6
PyQt5-Qt5==5.15.2
PyQt5-sip==12.9.1
six==1.16.0

There are a few ways to look at this, at the very least (if my issue here is reproducible for others), the conda recipe for ete3 should specify python <3.10. Perhaps this issue is fundamentally an issue with pyqt, but it looks like it could be fixed in ete by explicitly casting width and height arguments provided to QSize to int.

willdumm avatar Mar 09 '22 17:03 willdumm

same problem here.

Shakkak avatar Mar 17 '22 11:03 Shakkak

same issue here; python 3.10.4; index 0 has type 'float' but 'int' is expected

edit: ok, casting everything to int seems to fix the problem with the render; this is a temp fix, I agree with @willdumm could be a fundamental issue with PyQt

edit1: opened a PR #646 to fix this issue

Creative-Ataraxia avatar Aug 27 '22 15:08 Creative-Ataraxia

same issue here; python 3.10.4; index 0 has type 'float' but 'int' is expected

edit: ok, casting everything to int seems to fix the problem with the render; this is a temp fix, I agree with @willdumm could be a fundamental issue with PyQt

edit1: opened a PR #646 to fix this issue

Hi, I have the same issue, but can't handle it.

setDotsPerMeterX(self, int): argument 1 has unexpected type 'float'

what sould I do?

galnora avatar Dec 05 '22 07:12 galnora