compas-dev / compas

Core packages of the COMPAS framework.
https://compas.dev/compas/
MIT License
307 stars 106 forks source link

Point float arithmetic not mutable?! #1344

Open xarthurx opened 3 months ago

xarthurx commented 3 months ago

Describe the bug The code means more than a thousand words:

>>> p1 = cg.Point(1.2, 4, 3)
>>> p1                           
Point(x=1.2, y=4.0, z=3.0)
>>> p1 * 0.5 
Point(x=0.6, y=2.0, z=1.5)
>>> 0.5 * p1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'float' and 'Point'

Expected behavior No Errors

Desktop (please complete the following information):

Additional context Is this by design?!

gonzalocasas commented 3 months ago

This was discussed recently here https://github.com/compas-dev/compas/issues/1248#issuecomment-1877582973

xarthurx commented 3 months ago

This was discussed recently here #1248 (comment)

OK. as one basic math operations, I DO think this is very necessary and common... If you don't support sth like this, I would recommend it should be highlighted in the documentation...

Based on my experience, people may prefer to put the float in front, especially when you compute a

*"WEIGHTED long-expression"**