compas-dev / compas-dev/compas
`offset_polygon()` returns `TypeError` when the parameter `polygon` is provided a `Polygon` instance
- Dominant language
- Python
- Stars
- 386
- Forks
- 122
- Avg merge
- 11d 46m
- Merged PRs (30d)
- 1
Description
**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
```python
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
```text
Traceback (most recent call last):
File "/PATH/TO/SCRIPTS/offset.py", line 7, in
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](https://compas.dev/compas/1.17.9/api/generated/compas.geometry.offset_polygon.html?highlight=offset#compas.geometry.offset_polygon) 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
Contributor guide
Assessment
This issue has not been assessed yet.