compas
compas copied to clipboard
`offset_polygon()` returns `TypeError` when the parameter `polygon` is provided a `Polygon` instance
Describe the bug
The compas.geometry.offset_polygon() returns TypeError when the parameter polygon is provided a Polygon instance
To Reproduce Running this script with Python 3.11
from compas.geometry import Polygon
from compas.geometry import offset_polygon
pts = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
polygon = Polygon(pts)
offset_polygon(pts, 0.1) # this works
offset_polygon(polygon, 0.1) # this is not working
returns
Traceback (most recent call last):
File "/PATH/TO/SCRIPTS/offset.py", line 7, in <module>
offset_polygon(polygon, 0.1)
File "/opt/homebrew/Caskroom/miniconda/base/envs/ENV_NAME/lib/python3.11/site-packages/compas/geometry/offset/offset.py", line 147, in offset_polygon
polygon = polygon + polygon[:1]
~~~~~~~~^~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'Polygon' and 'list'
Expected behavior
As the doc implies, the polygon parameter should accept sequence[point] | [Polygon]
Desktop (please complete the following information):
- OS: macOS 14.1.1
- Python version: 3.11.6
- Python package manager: conda
- compas version: 1.17.9
Also, the docs said that it returns a list where the first and last coordinates are identical. This is not the case when I run the script, and it returns 4 pts instead.
IMO this is a better behavior as it is consistent with the input.