from_dt_notation#
- from_dt_notation(notation, oriented=False)#
Parse DT notation (knot or link) and return a diagram.
This currently parses and validates the input but does not finish the DT→diagram construction (the original code also stopped mid-way). For now, non-empty inputs raise a clear
NotImplementedError
instead of silently printing and returningNone
.- Accepts:
A string with rows separated by commas/semicolons/spaces (e.g.
"4 -6 2"
or"4 -6 2 ; 8 -10 12"
)A list of ints (knot) → will be wrapped as a single-component link
A list of lists of ints (link)
- Parameters:
notation (str | Iterable[int] | Iterable[Iterable[int]]) – DT notation (string or nested iterables of ints).
oriented (bool) – If
True
, returns an oriented diagram instance; ifFalse
, an unoriented one.
- Returns:
PlanarDiagram | OrientedPlanarDiagram – Empty diagram if input is empty.
- Raises:
ValueError – If parsing fails.
NotImplementedError – For non-empty inputs until the constructor is completed.
Notes
The unfinished part in the original code explored endpoint placement options but never built the final diagram. This version preserves behavior safely by raising a clear exception.