Commit 13566a2
Sol review fixes (#61)
* Make parallel_for_chunks exception-safe
A throw from a worker chunk previously called std::terminate (unhandled
exception in std::thread), and a throw from the thread-0 chunk destroyed
joinable threads — either way aborting the whole process, e.g. for
negative labels in the distributed block scanners with
number_of_threads > 1. Capture the first exception, always join every
worker, and rethrow on the calling thread.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Compute standard deviations numerically stably
The naive sum_of_squares/count - mean^2 formula suffers catastrophic
cancellation for values with a large baseline and small spread (e.g.
values [1e8, 1e8+1] gave std 0.0 instead of 0.5).
- Distributed: switch the (n, 5) partial-stats layout from
[count, sum, sum_of_squares, min, max] to the Welford/Chan
representation [count, mean, M2, min, max]; merge via the Chan
combine, finalize as variance = M2 / count.
- In-core complex features: compute the variance two-pass from the
values already stored for the percentiles (exact).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Update the feature-merge accumulator in place
merge_block_edge_stats copied the entire (E, 5) global accumulator on
every call, making the documented per-block merge loop
O(number_of_blocks x global_edges). Mutate the caller's accumulator in
place instead (and return it, so existing loops keep working): one merge
is now O(block edges) regardless of global graph size. The Python
wrapper requires a C-contiguous writable float64 accumulator and no
longer coerces it (a silent copy would discard the update).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate merge_edges via sort + unique
The unordered_set added ~8x node/bucket overhead over the raw edge
data (about 114 MB extra for one million edges). Canonicalize into a
vector and sort + unique instead: same sorted-unique output, peak
memory close to one copy of the input. Document that outputs are valid
inputs, so callers can bound peak memory with a hierarchical merge.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Reject non-integral and negative inputs in graph.distributed
- own_begin / own_shape now require integer dtypes (floats such as
[0.9, 0] were silently truncated by int()).
- Affinity offsets go through operator.index, which rejects floats.
- merge_edges rejects floating-dtype edge arrays and negative node ids
in signed arrays (an int64 edge [-1, 2] silently wrapped to
[2, 2**64 - 1] via the unconditional uint64 cast).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Return the Python UndirectedGraph subclass from from_(unique_)edges
The core statics return the raw _core.UndirectedGraph, so results
lacked the subclass convenience wrappers (find_edges on lists, ...) and
failed isinstance checks against bic.graph.UndirectedGraph. Add a
constructor overload taking (number_of_nodes, uvs, unique) — an
__init__ overload constructs the derived Python class, unlike a static
— and build the subclass classmethods on it. from_edges also gains the
single-pass C++ construction instead of insert_edges.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Document the dense-label requirement of the distributed pipeline
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Remove unused imports and variables (pyflakes)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Share one clipped grid sweep between in-core and distributed scans
The 2D/3D offset-box sweeps in feature_accumulation.hxx and the
owned-box sweeps in the distributed block extraction duplicated the
same clamp + loop logic. Move a single sweep_clipped_box_{2d,3d} with a
per-axis clip box into detail/grid.hxx; the in-core wrappers pass the
thread slab with unclipped remaining axes, the distributed dispatch
folds the owned box and slab into the clips. Inner loops are unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Fix build issues on Mac by removing jthread
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent fad254f commit 13566a2
16 files changed
Lines changed: 505 additions & 261 deletions
File tree
- include/bioimage_cpp
- detail
- graph
- distributed
- src
- bindings
- bioimage_cpp
- graph
- label_multiset
- tests
- graph
- label_multiset
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
503 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
504 | 508 | | |
505 | 509 | | |
506 | 510 | | |
| |||
519 | 523 | | |
520 | 524 | | |
521 | 525 | | |
522 | | - | |
| 526 | + | |
523 | 527 | | |
524 | 528 | | |
525 | | - | |
| 529 | + | |
526 | 530 | | |
527 | 531 | | |
528 | 532 | | |
529 | 533 | | |
530 | 534 | | |
531 | 535 | | |
532 | 536 | | |
533 | | - | |
534 | | - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
535 | 542 | | |
536 | 543 | | |
537 | 544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
114 | 209 | | |
115 | 210 | | |
116 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
84 | 94 | | |
85 | 95 | | |
86 | 96 | | |
| |||
0 commit comments