From 9d1a0e50e69338207460ffe90d4988ff2eeb7ebf Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Fri, 20 Feb 2026 23:07:15 -0600 Subject: [PATCH] renames --- src/daglib/dag.py | 8 ++++---- src/daglib/set.py | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/daglib/dag.py b/src/daglib/dag.py index 6c97d5d..8cb7691 100644 --- a/src/daglib/dag.py +++ b/src/daglib/dag.py @@ -4,12 +4,12 @@ from collections import defaultdict from collections.abc import Iterable, Iterator, MutableMapping, MutableSet from typing import DefaultDict, Generic, Set, TypeVar -from .set import _AdjView +from .set import DAGSet T = TypeVar("T") -class DagAdj(Generic[T], MutableMapping[T, MutableSet[T]]): +class DAG(Generic[T], MutableMapping[T, MutableSet[T]]): """ DAG adjacency map: - g[u] -> mutable set-like view of successors of u @@ -28,10 +28,10 @@ class DagAdj(Generic[T], MutableMapping[T, MutableSet[T]]): def __getitem__(self, u: T) -> MutableSet[T]: # defaultdict semantics: touch key _ = self._succ[u] - return _AdjView(self, u) + return DAGSet(self, u) def __setitem__(self, u: T, vs: Iterable[T]) -> None: - view = _AdjView(self, u) + view = DAGSet(self, u) view.clear() view |= vs # uses our in-place operator diff --git a/src/daglib/set.py b/src/daglib/set.py index 1fc09b0..f7d44d6 100644 --- a/src/daglib/set.py +++ b/src/daglib/set.py @@ -4,15 +4,15 @@ from collections.abc import Iterable, Iterator, MutableSet, Set from typing import TYPE_CHECKING, TypeVar if TYPE_CHECKING: - from .dag import DagAdj + from .dag import DAG T = TypeVar("T") -class _AdjView(MutableSet[T]): +class DAGSet(MutableSet[T]): """ - A mutable set-like view onto DagAdj._succ[u], with reverse-index maintenance. + A mutable set-like view onto DAG._succ[u], with reverse-index maintenance. Supports all set update operators: - |= (union_update) @@ -24,7 +24,7 @@ class _AdjView(MutableSet[T]): __slots__ = ("_g", "_u") - def __init__(self, g: DagAdj[T], u: T) -> None: + def __init__(self, g: DAG[T], u: T) -> None: self._g = g self._u = u @@ -63,12 +63,12 @@ class _AdjView(MutableSet[T]): # --- in-place operator support --- - def __ior__(self, other: Iterable[T]) -> _AdjView[T]: + def __ior__(self, other: Iterable[T]) -> DAGSet[T]: # a |= b => add everything in other self.update(other) return self - def __iand__(self, other: Iterable[T]) -> _AdjView[T]: + def __iand__(self, other: Iterable[T]) -> DAGSet[T]: # a &= b => keep only those also in other other_set = set(other) for v in list(self._raw()): @@ -76,13 +76,13 @@ class _AdjView(MutableSet[T]): self._g.remove_edge(self._u, v, missing_ok=True) return self - def __isub__(self, other: Iterable[T]) -> _AdjView[T]: + def __isub__(self, other: Iterable[T]) -> DAGSet[T]: # a -= b => remove those in other for v in other: self._g.remove_edge(self._u, v, missing_ok=True) return self - def __ixor__(self, other: Iterable[T]) -> _AdjView[T]: + def __ixor__(self, other: Iterable[T]) -> DAGSet[T]: # a ^= b => symmetric difference update other_set = set(other) raw = self._raw() @@ -95,7 +95,7 @@ class _AdjView(MutableSet[T]): self._g.add_edge(self._u, v) return self - def __iadd__(self, other: Iterable[T]) -> _AdjView[T]: + def __iadd__(self, other: Iterable[T]) -> DAGSet[T]: """ Built-in set doesn't define +=, but many folks expect it. Treat it as 'update' (extend).