Qubed
import qubed
from qubed import Qube
Qubed provides a data-structure primitive for working with trees of data-cubes by representing them in a compressed form:
q = qubed.examples.basic()
q
root
├── class=od, expver=1/2, param=1/2└── class=rd
├── expver=1, param=1/2/3 └── expver=2, param=1/2
This qube represents three data-cubes with shapes (1,2,2), (1,1,3) and (1,1,2) for a total of 9 leaves. So fully expanded it would look like this:
q.expand().display(depth=3)
root
├── class=od
│ ├── expver=1
│ │ ├── param=1│ │ └── param=2│ └── expver=2
│ ├── param=1│ └── param=2└── class=rd
├── expver=1
│ ├── param=1 │ ├── param=2 │ └── param=3└── expver=2
├── param=1 └── param=2
The goal of qubed is to never need to work with the expanded form, so qubed defines various useful operations that work directly on the compressed form, and keep it compressed. These include set operations, compression, search, transformation and filtering. The set operations include unions, intersections, subtractions and any other combination of the Venn diagram you want!
r = (Qube.from_tree("root, class=xd, expver=0001/0002, param=1/2")
.convert_dtypes({"expver" : int}))
q | r # Does a union between q and r
root
├── class=od, expver=1/2, param=1/2└── class=xd, expver=1/2, param=1/2├── class=rd
│ ├── expver=1, param=1/2/3│ └── expver=2, param=1/2
To get a little more background on the motivation and structure of a Qube go to Background, for a more hands on intro, go to Quickstart.