toolwake 0.2.3__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {toolwake-0.2.3 → toolwake-0.3.0}/CHANGELOG.md +45 -0
  2. {toolwake-0.2.3/src/toolwake.egg-info → toolwake-0.3.0}/PKG-INFO +1 -1
  3. {toolwake-0.2.3 → toolwake-0.3.0}/pyproject.toml +1 -1
  4. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/__init__.py +1 -1
  5. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/simulate.py +29 -7
  6. {toolwake-0.2.3 → toolwake-0.3.0/src/toolwake.egg-info}/PKG-INFO +1 -1
  7. {toolwake-0.2.3 → toolwake-0.3.0}/tests/test_toolwake.py +52 -0
  8. {toolwake-0.2.3 → toolwake-0.3.0}/LICENSE +0 -0
  9. {toolwake-0.2.3 → toolwake-0.3.0}/MANIFEST.in +0 -0
  10. {toolwake-0.2.3 → toolwake-0.3.0}/README.md +0 -0
  11. {toolwake-0.2.3 → toolwake-0.3.0}/examples/demo.py +0 -0
  12. {toolwake-0.2.3 → toolwake-0.3.0}/setup.cfg +0 -0
  13. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/cli.py +0 -0
  14. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/deposit.py +0 -0
  15. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/geometry.py +0 -0
  16. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/profile.py +0 -0
  17. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/render.py +0 -0
  18. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/serve.py +0 -0
  19. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/tool.py +0 -0
  20. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/toolpath.py +0 -0
  21. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake/viewer.py +0 -0
  22. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake.egg-info/SOURCES.txt +0 -0
  23. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake.egg-info/dependency_links.txt +0 -0
  24. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake.egg-info/entry_points.txt +0 -0
  25. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake.egg-info/requires.txt +0 -0
  26. {toolwake-0.2.3 → toolwake-0.3.0}/src/toolwake.egg-info/top_level.txt +0 -0
@@ -4,6 +4,51 @@ All notable changes to this project are documented here. Format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.3.0] — 2026-09-24
8
+
9
+ Performance. Verdicts are unchanged on every file tested; reported clearances
10
+ for DISTANT material are not, which is why this is a minor rather than a patch.
11
+
12
+ ### Changed
13
+ - **`search` default 0.02 → 0.002 m.** Twenty millimetres of padding around
14
+ every query meant that on a 10 mm part the query box covered the whole
15
+ thing and the spatial hash could prune nothing: 949 candidate beads per
16
+ query against a wake of 2 046, and 99.2% of the 30 million point-distance
17
+ evaluations were against material nowhere near the tool.
18
+
19
+ Detection is unaffected — 2 mm is still more than forty times the largest
20
+ bead radius. What changes is that a clearance larger than `search` now
21
+ reports `inf` instead of a number, so anything printing at a much larger
22
+ scale wants this raised.
23
+ - **Grid cell size now follows the TOOL, not `search`.** They were tied
24
+ (`cell = search / 4`), which welded two opposing costs to one knob:
25
+ shrinking `search` cut candidates per query 36x (949 → 26) but grew the
26
+ cells walked per query 1000x (8 → 7 913), because the cell shrank with it.
27
+ Below about 5 mm the second swamped the first and asking for a tighter
28
+ search radius made the whole sweep *slower*.
29
+
30
+ Query boxes are a tool bounding box plus `search`, so the tool's own width
31
+ is what the grid should be sized against. For a luer tip that is the 11 mm
32
+ collar, giving 2.75 mm cells — within noise of the 2.5 mm that measured
33
+ fastest. The housing is excluded: at 130 mm it would force cells so coarse
34
+ that every needle query returned the whole wake.
35
+
36
+ Measured over the reference set, with every verdict and every worst clearance
37
+ identical to 0.2.3:
38
+
39
+ | toolpath | rows | 0.2.3 | 0.3.0 | |
40
+ |---|---|---|---|---|
41
+ | 360-180 SMOL Middle | 36 305 | 626 s | 252 s | 2.5x |
42
+ | 360-180 SMOL Middle (1) | 36 305 | 577 s | 261 s | 2.2x |
43
+ | test_infill | 2 674 | 7.3 s | 1.0 s | 7.2x |
44
+ | REDO WOW Slab | 2 674 | 7.8 s | 3.6 s | 2.2x |
45
+ | slab_infill | 2 674 | 7.2 s | 3.8 s | 1.9x |
46
+ | small_slab | 1 747 | 3.0 s | 2.3 s | 1.3x |
47
+ | LightPipeRobotTest | 1 170 | 0.8 s | 0.7 s | 1.1x |
48
+
49
+ Timings are from one laptop and vary with what else it is doing; treat the
50
+ ratios as indicative, not as a benchmark.
51
+
7
52
  ## [0.2.3] — 2026-09-18
