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

offset_polygon() returns TypeError when the parameter polygon is provided a Polygon instance #1215

Open
ChiaChing-Yen opened this issue Nov 28, 2023 · 1 comment

Comments

@ChiaChing-Yen
Copy link

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
@ChiaChing-Yen
Copy link
Author

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.

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

1 participant