compas icon indicating copy to clipboard operation
compas copied to clipboard

Point float arithmetic not mutable?!

Open xarthurx opened this issue 1 year ago • 2 comments

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):

  • OS: Win/Linux
  • Python version [e.g. 2.7]
  • Python package manager [e.g. macports, pip, conda]

Additional context Is this by design?!

xarthurx avatar Apr 29 '24 11:04 xarthurx

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

gonzalocasas avatar Apr 29 '24 11:04 gonzalocasas

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"

xarthurx avatar Apr 29 '24 11:04 xarthurx