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

fix (specklepy): update polyline class to use closed flag #394

Open
wants to merge 1 commit into
base: v3-dev
Choose a base branch
from

Conversation

dogukankaratas
Copy link

  • Added a closed bool property to directly get and set
  • changed is_closed() from an instance method to static method. still accessible but not tightly coupled.
  • updated tests

Copy link
Member

@KatKatKateryna KatKatKateryna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave a comment based on C# description, otherwise other recommendations are optional and non-critical 🙌

"""
if len(self.value) < 6: # need at least 2 points to be closed
if len(points) < 6: # need at least 2 points to be closed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least 3 points for non-overlapping start-end coordinates to make a closed shape, and at least 4 points for start-end coordinates to possibly overlap

assert closed_poly.is_closed()
# Test with closed flag
open_poly = Polyline(value=open_square_coords, units=Units.m)
closed_poly = Polyline(value=closed_square_coords, units=Units.m, closed=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically doesn't make difference for this test, but the "value" should be =open_square_coords, to create (what we expect to be) a valid speckle polyline (following C# class)

This applies to all usages of "closed_square_coords" in the tests. It should only be used to test the static .is_closed method, but not to construct a Polyline

@@ -13,24 +14,28 @@ class Polyline(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Polyline"
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add a comment here from C# to make it clear how "closed" Polyline should look like: "/// If true, do not add the last point to the value list. Polyline first and last points should be unique."

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

Successfully merging this pull request may close these issues.

3 participants