Vault tree (vaultkg.scene)¶
vaultkg.scene
¶
scene.py -- a vault grown as a 3-D tree, for the viewer and for quilts.
The grammar: the vault is the trunk, its folders are limbs (subfolders branch off their parent folder's limb), and every note is a leaf clustered at the tip of the folder that holds it. Notes at the vault root ring the base of the trunk. The folder tree is structure the author built, so the canopy's shape is the vault's own shape, and the same vault always grows the same tree.
A vault with no folders has nothing to branch on, so group_by="auto"
grows it from nested tags instead (#ml/retrieval is the limb
ml -> retrieval), with untagged notes at the base.
Split the way genealogy_kg's scene.py is, so placement is testable with
NumPy alone:
- :func:
vault_tree_positionsis pure NumPy: where each limb tip and each note goes. No PyVista import. - :func:
build_vault_tree_scenegrows wood toward those points with the fleet's shared space-colonization engine (kg_utils.viz3d) and composes it into a caller'spv.Plotter. That half needs theviz3dextra.
Colours come from :mod:vaultkg.theme, never from :mod:vaultkg.viz, so this
module imports with the viz3d extra alone.
VaultTree(positions, points, legend, title, counts=dict())
dataclass
¶
What a composed vault-tree scene contains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
VaultTreePositions
|
The placement it was grown from. |
required |
points
|
ndarray
|
Every drawn point, for camera framing with
:func: |
required |
legend
|
dict[str, str]
|
Label to hex colour, for the CLI and window title. |
required |
title
|
str
|
One-line summary. |
required |
counts
|
dict[str, int]
|
|
dict()
|
VaultTreePositions(note_positions, limb_tips, limb_parent, note_group, trunk_guides, trunk_height, group_by, size_scale=1.0)
dataclass
¶
Pure-geometry result of :func:vault_tree_positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note_positions
|
dict[str, ndarray]
|
Each note id's leaf position. |
required |
limb_tips
|
dict[str, ndarray]
|
Each group path's limb tip ( |
required |
limb_parent
|
dict[str, str]
|
Each group path's parent group ( |
required |
note_group
|
dict[str, str]
|
Each note's group path; |
required |
trunk_guides
|
ndarray
|
Growth targets up the trunk, never drawn. |
required |
trunk_height
|
float
|
Trunk height used, in world units. |
required |
group_by
|
str
|
|
required |
size_scale
|
float
|
Geometry multiplier for twig and leaf radii. |
1.0
|
build_vault_tree_scene(kg, plotter, *, group_by='auto', color_by='group', size_by='links', tip_radius=0.06, leaf_size=0.35, organic=True)
¶
Grow the vault into plotter as one tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kg
|
VaultKG
|
An open vault graph. |
required |
plotter
|
Plotter
|
PyVista plotter to compose into; its actors are cleared. |
required |
group_by
|
str
|
|
'auto'
|
color_by
|
str
|
|
'group'
|
size_by
|
str
|
|
'links'
|
tip_radius
|
float
|
Twig radius (organic) or trunk radius base (schematic). |
0.06
|
leaf_size
|
float
|
Leaf glyph radius before size scaling. |
0.35
|
organic
|
bool
|
|
True
|
Returns:
| Type | Description |
|---|---|
VaultTree
|
The composed :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the vault has no notes, or an option is unknown. |
Source code in src/vaultkg/scene.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
leaf_colors(kg, note_ids, positions, *, color_by)
¶
Per-leaf palette codes, the palette, and a legend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kg
|
VaultKG
|
An open vault graph. |
required |
note_ids
|
list[str]
|
Leaf order; matches the positions array. |
required |
positions
|
VaultTreePositions
|
The placement, for each note's group. |
required |
color_by
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, list[str], dict[str, str]]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
On an unknown |
Source code in src/vaultkg/scene.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
leaf_scales(kg, note_ids, *, size_by)
¶
Per-leaf size multipliers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kg
|
VaultKG
|
An open vault graph. |
required |
note_ids
|
list[str]
|
Leaf order; matches the positions array. |
required |
size_by
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
On an unknown |
Source code in src/vaultkg/scene.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
vault_tree_positions(notes, *, group_by='auto')
¶
Place every limb tip and every note.
Each group path and all its ancestors become limbs. Top-level limbs are spread by the golden angle, largest (most notes beneath) first; subfolders fan out around their parent's direction and reach further and higher. Limb reach grows with the square root of the notes beneath it, so the biggest folder is the longest limb. Notes cluster at their own group's tip, in path order, facing out and up.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notes
|
list[dict[str, Any]]
|
Note nodes ( |
required |
group_by
|
str
|
|
'auto'
|
Returns:
| Type | Description |
|---|---|
VaultTreePositions
|
Positions for the whole tree. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there are no notes, or |
Source code in src/vaultkg/scene.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |