Skip to content

Commit 4ae4c6f

Browse files
fdrgsprlokkiepre-commit-ci[bot]tlambert03
authored
refactor: update GridFromPolygon (#241)
* added GridFromPolygon * style(pre-commit.ci): auto fixes [...] * shapely for all logic, and refactored pydantic bit * style(pre-commit.ci): auto fixes [...] * feat: brought tile formation in line with other gridplans, and updated plotting * style(pre-commit.ci): auto fixes [...] * refactored docstrings * style(pre-commit.ci): auto fixes [...] * moved polygon manipulation to initialization, added plotting offsetted polygon Moved offset and convex hull before bounding box creation of prepared polygon. Offset polygon is now used for plotting. Some skipped tiles seem to be present when offsetting, different buffer style may fix that. Not happy yet with the coverage of the exterior line of the polygon, may be because of the bounding box is under/over-influenced by fov-size. * style(pre-commit.ci): auto fixes [...] * Added docstrings, removed some non functional pydantic annotations, enlarged initial bounding box enlarged the initial bounding box slightly by fov, this ensures to-be-checked tiles will also be created on the extreme edges of the polygon. * Import PrivateAttr to hide some attributes in the signature gridfrompolygon * Fix private attributes * feat: update polygon * fix: fix MDASequence * fix: fix MDASequence * feat: update plot methods * fix: set default * feat: handle plot figure size * fix ZeroDivisionError * fix overlap * style(pre-commit.ci): auto fixes [...] * fix mypy * fix again * ignore deprecation * change semantics of polygon bounds * remove caching * format * fix test * skip win3.9 --------- Co-authored-by: rlokkie <re.lokhorst@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Talley Lambert <talley.lambert@gmail.com> Co-authored-by: rlokkie <93552211+rlokkie@users.noreply.github.com>
1 parent 77bb8df commit 4ae4c6f

File tree

9 files changed

+343
-139
lines changed

9 files changed

+343
-139
lines changed

examples/grid_from_poly.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from useq import GridFromPolygon
2+
3+
grid = GridFromPolygon(
4+
vertices=[(0, 0), (3, 0), (3, 0.82), (1, 1), (0.7, 3), (0, 3)],
5+
fov_height=0.4,
6+
fov_width=0.4,
7+
# convex_hull=True,
8+
)
9+
10+
grid.plot(show=True)

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ dependencies = [
4242
"numpy >=1.26.0; python_version >= '3.12'",
4343
"numpy >=1.25.2",
4444
"typing-extensions >=4",
45+
"shapely>=2.0.7",
4546
]
4647

4748
# extras
@@ -131,7 +132,10 @@ ban-relative-imports = "all"
131132
[tool.pytest.ini_options]
132133
minversion = "6.0"
133134
testpaths = ["tests"]
134-
filterwarnings = ["error"]
135+
filterwarnings = [
136+
"error",
137+
"ignore:'mode' parameter is deprecated and will be removed:DeprecationWarning",
138+
]
135139

136140
# https://mypy.readthedocs.io/en/stable/config_file.html
137141
[tool.mypy]

src/useq/_base_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from typing_extensions import Self
2222

23-
ReprArgs = Iterable[tuple[str | None, Any]]
23+
ReprArgs = Iterable[tuple["str | None", Any]]
2424

2525
__all__ = ["FrozenModel", "UseqModel"]
2626

0 commit comments

Comments
 (0)