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

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

Open
Home-Control9000 opened this issue Jun 20, 2023 · 5 comments

Comments

@Home-Control9000
Copy link

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

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

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

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

paddywwoof commented Sep 26, 2023

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

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

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

No branches or pull requests

3 participants