-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure the EXCLUDE_OBJECT_DEFINE comes before any other GCode This allows use of the defined objects in your PRINT_START macros Move typing imports into TYPE_CHECKING blocks, which removes the need for installing typing_extensions or mypy_extensions at runtime
- Loading branch information
Showing
10 changed files
with
113 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "preprocess_cancellation" | ||
version = "0.3.a1" | ||
version = "0.3.a2" | ||
description = "GCode processor to add klipper exclude-object markers" | ||
readme = "README.md" | ||
authors = ["Franklyn Tackitt <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import math | ||
|
||
import pytest | ||
|
||
from preprocess_cancellation.hulls import ShapelyHullTracker | ||
from preprocess_cancellation.types import Point | ||
|
||
try: | ||
import shapely.geometry # pylint: disable=unused-import | ||
except ImportError: | ||
pytest.skip("Requires shapely installed", allow_module_level=True) | ||
except OSError: | ||
pytest.skip("Requires libgeos installed", allow_module_level=True) | ||
|
||
|
||
def test_shapely_hulls_simple(): | ||
hull_tracker = ShapelyHullTracker() | ||
|
||
hull_tracker.add_point(Point(0.0, 0.0)) | ||
hull_tracker.add_point(Point(0.0, 1.0)) | ||
hull_tracker.add_point(Point(1.0, 1.0)) | ||
hull_tracker.add_point(Point(1.0, 0.0)) | ||
|
||
assert hull_tracker.exterior() == [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)] | ||
assert hull_tracker.center() == (0.5, 0.5) | ||
|
||
|
||
def test_shapely_hulls_rhombus(): | ||
hull_tracker = ShapelyHullTracker() | ||
|
||
hull_tracker.add_point(Point(0.0, 5.0)) | ||
hull_tracker.add_point(Point(5.0, 10.0)) | ||
hull_tracker.add_point(Point(10.0, 5.0)) | ||
hull_tracker.add_point(Point(5.0, 0.0)) | ||
|
||
assert hull_tracker.exterior() == [(5.0, 0.0), (0.0, 5.0), (5.0, 10.0), (10.0, 5.0), (5.0, 0.0)] | ||
assert hull_tracker.center() == (5.0, 5.0) | ||
|
||
|
||
def test_shapely_hulls_circle(): | ||
hull_tracker = ShapelyHullTracker() | ||
center = Point(5.0, 5.0) | ||
|
||
for i in range(0, 360, 1): | ||
hull_tracker.add_point( | ||
Point( | ||
center.x + 5 * math.cos(math.radians(i)), | ||
center.y + 5 * math.sin(math.radians(i)), | ||
) | ||
) | ||
|
||
# Yeah, its approxamitely a circle? All points are within 0.1mm of the expected circle | ||
for x, y in hull_tracker.exterior(): | ||
assert 4.9 <= math.sqrt((5 - x) ** 2 + (5 - y) ** 2) <= 5.1 | ||
assert hull_tracker.center() == (5.0, 5.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters