ManimCommunity/manim

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

Open

#3.798 aberto em 9 de jun. de 2024

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)Python (1.378 forks)batch import
good first issuenew feature

Métricas do repositório

Stars
 (17.820 stars)
Métricas de merge de PR
 (Mesclagem média 11d 17h) (4 fundiu PRs em 30d)

Description

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)].

Guia do colaborador