pi3d / pi3d_demos

Demos and support files for pi3d (3D graphics python package for the raspberry pi)
Other
71 stars 33 forks source link

PictureFrame2020.py: ValueError: operands could not be broadcast together with shapes (200,3) (0,) #67

Open Home-Control9000 opened 1 year ago

Home-Control9000 commented 1 year ago

Hi,

Im installing a new Ubuntu system for using as a photoframe. I have 3 old systems with no problems. When im run PictureFrame2020.py i get a following error.

python3 PictureFrame2020.py Traceback (most recent call last): File "/home/walter/pi3d_demos/PictureFrame2020.py", line 498, in text = pi3d.PointText(font, CAMERA, max_chars=200, point_size=config.SHOW_TEXT_SZ) File "/usr/local/lib/python3.10/dist-packages/pi3d/util/PointText.py", line 51, in init self.text = Points(camera=camera, vertices=self.locations, normals=self.normals, File "/usr/local/lib/python3.10/dist-packages/pi3d/shape/Points.py", line 34, in init if normals == [] and tex_coords == []: ValueError: operands could not be broadcast together with shapes (200,3) (0,)

joshstir commented 1 year ago

I know this is a bit ago, but I just ran into this same issue. The problem is that the shape of normals and tex_coords is 200,3 and the shape of an array is (0,) so this comparison fails. It looks like it's just checking if the array is empty, which could be fixed by switching the code to:if normals.size == 0 and tex_coords.size == 0:

paddywwoof commented 1 year ago

Hi, sorry this has languished. I will look at it now. @joshstir, did you try altering the line as you suggest and did it work?

Paddy

Home-Control9000 commented 1 year ago

I know this is a bit ago, but I just ran into this same issue. The problem is that the shape of normals and tex_coords is 200,3 and the shape of an array is (0,) so this comparison fails. It looks like it's just checking if the array is empty, which could be fixed by switching the code to:if normals.size == 0 and tex_coords.size == 0:

Thanks for the solution. I solved it a few months ago by downgrading to a older Ubuntu distribution which is not that elegant but it was the only option to make it work. I will try your fix when installing a new system.

Walter

paddywwoof commented 1 year ago

Hi, I've just change the source to if len(normals) == 0 and len(tex_coords) == 0: as the Points class is used elsewhere being passed normal python lists. The lists get converted into numpy arrays in Buffer.__init__() which can cope with lists or np arrays. Previously python would compare np arrays with empty lists but gave a deprecation warning (which I hadn't noticed until I ran some tests in a terminal just now. It still works OK on ubuntu 22, which I'm using here, but will obviously fail soon)

I will push a new version up to github and pypi later today so you should be able to pip install --upgrade

PS I spoke too soon. PYPI has become almost impossible to upload to unless the developer is doing it on a frequent basis. I have to log onto my account to get a code to allow me to log onto my account!! I probably had an app installed on my phone last time I did this... but I've got a different phone now. When I lodged a request to unfreeze my account I ticked a checkbox to the effect that it might take the administrators a very long time to sort it out (presumably there a lot of accounts on PYPI that are currently unmaintainable)

joshstir commented 1 year ago

Sorry for my late reply, that did fix it, but you've already got it fixed. 😃. Thanks for taking a look at this!