Skip to main content

connectivity

Function connectivity 

Source
pub fn connectivity(
    inputs: &Inputs<'_>,
    config: &Config<'_>,
) -> Result<Array2<f32>>
Expand description

Connectedness, or BERI when Inputs::transgrids is non-empty, of every unmasked cell.

Returns an array with the shape of Inputs::condition: NaN where the mask is true, otherwise the mean score over Config::lambdas, normally in [0, 1] and 0 for a cell that reaches no destination.

§Errors

Returns an error when Inputs::traversal differs in shape from the condition array ("Dimension mismatch for key <level>: <traversal shape> vs <condition shape>"). The Python binding raises errors as RuntimeError("Connectivity failed: <message>").

§Panics

Invalid settings panic, with messages the Python binding raises as pyo3_runtime.PanicException; panics on worker threads reach the caller through Rayon.

  • A level that is not a power of two ("Failed average resampling.: Level 3 is not a power of 2"), or no level-1 transform ("Missing base-level transform (key=1).").
  • When at least one cell is unmasked: no level 1 ("Base condition level not found!"), an even window_size ("Window size must be odd-numbered") or an even outer_window >= window_size ("Outer window size must be odd-numbered"), a level without a transform ("Missing level in Affine set."), or levels that skip a power of two once a level past the gap has window cells ("levels must form a continuous power-of-two sequence").
  • An integer path cost beyond u32::MAX, e.g. from a very large max_cost or unscaled traversal values ("Path cost overflow; check max_cost and resistance scaling!").
  • A mask or transgrid smaller than the condition array can panic on indexing.