toolwake 0.2.2__tar.gz → 0.2.3__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.2 → toolwake-0.2.3}/CHANGELOG.md +26 -0
  2. {toolwake-0.2.2/src/toolwake.egg-info → toolwake-0.2.3}/PKG-INFO +1 -1
  3. {toolwake-0.2.2 → toolwake-0.2.3}/pyproject.toml +1 -1
  4. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/__init__.py +1 -1
  5. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/simulate.py +35 -4
  6. {toolwake-0.2.2 → toolwake-0.2.3/src/toolwake.egg-info}/PKG-INFO +1 -1
  7. {toolwake-0.2.2 → toolwake-0.2.3}/tests/test_toolwake.py +29 -0
  8. {toolwake-0.2.2 → toolwake-0.2.3}/LICENSE +0 -0
  9. {toolwake-0.2.2 → toolwake-0.2.3}/MANIFEST.in +0 -0
  10. {toolwake-0.2.2 → toolwake-0.2.3}/README.md +0 -0
  11. {toolwake-0.2.2 → toolwake-0.2.3}/examples/demo.py +0 -0
  12. {toolwake-0.2.2 → toolwake-0.2.3}/setup.cfg +0 -0
  13. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/cli.py +0 -0
  14. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/deposit.py +0 -0
  15. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/geometry.py +0 -0
  16. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/profile.py +0 -0
  17. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/render.py +0 -0
  18. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/serve.py +0 -0
  19. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/tool.py +0 -0
  20. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/toolpath.py +0 -0
  21. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake/viewer.py +0 -0
  22. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake.egg-info/SOURCES.txt +0 -0
  23. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake.egg-info/dependency_links.txt +0 -0
  24. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake.egg-info/entry_points.txt +0 -0
  25. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake.egg-info/requires.txt +0 -0
  26. {toolwake-0.2.2 → toolwake-0.2.3}/src/toolwake.egg-info/top_level.txt +0 -0
@@ -4,6 +4,32 @@ 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.2.3] — 2026-09-18
8
+
9
+ Touching is not penetrating. Reported collision counts change.
10
+
11
+ ### Fixed
12
+ - **Exact tangency was reported as a collision, at random.** With
13
+ `bead_radius` and `bead_drop` both h/2 — the setting that makes a bead fill
14
+ its layer, which 0.2.1 introduced — a same-layer neighbour passing under the
15
+ nozzle wall sits at a clearance of EXACTLY zero. Which side of zero each one
16
+ lands on is rounding, not geometry.
17
+
18
+ On a real 36 305-row part that put **4 677 rows, 12.9% of the file**, on the
19
+ wrong side and reported them as collisions. Every one was blamed on the
20
+ cannula, every culprit bead was a same-layer neighbour 0.066–0.093 mm away
21
+ laterally — under the wall, outside the bore — and every penetration depth
22
+ printed as `-0.0000 mm`.
23
+
24
+ `Result.n_hits` and `Result.status` now ignore anything shallower than
25
+ `CONTACT_TOL` (1e-12 m), which is six orders of magnitude above
26
+ double-precision noise on metre-scale coordinates and seven below anything
27
+ this models. `report()` reports such a row as `0.0` rather than `-0.0`.
28
+ - **A zero threshold reported tangencies as "close".** With no warning band,
29
+ a clearance of -1e-13 satisfied both "not penetrating" and "below the
30
+ threshold", so a clean result came back as `warn`. A threshold of zero now
31
+ means what it says: only penetration counts.
32
+
7
33
  ## [0.2.2] — 2026-09-18
8
34
 
9
35
  Bounds the size of the viewer page. No reported number changes.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolwake
3
- Version: 0.2.2
3
+ Version: 0.2.3
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.2"
7
+ version = "0.2.3"
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.2"
22
+ __version__ = "0.2.3"
23
23
 
