Skip to content

internal: GrangerCausalityResult.summary() rebuilds the stacked strength array three times #282

Description

@thomaspinder

Context

After #277, GrangerCausalityResult._stacked() (src/impulso/results.py, ~line 898) builds a named (chain, draw, term) DataArray via np.concatenate on every call — required by the seam's hdi_bounds contract and correct.

Problem

summary() (~line 944) triggers that construction three times per call: once through _stacked_hdi(prob) (which itself calls _stacked() + hdi_bounds) and again directly for the median row. Refactor artifact from the migration; purely repeated work, no correctness impact.

Suggested approach

Bind stacked = self._stacked() once in summary() and pass it through (e.g. let _stacked_hdi accept an optional prebuilt array, or inline the hdi_bounds call). Behaviour covered by existing Granger tests; no new tests needed.

Affected files

  • src/impulso/results.py (GrangerCausalityResult._stacked / _stacked_hdi / summary)

Metadata

Metadata

Assignees

No one assigned

    Labels

    internalInternal improvements (refactor, test, chore)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions