Clip the selection values to compute the expected selection. Reproduces the clipping performed by the RangeManager.
(sel, rng, selection_to_range_min)
| 329 | rman.set_range(full_range[0], full_range[1]) |
| 330 | |
| 331 | def _clip_selection(sel, rng, selection_to_range_min): |
| 332 | """ |
| 333 | Clip the selection values to compute the expected selection. |
| 334 | Reproduces the clipping performed by the RangeManager. |
| 335 | """ |
| 336 | sel = [max(min(_, rng[1]), rng[0]) for _ in sel] |
| 337 | if value_type == "float": |
| 338 | min_diff = (rng[1] - rng[0]) * selection_to_range_min |
| 339 | else: |
| 340 | min_diff = 1 |
| 341 | if sel[1] - sel[0] < min_diff: |
| 342 | sel[1] = sel[0] + min_diff |
| 343 | if sel[1] > rng[1]: |
| 344 | sel = [rng[1] - min_diff, rng[1]] |
| 345 | return sel |
| 346 | |
| 347 | sel = _clip_selection(selection, full_range, selection_to_range_min) |
| 348 |
no outgoing calls
no test coverage detected