diff --git a/CHANGELOG.md b/CHANGELOG.md index e56876c..bf08ee2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ The package version runs on its own semver; the schema it is generated from is `SCHEMA_DIST_TAG`. +## 0.130.1 (2026-11-16) + +- **`layout_by_links_3d` no longer raises on a Map whose width or height is under 0.** A Map's `width` and `height` are any whole number in the standard. One under 0 raised a `PlateError` from inside the method when that Map held the most pinned elements, and with both under 0 the Map became a plate with every place mirrored. A width or height that is not over 0 is now no size: such a Map is no plate, no other Map is tried in its stead, and the world is laid out by its links alone; a Map over a place with such a size is no small plate. The method's shared fixture gains four cases for it (64), the same bytes as the npm SDK's copy. +- **Held points cost what they move.** The force steps worked out the push between every two fixed elements, 300 times, though neither can move and the push was never read. They no longer do; no number of any answer changes. +- The `held` list's comment says what False means: a pinned element stands at its Pin and is never answered as held, so what is new is every id that was not handed in. + ## 0.130.0 (2026-11-16) - **`layout_by_links_3d`: a 3D layout of a whole graph by its links (`by-links-3d`).** Given the graph as `world_graph` answers it and, optionally, the world's elements as served, it answers a point `[x, y, z]` for every node, in the order handed in (one flat `points` list), and how each was placed: a group's centre, with a centre, hanging off the body, on the shelf, or at its Pin. The body of the graph is cut into groups round its centres, the groups are packed apart in directions read from a table baked into the package, and 300 seeded force steps settle it; what hangs off the body is fanned out from it, and what is not joined to the main piece stands on a shelf under the picture. When a Map holds three or more of the graph's elements by a Pin, the Map that holds the most is a flat plate with each of its elements at its Pin, and a Map over a place on it a small plate above that place; a Pin's z is not read, and a layout map is never the plate. Maps and Pins are read through `map_space` and `layout_of`, nothing else. The same input gives the same points as the npm SDK's `layoutByLinks3d`: to the last bit for elements placed at a centre, with a centre or at a Pin, within a billionth of a rest (the unit `BY_LINKS_3D_REST`, 60) for the rest, which are placed with the runtime's cosine and sine. Two keyword options: `held`, points an earlier answer gave (element id to three finite numbers), so the picture keeps still as the world changes, and `held_unit`, the step those points were rounded to. A bad `held` or `held_unit` is refused before anything runs, each error with a `code` (`held-not-object`, `held-not-point`, `held-box`, `held-unit`). It is pure Python, so a world of several thousand elements takes minutes. The word `by-links-3d` is the tool's own until the method's page is published, and until then a release may move its points. diff --git a/src/onlyworlds/_layout3d/plate.py b/src/onlyworlds/_layout3d/plate.py index c84a4d0..e8e6616 100644 --- a/src/onlyworlds/_layout3d/plate.py +++ b/src/onlyworlds/_layout3d/plate.py @@ -19,7 +19,8 @@ A row's key that is absent is read as UNDEF, which is not None. Map and element ids are held as keys by jkey(), so True and 1 are two keys and 1 and 1.0 one (as the npm SDK's Map holds them). A width or height that is not a number, -or a negative area, raises PlateError. A division by a zero root is infinite (js_div()). +raises PlateError. A width or height that is not over 0 is no size: such a first map gives no plate, such a small +map is not taken, so a negative area is never reached. A division by a zero root is infinite (js_div()). """ from __future__ import annotations @@ -85,6 +86,15 @@ def key(v: Any, what: str) -> tuple[Any, ...]: return jkey(v, what) +def sized(v: Any) -> bool: + """a size: truthy and, when a number, over 0 (a Map's width is any whole number; NaN is no size)""" + if not truthy(v): + return False + if is_num(v): + return bool(v > 0) + return True + + def truthy(v: Any) -> bool: """the truth of a JSON value: UNDEF, None, False, 0, "", an empty list or object are false; NaN is true""" if v is UNDEF or v is None or v is False: @@ -214,7 +224,7 @@ def plate(rows: Sequence[Any], nodes: Sequence[Any], scale: Any = UNDEF) -> dict mp = maps[mk] W, H = get(mp, "width"), get(mp, "height") count = len(at[mk][1]) - if count < 3 or not truthy(W) or not truthy(H): + if count < 3 or not sized(W) or not sized(H): return None # 4. the scale and the first map's places @@ -253,7 +263,7 @@ def plate(rows: Sequence[Any], nodes: Sequence[Any], scale: Any = UNDEF) -> dict for ek, (el, xy) in mine.items(): if ek not in out: fresh.append((ek, el, xy)) - if key(loc, "a map's location") in out and truthy(cw) and truthy(ch) and len(mine) >= 3 and len(fresh): + if key(loc, "a map's location") in out and sized(cw) and sized(ch) and len(mine) >= 3 and len(fresh): sc = js_div(TILE * REST, root(cw, ch, len(mine), f"the map {c}")) lx, ly, lz = out[jkey(loc)][1] rise = REST * (4 if len(mine) >= 20 else 2) diff --git a/src/onlyworlds/_layout3d/relax.py b/src/onlyworlds/_layout3d/relax.py index 56fccd5..5012635 100644 --- a/src/onlyworlds/_layout3d/relax.py +++ b/src/onlyworlds/_layout3d/relax.py @@ -13,6 +13,7 @@ 3. the move: each element's push, plus its links' pull times its scale (1 over the larger of 1 and a quarter of its links' summed weight), plus (anchor - point) * pull, moves it by at most the cap, cap0 * R * (1 - step / steps) + R / 20; a fixed element stands at its anchor. +The push between two fixed elements is never read and is not worked out, which moves no number. Every sum runs in the order written and every expression keeps its grouping. A distance under 1e-6 is read as 1e-6 and a move's length under 1e-9 as 1e-9; a NaN goes through as it is (no max() or min()). """ @@ -78,7 +79,13 @@ def relax(feed: dict[str, Any], cutoff: float = 3, cap0: float = 3) -> dict[str, R3 = R / 3 OFFS = _offsets() - for step in range(STEPS): + # Two fixed elements push each other and neither moves, so that push is never read: it is not worked out (a + # cell pair with no free element is passed over whole, and so is a pair of two fixed elements). The pushes on a + # free element are still summed in the same order, so no number of the answer changes. With no free element at + # all one step does what every step would: each element at its anchor. + free = n - sum(fixed) + run = min(STEPS, 1) if free == 0 else STEPS + for step in range(run): x0 = y0 = z0 = math.inf x1 = y1 = z1 = -math.inf for i in range(n): @@ -115,6 +122,10 @@ def relax(feed: dict[str, Any], cutoff: float = 3, cap0: float = 3) -> dict[str, c = cellOf[i] order[fill[c]] = i fill[c] += 1 + freeIn = [0] * cells + for i in range(n): + if not fixed[i]: + freeIn[cellOf[i]] += 1 for i in range(n): dx[i] = 0.0 @@ -140,6 +151,8 @@ def relax(feed: dict[str, Any], cutoff: float = 3, cap0: float = 3) -> dict[str, t1 = startOf[q + 1] if t0 == t1: continue + if freeIn[c] == 0 and freeIn[q] == 0: + continue for u in range(s0, s1): i = order[u] xi = px[i] @@ -147,6 +160,8 @@ def relax(feed: dict[str, Any], cutoff: float = 3, cap0: float = 3) -> dict[str, zi = pz[i] for w in range(u + 1 if same else t0, t1): j = order[w] + if fixed[i] and fixed[j]: + continue ux = xi - px[j] uy = yi - py[j] uz = zi - pz[j] diff --git a/src/onlyworlds/_version.py b/src/onlyworlds/_version.py index 99eab24..5dca202 100644 --- a/src/onlyworlds/_version.py +++ b/src/onlyworlds/_version.py @@ -1 +1 @@ -__version__ = "0.130.0" +__version__ = "0.130.1" diff --git a/src/onlyworlds/layout_links_3d.py b/src/onlyworlds/layout_links_3d.py index c478633..5189aa2 100644 --- a/src/onlyworlds/layout_links_3d.py +++ b/src/onlyworlds/layout_links_3d.py @@ -45,7 +45,9 @@ class LayoutByLinks3d(TypedDict): part: list[Literal["map", "one-link", "no-link"] | None] #: The centres' ids, in rank order. centres: list[str] - #: True where the point answered is the element's held point; False everywhere when nothing is held. + #: True where the point answered is the element's held point; False everywhere when nothing is held. A pinned + #: element stands at its Pin and is never held, so False does not mean new: what is new is every id that was not + #: handed in. held: list[bool] @@ -65,9 +67,10 @@ def layout_by_links_3d( body by one element is fanned out from it, and what is not joined to the main piece stands on a shelf under the picture. When the world has a Map that holds three or more elements of the graph by a Pin, the Map that holds the most (a tie to the greater id) is a flat plate, each of its pinned elements at its Pin, the groups whose centre is - pinned standing over it; a Map over a place on that plate is a small plate a little above it. A Pin's z is not - read: the plate is flat. A layout map (a Map whose ``x_layout`` names a method, the map-space profile's mark) is - never the plate: a saved layout never stands in for the world's own space. + pinned standing over it; a Map over a place on that plate is a small plate a little above it. A Map whose width + or height is not over 0 is no plate, and when it is the Map that holds the most, the world is laid out by its + links alone. A Pin's z is not read: the plate is flat. A layout map (a Map whose ``x_layout`` names a method, + the map-space profile's mark) is never the plate: a saved layout never stands in for the world's own space. ``graph`` is ``world_graph``'s answer, or any mapping of the same shape: ``nodes`` (each with ``id`` and ``type``) and ``edges`` (each with ``source`` and ``target``, and ``field`` and ``index`` where it has them), the diff --git a/tests/fixtures/layout/by-links-3d.fixture.json b/tests/fixtures/layout/by-links-3d.fixture.json index 2dd796c..82b52bd 100644 --- a/tests/fixtures/layout/by-links-3d.fixture.json +++ b/tests/fixtures/layout/by-links-3d.fixture.json @@ -26,6 +26,10 @@ {"name":"a Pin with one link key","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":100,"height":100},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_id":"b8","x":40,"y":90}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[103.13504981673296,-43.99117271621754,-346.3981949679349,-7.175991847177464,7.59435419516862,-346.3981949679349,114.84644680245012,41.71770842328562,-346.3981949679349,57.312042860041416,-137.16379092977684,-346.3981949679349,-70.8131683232369,122.91031972920375,326.7189934722685,251.57781198474657,-215.7248329450778,288.5299110453601,194.60721408934887,-185.15685879597083,306.417055363569,1.0755067654496808,-15.926286767633117,51.67439926439769,28.73229311972016,-26.321134117877236,133.24213476076136,120.87891751177372,-115.96760419487009,-166.3981949679349,-25.517476770473174,52.0311283318875,196.84695129658414,58.52508843929412,-32.829165431563965,-166.3981949679349,72.50548335963926,-51.67038042271536,274.5864687742903,-3.8287406331854683,-95.18299450404355,-166.3981949679349,-87.25738155901429,79.93490924026771,33.15606020717357],"how":["shelf","shelf","shelf","shelf","link","arm","arm","with","centre","map","with","map","with","map","centre"],"group":[null,null,null,null,null,null,null,"b7","b7",null,"b4","b4","b4",null,"b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link",null,null,"map",null,null,null,"map",null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, {"name":"Pins that are no point","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":100,"height":100},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40.5,"y":90},{"id":"p05","type":"pin","map":"m1","element_type":"location","element_id":"b3","x":true,"y":70}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[103.13504981673296,-43.99117271621754,-346.3981949679349,-7.175991847177464,7.59435419516862,-346.3981949679349,114.84644680245012,41.71770842328562,-346.3981949679349,57.312042860041416,-137.16379092977684,-346.3981949679349,-70.8131683232369,122.91031972920375,326.7189934722685,251.57781198474657,-215.7248329450778,288.5299110453601,194.60721408934887,-185.15685879597083,306.417055363569,1.0755067654496808,-15.926286767633117,51.67439926439769,28.73229311972016,-26.321134117877236,133.24213476076136,120.87891751177372,-115.96760419487009,-166.3981949679349,-25.517476770473174,52.0311283318875,196.84695129658414,58.52508843929412,-32.829165431563965,-166.3981949679349,72.50548335963926,-51.67038042271536,274.5864687742903,-3.8287406331854683,-95.18299450404355,-166.3981949679349,-87.25738155901429,79.93490924026771,33.15606020717357],"how":["shelf","shelf","shelf","shelf","link","arm","arm","with","centre","map","with","map","with","map","centre"],"group":[null,null,null,null,null,null,null,"b7","b7",null,"b4","b4","b4",null,"b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link",null,null,"map",null,null,null,"map",null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, {"name":"a Map with no width or height","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1"},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40,"y":90}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[-66.49309146712031,129.37460383358905,-263.1230343671361,-176.80413313103074,180.9601307449752,-263.1230343671361,-54.78169448140315,215.0834849730922,-263.1230343671361,-112.31609842381185,36.201985620029745,-263.1230343671361,44.996449034209235,-3.441652836419536,434.1273461443579,-363.4938133704705,283.87226676574005,185.0804486569669,-331.9054921531681,293.48534229388224,243.4736566657992,-183.6109579469753,295.4818986767949,-0.320240745284204,91.88445672516173,-84.17368912164379,-83.1230343671361,-70.47387295712771,97.49199994456161,-0.320240745284204,-48.40527898171669,82.70814819641856,272.38296144236494,-155.3266866995134,210.6290849344092,-0.320240745284204,-160.63581056863723,205.31996106528538,406.4683998387009,-240.1795004418991,125.7762711920235,-0.320240745284204,91.72650122181356,-84.02898894157254,83.4432751124203],"how":["shelf","shelf","shelf","shelf","link","arm","arm","map","centre","map","with","map","with","map","centre"],"group":[null,null,null,null,null,null,null,null,"b7",null,"b4","b4","b4",null,"b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link","map",null,"map",null,null,null,"map",null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, +{"name":"a first Map with a width of 0","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":0,"height":100},{"id":"m2","type":"map","name":"m2","width":100,"height":100},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40,"y":90},{"id":"p05","type":"pin","map":"m2","element_type":"location","element_id":"b3","x":10,"y":70},{"id":"p06","type":"pin","map":"m2","element_type":"institution","element_id":"b5","x":60,"y":10},{"id":"p07","type":"pin","map":"m2","element_type":"location","element_id":"b7","x":90,"y":50}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[84.40198472905804,4.283808977263129,-310.7191262561572,-25.90905693485238,55.86933588864929,-310.7191262561572,96.1133817147752,89.9926901167663,-310.7191262561572,38.5789777723665,-88.88880923629617,-310.7191262561572,-106.17788138365609,-126.38604999881686,138.07981557860447,188.3951282137921,84.18268908138815,263.95912950511695,151.83933451370774,33.26506077030564,240.06207792691336,-43.08125578587824,6.833411417025399,-130.71912625615718,38.52640162843316,-35.29333980117323,-122.92929969078678,38.02821784038996,-3.499757855374204,-37.092899627567185,-28.995012069898106,-45.83684375966108,68.52078458366483,42.88354548611926,-39.28484049243998,126.94701828570845,94.03772045449811,28.860361253265857,138.30425348142552,40.37558023668299,69.70302784176151,72.99912606651363,-81.4099471145524,74.5781802936132,-4.017718594921658],"how":["shelf","shelf","shelf","shelf","link","arm","arm","with","centre","with","with","centre","with","with","centre"],"group":[null,null,null,null,null,null,null,"b7","b7","b7","b4","b4","b4","b4","b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link",null,null,null,null,null,null,null,null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, +{"name":"a first Map with a width under 0","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":-100,"height":100},{"id":"m2","type":"map","name":"m2","width":100,"height":100},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40,"y":90},{"id":"p05","type":"pin","map":"m2","element_type":"location","element_id":"b3","x":10,"y":70},{"id":"p06","type":"pin","map":"m2","element_type":"institution","element_id":"b5","x":60,"y":10},{"id":"p07","type":"pin","map":"m2","element_type":"location","element_id":"b7","x":90,"y":50}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[84.40198472905804,4.283808977263129,-310.7191262561572,-25.90905693485238,55.86933588864929,-310.7191262561572,96.1133817147752,89.9926901167663,-310.7191262561572,38.5789777723665,-88.88880923629617,-310.7191262561572,-106.17788138365609,-126.38604999881686,138.07981557860447,188.3951282137921,84.18268908138815,263.95912950511695,151.83933451370774,33.26506077030564,240.06207792691336,-43.08125578587824,6.833411417025399,-130.71912625615718,38.52640162843316,-35.29333980117323,-122.92929969078678,38.02821784038996,-3.499757855374204,-37.092899627567185,-28.995012069898106,-45.83684375966108,68.52078458366483,42.88354548611926,-39.28484049243998,126.94701828570845,94.03772045449811,28.860361253265857,138.30425348142552,40.37558023668299,69.70302784176151,72.99912606651363,-81.4099471145524,74.5781802936132,-4.017718594921658],"how":["shelf","shelf","shelf","shelf","link","arm","arm","with","centre","with","with","centre","with","with","centre"],"group":[null,null,null,null,null,null,null,"b7","b7","b7","b4","b4","b4","b4","b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link",null,null,null,null,null,null,null,null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, +{"name":"a first Map with a width and a height under 0","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":-100,"height":-100},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40,"y":90}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[84.40198472905804,4.283808977263129,-310.7191262561572,-25.90905693485238,55.86933588864929,-310.7191262561572,96.1133817147752,89.9926901167663,-310.7191262561572,38.5789777723665,-88.88880923629617,-310.7191262561572,-106.17788138365609,-126.38604999881686,138.07981557860447,188.3951282137921,84.18268908138815,263.95912950511695,151.83933451370774,33.26506077030564,240.06207792691336,-43.08125578587824,6.833411417025399,-130.71912625615718,38.52640162843316,-35.29333980117323,-122.92929969078678,38.02821784038996,-3.499757855374204,-37.092899627567185,-28.995012069898106,-45.83684375966108,68.52078458366483,42.88354548611926,-39.28484049243998,126.94701828570845,94.03772045449811,28.860361253265857,138.30425348142552,40.37558023668299,69.70302784176151,72.99912606651363,-81.4099471145524,74.5781802936132,-4.017718594921658],"how":["shelf","shelf","shelf","shelf","link","arm","arm","with","centre","with","with","centre","with","with","centre"],"group":[null,null,null,null,null,null,null,"b7","b7","b7","b4","b4","b4","b4","b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link",null,null,null,null,null,null,null,null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, +{"name":"a small Map with a width and a height under 0","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":100,"height":100},{"id":"m2","type":"map","name":"m2","width":-60,"height":-40,"location":"b4"},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40,"y":90},{"id":"p05","type":"pin","map":"m2","element_type":"object","element_id":"r1","x":10,"y":10},{"id":"p06","type":"pin","map":"m2","element_type":"object","element_id":"r2","x":30,"y":20},{"id":"p07","type":"pin","map":"m2","element_type":"character","element_id":"f1","x":50,"y":30}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[-60.8972518559337,93.63010718191268,-262.9303589667737,-171.20829351984412,145.21563409329883,-262.9303589667737,-49.185854870216545,179.33898832141585,-262.9303589667737,-106.72025881262525,0.45748896835337405,-262.9303589667737,49.475225262597434,-23.271803042751117,401.4431621046532,-334.47771537071793,209.0702383781558,188.07837672675998,-306.5976929794278,221.8625962694665,247.7362339715671,-171.62183122021491,231.23368991412252,-0.432955695464357,73.94350482762282,-67.73830754141763,-82.93035896677371,-75.62183122021491,63.23368991412252,-0.432955695464357,-53.2843179619074,61.83333222463368,274.3728659763609,-147.62183122021491,159.23368991412252,-0.432955695464357,-152.11977570517035,154.73574542916708,406.397595945696,-219.62183122021491,87.23368991412252,-0.432955695464357,73.67832639259214,-67.4953823727049,83.36331466223805],"how":["shelf","shelf","shelf","shelf","link","arm","arm","map","centre","map","with","map","with","map","centre"],"group":[null,null,null,null,null,null,null,null,"b7",null,"b4","b4","b4",null,"b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link","map",null,"map",null,null,null,"map",null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, {"name":"two Pin rows with one id","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":100,"height":100},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40,"y":90},{"id":"p01","type":"pin","map":"m1","element_type":"location","element_id":"b3","x":70,"y":70}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[-16.01273341867332,79.06729335008664,-262.9303589667737,-126.32377508258375,130.6528202614728,-262.9303589667737,-4.3013364329561625,164.7761744895898,-262.9303589667737,-61.835740375364864,-14.10532486347266,-262.9303589667737,-108.67175756212026,-132.5094330696217,399.48997000558967,-110.68236439138971,193.36604432804538,119.56704430453564,-99.62183122021491,183.23368991412252,59.56704430453564,-171.62183122021491,231.23368991412252,-0.432955695464357,73.94350482762282,-67.73830754141763,-82.93035896677371,-75.62183122021491,63.23368991412252,-0.432955695464357,-95.18430885685281,27.59372249407859,271.18305013772243,-147.62183122021491,159.23368991412252,-0.432955695464357,-99.62183122021491,183.23368991412252,-0.432955695464357,-9.114311914184253,96.35513344196072,276.63972923392964,73.67832639259214,-67.4953823727049,83.36331466223805],"how":["shelf","shelf","shelf","shelf","link","arm","arm","map","centre","map","with","map","map","with","centre"],"group":[null,null,null,null,null,null,null,null,"b7",null,"b4","b4",null,"b4","b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link","map",null,"map",null,null,"map",null,null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, {"name":"a Map whose location is no id","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":100,"height":100},{"id":"m2","type":"map","name":"m2","width":60,"height":40,"location":["b4"]},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40,"y":90},{"id":"p05","type":"pin","map":"m2","element_type":"object","element_id":"r1","x":10,"y":10},{"id":"p06","type":"pin","map":"m2","element_type":"object","element_id":"r2","x":30,"y":20},{"id":"p07","type":"pin","map":"m2","element_type":"character","element_id":"f1","x":50,"y":30}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[-60.8972518559337,93.63010718191268,-262.9303589667737,-171.20829351984412,145.21563409329883,-262.9303589667737,-49.185854870216545,179.33898832141585,-262.9303589667737,-106.72025881262525,0.45748896835337405,-262.9303589667737,49.475225262597434,-23.271803042751117,401.4431621046532,-334.47771537071793,209.0702383781558,188.07837672675998,-306.5976929794278,221.8625962694665,247.7362339715671,-171.62183122021491,231.23368991412252,-0.432955695464357,73.94350482762282,-67.73830754141763,-82.93035896677371,-75.62183122021491,63.23368991412252,-0.432955695464357,-53.2843179619074,61.83333222463368,274.3728659763609,-147.62183122021491,159.23368991412252,-0.432955695464357,-152.11977570517035,154.73574542916708,406.397595945696,-219.62183122021491,87.23368991412252,-0.432955695464357,73.67832639259214,-67.4953823727049,83.36331466223805],"how":["shelf","shelf","shelf","shelf","link","arm","arm","map","centre","map","with","map","with","map","centre"],"group":[null,null,null,null,null,null,null,null,"b7",null,"b4","b4","b4",null,"b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link","map",null,"map",null,null,null,"map",null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, {"name":"a Map id served twice, the later row a layout map","input":{"nodes":[{"id":"s2","type":"character"},{"id":"s1","type":"object"},{"id":"q2","type":"species"},{"id":"q1","type":"species"},{"id":"f1","type":"character"},{"id":"r2","type":"object"},{"id":"r1","type":"object"},{"id":"b8","type":"character"},{"id":"b7","type":"location"},{"id":"b6","type":"character"},{"id":"b5","type":"institution"},{"id":"b4","type":"character"},{"id":"b3","type":"location"},{"id":"b2","type":"character"},{"id":"b1","type":"character"}],"edges":[{"source":"b1","target":"b2","field":"friends"},{"source":"b2","target":"b3","field":"friends"},{"source":"b3","target":"b4","field":"friends"},{"source":"b4","target":"b5","field":"friends"},{"source":"b5","target":"b6","field":"friends"},{"source":"b6","target":"b7","field":"friends"},{"source":"b7","target":"b8","field":"friends"},{"source":"b8","target":"b1","field":"friends"},{"source":"b1","target":"b4","field":"friends"},{"source":"b1","target":"b5","field":"friends"},{"source":"b1","target":"b6","field":"friends"},{"source":"b4","target":"b7","field":"friends"},{"source":"b2","target":"b6","field":"friends"},{"source":"b3","target":"r1","field":"friends"},{"source":"r1","target":"r2","field":"friends"},{"source":"b5","target":"f1","field":"friends"},{"source":"q1","target":"q2","field":"friends"}],"rows":[{"id":"m1","type":"map","name":"m1","width":100,"height":100},{"id":"p01","type":"pin","map":"m1","element_type":"character","element_id":"b2","x":20,"y":30},{"id":"p02","type":"pin","map":"m1","element_type":"character","element_id":"b4","x":50,"y":60},{"id":"p03","type":"pin","map":"m1","element_type":"character","element_id":"b6","x":80,"y":20},{"id":"p04","type":"pin","map":"m1","element_type":"character","element_id":"b8","x":40,"y":90},{"id":"m1","type":"map","name":"m1","width":100,"height":100,"x_layout":{"method":"by-kind"}}]},"steps":300,"want":{"ids":["s2","s1","q2","q1","f1","r2","r1","b8","b7","b6","b5","b4","b3","b2","b1"],"points":[84.40198472905804,4.283808977263129,-310.7191262561572,-25.90905693485238,55.86933588864929,-310.7191262561572,96.1133817147752,89.9926901167663,-310.7191262561572,38.5789777723665,-88.88880923629617,-310.7191262561572,-106.17788138365609,-126.38604999881686,138.07981557860447,188.3951282137921,84.18268908138815,263.95912950511695,151.83933451370774,33.26506077030564,240.06207792691336,-43.08125578587824,6.833411417025399,-130.71912625615718,38.52640162843316,-35.29333980117323,-122.92929969078678,38.02821784038996,-3.499757855374204,-37.092899627567185,-28.995012069898106,-45.83684375966108,68.52078458366483,42.88354548611926,-39.28484049243998,126.94701828570845,94.03772045449811,28.860361253265857,138.30425348142552,40.37558023668299,69.70302784176151,72.99912606651363,-81.4099471145524,74.5781802936132,-4.017718594921658],"how":["shelf","shelf","shelf","shelf","link","arm","arm","with","centre","with","with","centre","with","with","centre"],"group":[null,null,null,null,null,null,null,"b7","b7","b7","b4","b4","b4","b4","b1"],"part":["no-link","no-link","no-link","no-link","one-link","one-link","one-link",null,null,null,null,null,null,null,null],"centres":["b1","b4","b7"],"held":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}, diff --git a/tests/test_layout_links_3d.py b/tests/test_layout_links_3d.py index 6cdb3f4..ed39a04 100644 --- a/tests/test_layout_links_3d.py +++ b/tests/test_layout_links_3d.py @@ -30,7 +30,7 @@ REPO = Path(__file__).resolve().parent.parent FIXTURE = REPO / "tests" / "fixtures" / "layout" / "by-links-3d.fixture.json" TABLE = REPO / "codegen" / "layout" / "directions.json" -FIXTURE_SHA = "ae11c21d3c8faa285e59e288d40da8aafac19ac3cfe303bd8d90da3244c5babe" +FIXTURE_SHA = "16284adffac8903777e754cc01d547de95a61447b6d945ca2f641ddf93c4d4eb" BYTES = FIXTURE.read_bytes()