Skip to content

Pathfinder

Depth-first search over the undirected bus/branch graph that enumerates every simple path from a source bus to the active fault bus. The resulting ordered branch lists are used by ElectricalNetwork to inject the mutual-coupling Norton sources with the correct sign.

Physical / modelling context

In a meshed grounding network the mutual coupling between the faulted phase and the grounding return appears only along the path that the phase current actually travels between source and fault. The phase conductor and its associated grounding conductor are inductively coupled segment by segment; the resulting per-segment voltage drop is modelled as a series-EMF that can be Thevenin–Norton-converted into a current source on the grounding-side admittance matrix. To assemble those Norton sources correctly the algorithm has to:

  1. enumerate every simple (loop-free) path from the source bus to the active fault bus over the undirected bus/branch graph,
  2. preserve the traversal direction along each branch — the sign of the impressed Norton current depends on it,
  3. record the branch chain, which the legacy phase-current mode run_fault(..., phase_current_mode="paths") then weights with the optional parallel_coefficient on each branch.

parallel_coefficient only applies to phase_current_mode="paths"

Since 0.6.0 the default mode is "auto", which solves a reduced phase-conductor network from BranchType.phase_impedance_formula instead of splitting a prescribed current over enumerated paths. In that mode parallel_coefficient is not read at all — the split follows from the phase-conductor impedances. Set it only when you deliberately run the older "paths" mode.

The DFS enumeration is exhaustive, and its cost is exponential in the number of independent loops — not in the number of buses. A radial network of 500 buses has two paths and enumerates in milliseconds; a 5×5 grid of 25 buses already has 8 512 simple paths, and a 6×6 grid 1 262 816, which takes about a minute. Treat the enumeration as affordable only for radial and lightly meshed topologies.

Since the first release after 0.6.0 the default phase_current_mode="auto" therefore does not enumerate at all. It only needs to know which sources reach the fault, and Network.sources_reaching(fault) answers that with a breadth-first search in O(V + E). The enumeration runs for the legacy phase_current_mode="paths", for the transient state-space solver, and whenever you ask for it with gi.create_paths(network). net.paths is consequently empty after a default run_fault.

PathFinder.find_paths refuses to enumerate more than network.pathfinder_settings.max_paths paths (default 100_000) and raises a ValueError that names the bus pair instead of running for hours. Raise it for one network with network.pathfinder_settings = gi.PathfinderSettings(max_paths=...) if you genuinely need the full set on a meshed network.

Example

# fragment: assumes a network `net` with the fault "f1" and the buses named below
import groundinsight as gi
from groundinsight.pathfinder import PathFinder

# Build network and choose an active fault — see the quickstart
# for the create_* calls.
net.set_active_fault("f1")

# `create_paths` is NOT called by run_fault in the default
# phase_current_mode="auto". To enumerate the paths explicitly:
gi.create_paths(network=net)
for p in net.paths.values():
    print(p.source, "->", p.fault,
          "via", [b.name for b in p.segments])

# Direct use of the PathFinder helper:
pf = PathFinder(net)
all_paths = pf.find_paths(source_bus_name="bus_substation",
                          fault_bus_name="bus_fault")

Settings and memo per network

The path search keeps its settings and its memo per network (since audit pass 19). Up to then both were module globals: a limit set for one network applied to every network of the process — also to one another thread was solving at that moment — and three module-level dictionaries, shared by all networks and mutated without a lock, kept the branches of networks long gone alive.

Settings. gi.PathfinderSettings holds the two knobs:

Field Default Meaning
max_paths 100_000 most simple paths one (source bus, fault bus) enumeration may produce
cache_size 256 entries per table of the network's memo (LRU)
# fragment: assumes a network `net` with the fault "F"
import groundinsight as gi

net.pathfinder_settings = gi.PathfinderSettings(max_paths=1_000_000)
gi.run_fault(net, "F", phase_current_mode="paths")   # this network only
net.pathfinder_settings = None                        # back to the defaults

The settings are runtime configuration: they are not saved to a project file or a database, but copy.deepcopy, model_copy and pickle keep them. PathFinder(network, settings=...) overrides them for one search.