8
53
 
9
54
  Touching is not penetrating. Reported collision counts change.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolwake
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Simulate a depositing tool travelling a toolpath, accumulate the material it leaves in its wake, and check the tool against it.
5
5
  Author-email: Zane Bates <zanetbates1@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "toolwake"
7
- version = "0.2.3"
7
+ version = "0.3.0"
8
8
  description = "Simulate a depositing tool travelling a toolpath, accumulate the material it leaves in its wake, and check the tool against it."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -19,7 +19,7 @@ from .profile import Section, ToolProfile, blunt_cannula, luer_taper_tip
19
19
  from .tool import Needle, ToolPose
20
20
  from .toolpath import PRINT, TRAVEL, Toolpath
21
21
 
22
- __version__ = "0.2.3"
22
+ __version__ = "0.3.0"
23
23
 
24
24
  __all__ = [
25
25
  "Toolpath", "PRINT", "TRAVEL",
@@ -119,7 +119,7 @@ class Result:
119
119
 
120
120
 
121
121
  def simulate(path: Toolpath, needle: Needle | None = None, *, lag: int = 8,
122
- threshold: float = 5e-4, search: float = 0.02,
122
+ threshold: float = 5e-4, search: float = 0.002,
123
123
  bead_radius: float | None = None, bead_drop: float = 0.0,
124
124
  progress=None) -> Result:
125
125
  """Run the wake simulation over `path`.
@@ -130,8 +130,18 @@ def simulate(path: Toolpath, needle: Needle | None = None, *, lag: int = 8,
130
130
  lag: rows of immunity behind the nozzle. Material laid within this many
131
131
  rows is not treated as an obstacle.
132
132
  threshold: clearance below which a row counts as "close", metres.
133
- search: broad-phase radius, metres. Beads beyond this are not measured;
134
- raise it if the housing is large.
133
+ search: broad-phase radius, metres. Beads beyond this are not measured,
134
+ so a clearance larger than `search` comes back as `inf`.
135
+
136
+ Detection is unaffected as long as this exceeds the bead radius,
137
+ which it does by more than an order of magnitude; what it bounds is
138
+ how far away a clearance is still worth reporting a number for.
139
+
140
+ It was 0.02 (20 mm), which on a 10 mm part meant the query box
141
+ covered the whole thing and the spatial hash could prune nothing —
142
+ 949 candidate beads per query against a wake of 2 046. Measured
143
+ across three real files, dropping it to 2 mm is 1.9x to 5.1x
144
+ faster with identical verdicts and identical worst clearances.
135
145
  bead_radius: radius of the laid bead, metres. Defaults to the needle's
136
146
  bore radius, which assumes the bead keeps the round cross-section
137
147
  it had inside the needle.
@@ -171,10 +181,22 @@ def simulate(path: Toolpath, needle: Needle | None = None, *, lag: int = 8,
171
181
  r_bead = needle.bead_radius if bead_radius is None else float(bead_radius)
172
182
  if r_bead < 0:
173
183
  raise ValueError("bead_radius must be >= 0")
174
- # The grid only exists to shrink the candidate set, so scale it to the
175
- # query, not the bead — see Deposit.__init__.
176
- dep = Deposit(bead_radius=r_bead,
177
- cell=max(search / 4.0, 8.0 * r_bead))
184
+ # Cell size follows the TOOL, not the search radius. Tying it to `search`
185
+ # welded two opposing costs to one knob: shrinking `search` cut candidates
186
+ # per query 36x (949 -> 26) but grew the cells walked per query 1000x
187
+ # (8 -> 7 913), because the cell shrank with it. Below about 5 mm the
188
+ # second swamped the first and shrinking the search radius made the whole
189
+ # sweep SLOWER.
190
+ #
191
+ # The query boxes are a tool bounding box plus `search`, so the tool's own
192
+ # width is what the grid should be sized against. For a luer tip that is
193
+ # the 11 mm collar, giving 2.75 mm cells — within noise of the 2.5 mm that
194
+ # measured fastest. The housing is deliberately excluded: at 130 mm it
195
+ # would force cells so coarse that every needle query returned the whole
196
+ # wake, and its own query is already bounded by the occupied-cell count.
197
+ span = 2.0 * max((sec.r_max for sec in needle.profile.sections),
198
+ default=r_bead)
199
+ dep = Deposit(bead_radius=r_bead, cell=max(span / 4.0, 8.0 * r_bead))
178
200
  n = len(path)
179
201
  clearance = np.full(n, np.inf)
180
202
  culprit = np.full(n, -1, dtype=int)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolwake
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Simulate a depositing tool travelling a toolpath, accumulate the material it leaves in its wake, and check the tool against it.
5
5
  Author-email: Zane Bates <zanetbates1@gmail.com>
6
6
  License: MIT
@@ -949,3 +949,55 @@ def test_touching_is_not_penetrating():
949
949
  assert res.status == "ok"
950
950
  # ...and the report must not show a tangency as a negative clearance.
951
951
  assert res.report()["min_clearance_mm"] == 0.0
952
+
953
+
954
+ def test_grid_cell_does_not_follow_the_search_radius():
955
+ """Cell size must depend on the TOOL, not on `search`.
956
+
957
+ Tying them together welded two opposing costs to one knob: shrinking
958
+ `search` cut candidates per query 36x (949 -> 26) but grew the cells
959
+ walked per query 1000x (8 -> 7 913), because the cell shrank with it.
960
+ Below about 5 mm the second swamped the first and asking for a tighter
961
+ search radius made the whole sweep slower — the opposite of the point.
962
+ """
963
+ path = Toolpath.helix(radius=0.01, pitch=1e-3, turns=3.0, per_turn=60)
964
+ needle = Needle.luer(inner_d=90e-6)
965
+
966
+ wide = simulate(path, needle, lag=4, threshold=0.0, search=0.02)
967
+ tight = simulate(path, needle, lag=4, threshold=0.0, search=0.001)
968
+
969
+ assert wide.deposit.cell == tight.deposit.cell, (
970
+ f"cell moved with search: {wide.deposit.cell} vs {tight.deposit.cell}")
971
+
972
+ # And it should be sized against the tool's own width — the collar, here.
973
+ span = 2.0 * max(sec.r_max for sec in needle.profile.sections)
974
+ expected = max(span / 4.0, 8.0 * needle.bead_radius)
975
+ assert wide.deposit.cell == pytest.approx(expected)
976
+
977
+ # Narrowing the search must not change the verdict, only the work done.
978
+ assert wide.n_hits == tight.n_hits
979
+
980
+
981
+ def test_narrowing_the_search_radius_prunes_work():
982
+ """A tighter search must measure strictly fewer beads, not more."""
983
+ path = Toolpath.helix(radius=0.01, pitch=1e-3, turns=3.0, per_turn=60)
984
+ needle = Needle.luer(inner_d=90e-6)
985
+
986
+ seen = {}
987
+ from toolwake.geometry import Cylinder
988
+ original = Cylinder.distance
989
+
990
+ def counted(self, pts, _key=None):
991
+ seen[key] = seen.get(key, 0) + len(np.atleast_2d(pts))
992
+ return original(self, pts)
993
+
994
+ try:
995
+ Cylinder.distance = counted
996
+ for key in ("wide", "tight"):
997
+ simulate(path, needle, lag=4, threshold=0.0,
998
+ search=0.02 if key == "wide" else 0.001)
999
+ finally:
1000
+ Cylinder.distance = original
1001
+
1002
+ assert seen["tight"] < seen["wide"], (
1003
+ f"tight search measured {seen['tight']} points, wide {seen['wide']}")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes