ManimCommunity/manim

Add tuple key support in `GenericGraph.__getitem__()`

Open

#3.798 geöffnet am 9. Juni 2024

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (1.378 Forks)batch import
good first issuenew feature

Repository-Metriken

Stars
 (17.820 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 11T 17h) (4 gemergte PRs in 30 T)

Beschreibung

Description of proposed feature

vertices = [1, 2, 3, 4]
edges = [(1, 2), (2, 3), (3, 4), (1, 3), (1, 4)]
g = Graph(vertices, edges)
assert isinstance(g[1], Dot)  # This is OK
assert isinstance(g[(1, 2)], Line)  # But this will raise a KeyError

imo This is confusing. Why not add a support for edge mapping?

How can the new feature be used?

Every time people want to get or set a edge, just write g[(1, 2)] instead of g.edges[(1, 2)].

Contributor Guide