Memo. network.path_cache() returns the network's PathfinderCache: the adjacency graph built in _build_graph, the (source, fault) → List[Path] results of find_paths and the reaches answers, each table an LRU of cache_size entries keyed on the active-topology fingerprint

(id(network), network.name,
 len(network.buses), len(network.branches),
 frozenset(active_buses), frozenset(active_branches),
 frozenset((branch, from_bus, to_bus) for every active branch))

Repeated PathFinder(network) constructions on the same topology (the inner loop of analysis.inverse_rho_f.evaluate_max_epr_under_k, an outage study returning to its base case) pay the work only once. find_paths returns copies of the cached Path instances, so callers such as define_paths can set Path.name / source / fault without touching the memo. Every operation holds the memo's lock. The memo dies with its network, a copy or an unpickled network starts with an empty one, and two networks never compare unequal because of what they have cached.

Mutating a Network in place

Flipping Bus.active / Branch.active after define_paths() has already been called leaves the previously enumerated paths in network.paths. run_fault notices it and rebuilds them; for your own reads call Network.invalidate_paths(), which also clears the network's memo — and only that network's.

clear_pathfinder_cache(network) clears one network's memo; clear_pathfinder_cache() without an argument clears the memo of every network alive in the process (test fixtures, recovery paths).

Deprecated: the module-level switches

set_pathfinder_max_paths / get_pathfinder_max_paths and gi.set_pathfinder_cache_size / gi.get_pathfinder_cache_size still work and raise a DeprecationWarning. They change the process-wide defaults — pathfinder.default_pathfinder_settings(), the settings of every network without settings of its own — and set_pathfinder_cache_size trims the memo of those networks at once. They will be removed no earlier than two releases and six months after the release that deprecated them.

Before Now
pathfinder.set_pathfinder_max_paths(n) net.pathfinder_settings = gi.PathfinderSettings(max_paths=n)
gi.set_pathfinder_cache_size(n) net.pathfinder_settings = gi.PathfinderSettings(cache_size=n)
pathfinder.get_pathfinder_max_paths() net.pathfinder_settings.max_paths

When outage_context exits

outage_context clears the per-network pathfinder cache on exit as well as on entry (added in 0.5.0). The resident footprint after a long outage sweep therefore matches the externally-visible state of the network rather than carrying one cache entry per visited scenario forward.

API reference

pathfinder

PathFinder Module.

This module provides the PathFinder class, which is responsible for identifying all possible paths between sources and faults within an electrical network. It utilizes Depth-First Search (DFS) to traverse the network graph and determine the connectivity between different buses through branches.

The primary use cases include: - Determining all paths from a specific source to a fault point. - Analyzing the network's topology for fault impact assessment. - Facilitating impedance and grounding calculations based on identified paths.

Settings and memo belong to the network

The search keeps its limits and its memo per network, not per process. A limit in a module global would apply to every network of the process -- also to one that another thread is solving at that moment -- and a memo in module-level dictionaries keyed by id(network) would be mutated from several threads without a lock and keep the branches of networks long gone alive until an LRU evicted them.

Both belong to the network:

  • :class:PathfinderSettings (max_paths, cache_size) is runtime configuration of one network, set with network.pathfinder_settings = PathfinderSettings(...). It is not saved with the network, but copies keep it. A network without settings uses the process-wide defaults, which only the deprecated module-level switches change.
  • :class:PathfinderCache is the memo of one network -- adjacency graphs, enumerated paths and reachability answers per active topology, each table an LRU of cache_size entries guarded by a lock. Network.path_cache() hands it out; it dies with its network, a copy or an unpickled network starts with an empty one, and it takes no part in comparing networks.

The deprecated switches still work, with a DeprecationWarning: they change the process-wide defaults and therefore every network without settings of its own. A small registry of live caches (weak references) remains so that clear_pathfinder_cache() and the deprecated cache-size switch can reach them; the search itself never reads it.

PathFinder

PathFinder(
    network: Network,
    settings: Optional[PathfinderSettings] = None,
)

Find all simple paths between sources and faults in a network.

Constructs an adjacency list representation of the network graph and uses depth-first search (DFS) to identify all possible paths between a given source bus and fault bus. These paths are used to inject the mutual-coupling Norton sources with the correct sign in :mod:groundinsight.electrical_network.

Parameters:

Name Type Description Default
network Network

The :class:Network instance containing buses and branches.

required
settings PathfinderSettings

Settings for this search only. Defaults to network.pathfinder_settings.

None
Notes

The adjacency graph, the per-(source, fault) paths and the reachability answers are memoised in the network's own :class:PathfinderCache (network.path_cache()), keyed on a topology fingerprint (id(network), name, n_buses, n_branches, frozenset(active_buses), frozenset(active_branches), connectivity). Repeated constructions over the same logical topology -- for example the inner loop of :func:groundinsight.analysis.evaluate_max_epr_under_k -- therefore pay the DFS cost only on the first call, and nothing is shared with another network.

Build the adjacency-list representation of network.

Parameters:

Name Type Description Default
network Network

The Network instance containing buses and branches.

required
settings PathfinderSettings

Settings for this search; defaults to the network's.

None
Source code in src/groundinsight/pathfinder.py
def __init__(self, network: Network, settings: Optional[PathfinderSettings] = None):
    """
    Build the adjacency-list representation of ``network``.

    Parameters
    ----------
    network : Network
        The Network instance containing buses and branches.
    settings : PathfinderSettings, optional
        Settings for this search; defaults to the network's.
    """
    self.network = network
    self.settings = settings if settings is not None else network.pathfinder_settings
    self._cache = network.path_cache()
    self._topology_key = self._compute_topology_key()
    graph = self._cache.get("graph", self._topology_key)
    if graph is None:
        graph = self._build_graph()
        self._cache.put("graph", self._topology_key, graph, self.settings.cache_size)
    self.graph = graph

find_paths

find_paths(
    source_bus_name: str, fault_bus_name: str
) -> List[Path]

Find all simple paths between a source bus and a fault bus.

Uses depth-first search (DFS) to enumerate every loop-free route from the source to the fault over the active sub-graph.

Parameters:

Name Type Description Default
source_bus_name str

The name of the source bus.

required
fault_bus_name str

The name of the fault bus.

required

Returns:

Type Description
list of Path

All discovered paths, each as an ordered branch list.

Source code in src/groundinsight/pathfinder.py
def find_paths(self, source_bus_name: str, fault_bus_name: str) -> List[Path]:
    """
    Find all simple paths between a source bus and a fault bus.

    Uses depth-first search (DFS) to enumerate every loop-free route
    from the source to the fault over the active sub-graph.

    Parameters
    ----------
    source_bus_name : str
        The name of the source bus.
    fault_bus_name : str
        The name of the fault bus.

    Returns
    -------
    list of Path
        All discovered paths, each as an ordered branch list.
    """
    cache_key = (
        *self._topology_key,
        source_bus_name,
        fault_bus_name,
    )
    cached = self._cache.get("paths", cache_key)
    if cached is not None:
        # Return *copies* — callers (notably ``define_paths``) mutate
        # the returned ``Path`` instances (assigning ``name``,
        # ``source``, ``fault``) and that mutation must not bleed into
        # the cache.
        return [
            Path(
                name="",
                source="",
                fault="",
                segments=list(p.segments),
            )
            for p in cached
        ]

    all_paths = []
    visited_buses = set()
    path = []

    # Source or fault on an inactive (filtered) bus -> no path possible.
    if source_bus_name not in self.graph or fault_bus_name not in self.graph:
        self._cache.put("paths", cache_key, [], self.settings.cache_size)
        return []

    self._max_paths = self.settings.max_paths
    try:
        self._dfs(source_bus_name, fault_bus_name, visited_buses, path, all_paths)
    except _PathLimitExceededError:
        raise ValueError(
            f"Enumerating the simple paths from bus '{source_bus_name}' to "
            f"bus '{fault_bus_name}' exceeded the limit of {self._max_paths} "
            "paths. The number of simple paths grows exponentially with "
            "the number of loops in the network, so a moderately meshed "
            "network never finishes this enumeration while the solver "
            "itself needs milliseconds. The default "
            "phase_current_mode='auto' does not need the enumeration -- "
            "it solves a reduced phase-conductor network instead. Use it, "
            "or raise the limit for this network with "
            "network.pathfinder_settings = "
            "gi.PathfinderSettings(max_paths=...) if the enumerated paths "
            "are genuinely required."
        ) from None

    # Convert each list of Branch objects to a Path object
    paths = []
    for branch_path in all_paths:
        path = Path(
            name="",  # Name will be assigned in define_paths()
            source="",  # Will be set in define_paths()
            fault="",  # Will be set in define_paths()
            segments=branch_path,
        )
        paths.append(path)
    self._cache.put("paths", cache_key, paths, self.settings.cache_size)
    return [
        Path(
            name="",
            source="",
            fault="",
            segments=list(p.segments),
        )
        for p in paths
    ]

reaches

reaches(source_bus_name: str, fault_bus_name: str) -> bool

Report whether any route connects a source bus to a fault bus.

This is the question the stationary solver actually asks in the default phase_current_mode="auto": a source contributes to a fault if and only if at least one route exists. Answering it with :meth:find_paths means enumerating all simple paths, whose count is exponential in the number of independent loops -- 1 262 816 paths and roughly a minute on a 6x6 grid, against milliseconds in the solver. A breadth-first search over the same active sub-graph, with an early exit at the target, answers it in O(V + E).

The result is exactly equivalent to len(find_paths(...)) > 0: both run over the adjacency list built by :meth:_build_graph, so inactive buses and branches are excluded in the same way.

Parameters:

Name Type Description Default
source_bus_name str

The name of the source bus.

required
fault_bus_name str

The name of the fault bus.

required

Returns:

Type Description
bool

True if a route over active buses and branches exists.

Source code in src/groundinsight/pathfinder.py
def reaches(self, source_bus_name: str, fault_bus_name: str) -> bool:
    """
    Report whether *any* route connects a source bus to a fault bus.

    This is the question the stationary solver actually asks in the
    default ``phase_current_mode="auto"``: a source contributes to a
    fault if and only if at least one route exists. Answering it with
    :meth:`find_paths` means enumerating *all* simple paths, whose count
    is exponential in the number of independent loops -- 1 262 816 paths
    and roughly a minute on a 6x6 grid, against milliseconds in the
    solver. A breadth-first search over the same active sub-graph, with
    an early exit at the target, answers it in ``O(V + E)``.

    The result is exactly equivalent to ``len(find_paths(...)) > 0``:
    both run over the adjacency list built by :meth:`_build_graph`, so
    inactive buses and branches are excluded in the same way.

    Parameters
    ----------
    source_bus_name : str
        The name of the source bus.
    fault_bus_name : str
        The name of the fault bus.

    Returns
    -------
    bool
        ``True`` if a route over active buses and branches exists.
    """
    cache_key = (*self._topology_key, source_bus_name, fault_bus_name)
    cached = self._cache.get("reaches", cache_key)
    if cached is not None:
        return cached

    if source_bus_name not in self.graph or fault_bus_name not in self.graph:
        result = False
    elif source_bus_name == fault_bus_name:
        # A source sitting on the fault bus itself feeds the fault; the
        # DFS reports the empty path for this case, so ``find_paths``
        # returns one (zero-segment) path and the two agree.
        result = True
    else:
        visited = {source_bus_name}
        queue = deque([source_bus_name])
        result = False
        while queue:
            current = queue.popleft()
            for branch in self.graph[current]:
                neighbor = (
                    branch.to_bus
                    if branch.from_bus == current
                    else branch.from_bus
                )
                if neighbor == fault_bus_name:
                    result = True
                    queue.clear()
                    break
                if neighbor not in visited:
                    visited.add(neighbor)
                    queue.append(neighbor)

    self._cache.put("reaches", cache_key, result, self.settings.cache_size)
    return result

PathfinderCache

PathfinderCache(owner: Optional[Network] = None)

The path-search memo of one network.

Internal API: a network hands it out through :meth:Network.path_cache; configure the search with :class:PathfinderSettings instead; not exported from groundinsight and free to change in any release.

Three LRU tables keyed by the active topology of the network (see :meth:PathFinder._compute_topology_key): the adjacency graph, the enumerated paths per (source bus, fault bus) and the reachability answers per pair. Every operation holds the cache's lock, so concurrent readers of one network do not corrupt it.

Obtain it with network.path_cache(), which makes sure the cache belongs to that very network: a shallow copy (model_copy) shares the private attributes of its original, and the owner check gives it a cache of its own on first use. A deep copy and an unpickled network start empty. Any two caches compare equal, so the memo never decides whether two networks are equal.

Parameters:

Name Type Description Default
owner Network

The network the cache belongs to; held weakly.

None
Source code in src/groundinsight/pathfinder.py
def __init__(self, owner: Optional[Network] = None) -> None:
    self._owner = weakref.ref(owner) if owner is not None else None
    self._lock = threading.RLock()
    self._tables: Dict[str, OrderedDict[Hashable, Any]] = {
        name: OrderedDict() for name in _TABLES
    }
    _register(self)

belongs_to

belongs_to(network: Network) -> bool

Whether this cache is the memo of network itself.

Parameters:

Name Type Description Default
network Network

The network asking.

required

Returns:

Type Description
bool

True only for the network the cache was created for.

Source code in src/groundinsight/pathfinder.py
def belongs_to(self, network: Network) -> bool:
    """
    Whether this cache is the memo of ``network`` itself.

    Parameters
    ----------
    network : Network
        The network asking.

    Returns
    -------
    bool
        ``True`` only for the network the cache was created for.
    """
    return self._owner is not None and self._owner() is network

clear

clear() -> None

Drop every entry of every table.

Source code in src/groundinsight/pathfinder.py
def clear(self) -> None:
    """Drop every entry of every table."""
    with self._lock:
        for entries in self._tables.values():
            entries.clear()

get

get(table: str, key: Hashable) -> Any

Look key up in table and mark it as recently used.

Parameters:

Name Type Description Default
table (graph, paths, reaches)

The table.

"graph"
key hashable

The entry's key.

required

Returns:

Type Description
object or None

The stored value, or None when there is none.

Source code in src/groundinsight/pathfinder.py
def get(self, table: str, key: Hashable) -> Any:
    """
    Look ``key`` up in ``table`` and mark it as recently used.

    Parameters
    ----------
    table : {"graph", "paths", "reaches"}
        The table.
    key : hashable
        The entry's key.

    Returns
    -------
    object or None
        The stored value, or ``None`` when there is none.
    """
    with self._lock:
        entries = self._tables[table]
        value = entries.get(key)
        if value is not None:
            entries.move_to_end(key)
        return value

keys

keys(table: str) -> List[Hashable]

The keys of table, least recently used first.

Parameters:

Name Type Description Default
table (graph, paths, reaches)

The table.

"graph"

Returns:

Type Description
list

A snapshot of the keys.

Source code in src/groundinsight/pathfinder.py
def keys(self, table: str) -> List[Hashable]:
    """
    The keys of ``table``, least recently used first.

    Parameters
    ----------
    table : {"graph", "paths", "reaches"}
        The table.

    Returns
    -------
    list
        A snapshot of the keys.
    """
    with self._lock:
        return list(self._tables[table])

owner

owner() -> Optional[Network]

The network this cache belongs to, if it is still alive.

Returns:

Type Description
Network or None

The owner, or None for an unowned or orphaned cache.

Source code in src/groundinsight/pathfinder.py
def owner(self) -> Optional[Network]:
    """
    The network this cache belongs to, if it is still alive.

    Returns
    -------
    Network or None
        The owner, or ``None`` for an unowned or orphaned cache.
    """
    return self._owner() if self._owner is not None else None

put

put(
    table: str, key: Hashable, value: Any, capacity: int
) -> None

Store value and drop the least recently used entries over capacity.

Parameters:

Name Type Description Default
table (graph, paths, reaches)

The table.

"graph"
key hashable

The entry's key.

required
value object

The value; None is not stored.

required
capacity int

Most entries the table may hold afterwards.

required
Source code in src/groundinsight/pathfinder.py
def put(self, table: str, key: Hashable, value: Any, capacity: int) -> None:
    """
    Store ``value`` and drop the least recently used entries over capacity.

    Parameters
    ----------
    table : {"graph", "paths", "reaches"}
        The table.
    key : hashable
        The entry's key.
    value : object
        The value; ``None`` is not stored.
    capacity : int
        Most entries the table may hold afterwards.
    """
    if value is None:
        return
    with self._lock:
        entries = self._tables[table]
        entries[key] = value
        entries.move_to_end(key)
        while len(entries) > capacity:
            entries.popitem(last=False)

sizes

sizes() -> Dict[str, int]

Number of entries per table.

Returns:

Type Description
dict of str to int

{"graph": ..., "paths": ..., "reaches": ...}.

Source code in src/groundinsight/pathfinder.py
def sizes(self) -> Dict[str, int]:
    """
    Number of entries per table.

    Returns
    -------
    dict of str to int
        ``{"graph": ..., "paths": ..., "reaches": ...}``.
    """
    with self._lock:
        return {name: len(entries) for name, entries in self._tables.items()}

trim

trim(capacity: int) -> None

Drop least recently used entries until every table fits capacity.

Parameters:

Name Type Description Default
capacity int

Most entries per table.

required
Source code in src/groundinsight/pathfinder.py
def trim(self, capacity: int) -> None:
    """
    Drop least recently used entries until every table fits ``capacity``.

    Parameters
    ----------
    capacity : int
        Most entries per table.
    """
    with self._lock:
        for entries in self._tables.values():
            while len(entries) > capacity:
                entries.popitem(last=False)

PathfinderSettings

Bases: BaseModel

Settings of the source-to-fault path search of one network.

Assign an instance to network.pathfinder_settings; the settings then apply to every path search on that network -- :func:groundinsight.create_paths, run_fault(..., phase_current_mode="paths"), the transient state-space solver -- and to nothing else. They are runtime configuration: not saved with the network, kept by copies.

Attributes:

Name Type Description
max_paths int

Most simple paths one (source bus, fault bus) enumeration may produce before it stops with a ValueError. The count grows exponentially with the number of loops (a 6x6 grid has 1 262 816); the default phase_current_mode="auto" does not enumerate at all. Defaults to 100_000.

cache_size int

Entries per table of the network's path-search memo (adjacency graph, enumerated paths, reachability) before the least recently used one is dropped. One entry per active topology the network has been searched in -- an outage study visits one per scenario. Defaults to 256.

Examples:

>>> import groundinsight as gi
>>> settings = gi.PathfinderSettings(max_paths=1_000_000)
>>> settings.max_paths, settings.cache_size
(1000000, 256)
>>> network.pathfinder_settings = settings

clear_pathfinder_cache

clear_pathfinder_cache(
    network: Optional[Network] = None,
) -> None

Drop the path-search memo of one network, or of every live network.

Parameters:

Name Type Description Default
network Network

The network whose memo to drop. If None (default), the memo of every network that is alive in the process is dropped -- the coarse reset for test fixtures and "I lost track" recovery paths.

None
Notes

The memo is keyed by the active topology, so an active flip or a rewiring never reads a stale entry; :meth:Network.invalidate_paths calls the scoped form anyway, to release the memory. Other networks keep their memo -- it is theirs.

Examples:

>>> import groundinsight as gi
>>> from groundinsight.api.examples import build_minimal
>>> net = build_minimal()
>>> gi.create_paths(net)
>>> gi.clear_pathfinder_cache(net)
>>> len(net.paths)
1
Source code in src/groundinsight/pathfinder.py
def clear_pathfinder_cache(network: Optional[Network] = None) -> None:
    """Drop the path-search memo of one network, or of every live network.

    Parameters
    ----------
    network : Network, optional
        The network whose memo to drop. If ``None`` (default), the memo of
        every network that is alive in the process is dropped -- the coarse
        reset for test fixtures and "I lost track" recovery paths.

    Notes
    -----
    The memo is keyed by the active topology, so an ``active`` flip or a
    rewiring never reads a stale entry; :meth:`Network.invalidate_paths` calls
    the scoped form anyway, to release the memory. Other networks keep their
    memo -- it is theirs.

    Examples
    --------
    >>> import groundinsight as gi
    >>> from groundinsight.api.examples import build_minimal
    >>> net = build_minimal()
    >>> gi.create_paths(net)
    >>> gi.clear_pathfinder_cache(net)
    >>> len(net.paths)
    1
    """
    if network is None:
        for cache in _live_caches():
            cache.clear()
        return
    network.path_cache().clear()

default_pathfinder_settings

default_pathfinder_settings() -> PathfinderSettings

The settings of networks that have none of their own.

Returns:

Type Description
PathfinderSettings

PathfinderSettings() unless a deprecated module-level switch changed it.

Source code in src/groundinsight/pathfinder.py
def default_pathfinder_settings() -> PathfinderSettings:
    """
    The settings of networks that have none of their own.

    Returns
    -------
    PathfinderSettings
        ``PathfinderSettings()`` unless a deprecated module-level switch
        changed it.
    """
    return _process_defaults

get_pathfinder_cache_size

get_pathfinder_cache_size() -> int

Return the process-wide default size of the path-search memo (deprecated).

.. deprecated:: Read network.pathfinder_settings.cache_size.

Returns:

Type Description
int

The default of networks without settings of their own.

Warns:

Type Description
DeprecationWarning

Always.

Examples:

The replacement reads the settings of one network:

>>> import groundinsight as gi
>>> net = gi.create_network(name="n", frequencies=[50.0])
>>> net.pathfinder_settings.cache_size
256
Source code in src/groundinsight/pathfinder.py
def get_pathfinder_cache_size() -> int:
    """Return the process-wide default size of the path-search memo (deprecated).

    .. deprecated::
        Read ``network.pathfinder_settings.cache_size``.

    Returns
    -------
    int
        The default of networks without settings of their own.

    Warns
    -----
    DeprecationWarning
        Always.

    Examples
    --------
    The replacement reads the settings of one network:

    >>> import groundinsight as gi
    >>> net = gi.create_network(name="n", frequencies=[50.0])
    >>> net.pathfinder_settings.cache_size
    256
    """
    _deprecated_switch("get_pathfinder_cache_size", "network.pathfinder_settings.cache_size")
    return _process_defaults.cache_size

get_pathfinder_max_paths

get_pathfinder_max_paths() -> int

Return the process-wide default cap on enumerated paths (deprecated).

.. deprecated:: Read network.pathfinder_settings.max_paths.

Returns:

Type Description
int

The default of networks without settings of their own.

Warns:

Type Description
DeprecationWarning

Always.

Source code in src/groundinsight/pathfinder.py
def get_pathfinder_max_paths() -> int:
    """Return the process-wide default cap on enumerated paths (deprecated).

    .. deprecated::
        Read ``network.pathfinder_settings.max_paths``.

    Returns
    -------
    int
        The default of networks without settings of their own.

    Warns
    -----
    DeprecationWarning
        Always.
    """
    _deprecated_switch("get_pathfinder_max_paths", "network.pathfinder_settings.max_paths")
    return _process_defaults.max_paths

set_pathfinder_cache_size

set_pathfinder_cache_size(maxsize: int) -> int

Set the process-wide default size of the path-search memo (deprecated).

.. deprecated:: Use network.pathfinder_settings = PathfinderSettings(cache_size=...), which applies to that network only.

Parameters:

Name Type Description Default
maxsize int

Maximum number of entries per table of a network's memo. Must be a positive integer.

required

Returns:

Type Description
int

The previous default.

Raises:

Type Description
ValueError

If maxsize is not a positive integer.

Warns:

Type Description
DeprecationWarning

Always.

Notes

Changes :func:default_pathfinder_settings and trims the memo of every live network to its own effective size at once, so a smaller default is respected immediately by the networks that follow it.

Examples:

The replacement gives one network settings of its own:

>>> import groundinsight as gi
>>> net = gi.create_network(name="n", frequencies=[50.0])
>>> net.pathfinder_settings = gi.PathfinderSettings(cache_size=64)
>>> net.pathfinder_settings.cache_size
64
Source code in src/groundinsight/pathfinder.py
def set_pathfinder_cache_size(maxsize: int) -> int:
    """Set the process-wide default size of the path-search memo (deprecated).

    .. deprecated::
        Use ``network.pathfinder_settings =
        PathfinderSettings(cache_size=...)``, which applies to that network
        only.

    Parameters
    ----------
    maxsize : int
        Maximum number of entries per table of a network's memo. Must be a
        positive integer.

    Returns
    -------
    int
        The previous default.

    Raises
    ------
    ValueError
        If ``maxsize`` is not a positive integer.

    Warns
    -----
    DeprecationWarning
        Always.

    Notes
    -----
    Changes :func:`default_pathfinder_settings` and trims the memo of every
    live network to its own effective size at once, so a smaller default is
    respected immediately by the networks that follow it.

    Examples
    --------
    The replacement gives one network settings of its own:

    >>> import groundinsight as gi
    >>> net = gi.create_network(name="n", frequencies=[50.0])
    >>> net.pathfinder_settings = gi.PathfinderSettings(cache_size=64)
    >>> net.pathfinder_settings.cache_size
    64
    """
    global _process_defaults

    _deprecated_switch(
        "set_pathfinder_cache_size",
        "network.pathfinder_settings = gi.PathfinderSettings(cache_size=...)",
    )
    _positive_int(maxsize, "pathfinder cache size")
    with _process_defaults_lock:
        previous = _process_defaults.cache_size
        _process_defaults = _process_defaults.model_copy(update={"cache_size": maxsize})
    for cache in _live_caches():
        owner = cache.owner()
        if owner is not None:
            cache.trim(owner.pathfinder_settings.cache_size)
    return previous

set_pathfinder_max_paths

set_pathfinder_max_paths(maxcount: int) -> int

Set the process-wide default cap on enumerated simple paths (deprecated).

.. deprecated:: Use network.pathfinder_settings = PathfinderSettings(max_paths=...), which applies to that network only.

Parameters:

Name Type Description Default
maxcount int

Maximum number of simple paths per (source_bus, fault_bus) pair. Must be a positive integer.

required

Returns:

Type Description
int

The previous default.

Raises:

Type Description
ValueError

If maxcount is not a positive integer.

Warns:

Type Description
DeprecationWarning

Always.

Notes

Changes :func:default_pathfinder_settings, i.e. the limit of every network that has no :class:PathfinderSettings of its own.

Source code in src/groundinsight/pathfinder.py
def set_pathfinder_max_paths(maxcount: int) -> int:
    """Set the process-wide default cap on enumerated simple paths (deprecated).

    .. deprecated::
        Use ``network.pathfinder_settings =
        PathfinderSettings(max_paths=...)``, which applies to that network
        only.

    Parameters
    ----------
    maxcount : int
        Maximum number of simple paths per ``(source_bus, fault_bus)`` pair.
        Must be a positive integer.

    Returns
    -------
    int
        The previous default.

    Raises
    ------
    ValueError
        If ``maxcount`` is not a positive integer.

    Warns
    -----
    DeprecationWarning
        Always.

    Notes
    -----
    Changes :func:`default_pathfinder_settings`, i.e. the limit of every
    network that has no :class:`PathfinderSettings` of its own.
    """
    global _process_defaults

    _deprecated_switch(
        "set_pathfinder_max_paths",
        "network.pathfinder_settings = gi.PathfinderSettings(max_paths=...)",
    )
    _positive_int(maxcount, "pathfinder max_paths")
    with _process_defaults_lock:
        previous = _process_defaults.max_paths
        _process_defaults = _process_defaults.model_copy(update={"max_paths": maxcount})
    return previous