24
24
  __all__ = [
25
25
  "Toolpath", "PRINT", "TRAVEL",
@@ -23,6 +23,21 @@ from .toolpath import PRINT, Toolpath
23
23
 
24
24
  __all__ = ["Result", "simulate"]
25
25
 
26
+ # Below this, a negative clearance is not a penetration — it is a tangency that
27
+ # lost a coin-flip on the sign bit, metres.
28
+ #
29
+ # Tangency is not an edge case here, it is the designed-for case: with
30
+ # `bead_radius` and `bead_drop` both h/2 a bead exactly fills its layer, so a
31
+ # same-layer neighbour passing under the nozzle wall sits at a clearance of
32
+ # EXACTLY zero. Whether each one lands at +0, -1e-18 or +1e-18 is rounding.
33
+ #
34
+ # On a real 36 305-row part that put 4 677 rows — 12.9% of the file — on the
35
+ # wrong side of zero and reported them as collisions, every one at a depth that
36
+ # printed as -0.0000 mm. A picometre is six orders of magnitude above
37
+ # double-precision noise on metre-scale coordinates and seven below anything
38
+ # this models, so nothing physical can hide beneath it.
39
+ CONTACT_TOL = 1e-12
40
+
26
41
 
27
42
  @dataclass
28
43
  class Result:
@@ -45,13 +60,25 @@ class Result:
45
60
 
46
61
  @property
47
62
  def n_hits(self) -> int:
48
- """Rows where the tool actually penetrates deposited material."""
49
- return int(np.sum(self.clearance < 0))
63
+ """Rows where the tool actually penetrates deposited material.
64
+
65
+ Touching is not penetrating — see CONTACT_TOL.
66
+ """
67
+ return int(np.sum(self.clearance < -CONTACT_TOL))
50
68
 
51
69
  @property
52
70
  def n_close(self) -> int:
53
- """Rows inside the warning band but not penetrating."""
54
- return int(np.sum((self.clearance >= 0) & (self.clearance < self.threshold)))
71
+ """Rows inside the warning band but not penetrating.
72
+
73
+ A threshold of zero means there is no warning band — only penetration
74
+ counts. Without the guard, a tangency at -1e-13 satisfies both
75
+ "not penetrating" and "below zero" and gets reported as close, so a
76
+ result with nothing wrong with it comes back as a warning.
77
+ """
78
+ if self.threshold <= 0:
79
+ return 0
80
+ return int(np.sum((self.clearance >= -CONTACT_TOL)
81
+ & (self.clearance < self.threshold)))
55
82
 
56
83
  @property
57
84
  def status(self) -> str:
@@ -64,6 +91,10 @@ class Result:
64
91
  def report(self) -> dict:
65
92
  """A JSON-ready summary, shaped like a clearance report."""
66
93
  w = self.worst
94
+ # A tangency rounds to "-0.0", which looks like a penetration sitting
95
+ # in a report that has just said there were none.
96
+ if np.isfinite(w) and abs(w) <= CONTACT_TOL:
97
+ w = 0.0
67
98
  i = int(np.argmin(np.where(np.isfinite(self.clearance),
68
99
  self.clearance, np.inf)))
69
100
  return {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolwake
3
- Version: 0.2.2
3
+ Version: 0.2.3
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
@@ -920,3 +920,32 @@ def test_viewer_bounds_the_wake_but_keeps_every_collision():
920
920
  assert len(small) < len(full)
921
921
  assert sum(1 for b in small if b[7]) == n_hot, (
922
922
  "decimation dropped a bead that something collided with")
923
+
924
+
925
+ def test_touching_is_not_penetrating():
926
+ """A tangency must not be reported as a collision.
927
+
928
+ Tangency is the designed-for case, not an edge case: with `bead_radius` and
929
+ `bead_drop` both h/2 a bead exactly fills its layer, so a same-layer
930
+ neighbour passing under the nozzle wall sits at a clearance of EXACTLY
931
+ zero. Which side of zero each one lands on is rounding.
932
+
933
+ On a real 36 305-row part that put 4 677 rows — 12.9% of the file — on the
934
+ wrong side and reported them as collisions, every one at a depth that
935
+ printed as -0.0000 mm.
936
+ """
937
+ from toolwake.simulate import CONTACT_TOL
938
+
939
+ path = Toolpath.helix(radius=0.01, pitch=5e-4, turns=2.0, per_turn=60)
940
+ res = simulate(path, Needle(inner_d=90e-6), lag=4, threshold=0.0)
941
+
942
+ res.clearance = np.array([1e-3, 0.0, -CONTACT_TOL / 10, +CONTACT_TOL / 10,
943
+ -1e-6, -2e-3])
944
+ assert res.n_hits == 2, "only the two real penetrations should count"
945
+ assert res.status == "collision"
946
+
947
+ res.clearance = np.array([1e-3, 0.0, -CONTACT_TOL / 10, +CONTACT_TOL / 10])
948
+ assert res.n_hits == 0, "sub-picometre contact is not a penetration"
949
+ assert res.status == "ok"
950
+ # ...and the report must not show a tangency as a negative clearance.
951
+ assert res.report()["min_clearance_mm"] == 0.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes