-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Verweijen
committed
Jan 13, 2025
1 parent
ba4a6f9
commit 37baf23
Showing
8 changed files
with
143 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Hierarchies # | ||
|
||
For explanatory variables, it is recommended to supply a hierarchy. | ||
There are 3 kinds of hierarchy supported by PiArgus. | ||
|
||
## FlatHierarchy ## | ||
|
||
This is the default if no hierarchy is supplied. | ||
All labels are of the same level with a single total. | ||
|
||
```python | ||
import piargus as pa | ||
|
||
datacol = ["A", "B", "C", "B", "A"] | ||
hierarchy = pa.FlatHierarchy(total_code="Total") | ||
``` | ||
|
||
```{mermaid} | ||
graph LR; | ||
Total --> A; | ||
Total --> B; | ||
Total --> C; | ||
``` | ||
|
||
## LevelHierarchy ## | ||
|
||
A level hierarchy is useful when the hierarchy is encoded within the code itself. | ||
|
||
```python | ||
import piargus as pa | ||
|
||
datacol = ["11123", "11234", "23456"] | ||
hierarchy = pa.LevelHierarchy(levels=[2, 3], total_code="Total") | ||
``` | ||
|
||
```{mermaid} | ||
graph LR; | ||
Total --> 11; | ||
Total --> 23; | ||
11 --> 123; | ||
11 --> 234; | ||
23 --> 456; | ||
``` | ||
|
||
## TreeHierarchy ## | ||
|
||
For complex hierarchies, a TreeHierarchy can be used. | ||
These are typically stored in a hrc-file. | ||
|
||
```python | ||
import piargus as pa | ||
|
||
datacol = ["PV20", "PV21", "PV22"] | ||
hierarchy = pa.TreeHierarchy.from_hrc("provinces.hrc", total_code="NL01") | ||
``` | ||
|
||
```{mermaid} | ||
graph LR; | ||
NL01 --> LD01; | ||
NL01 --> LD02; | ||
LD01 --> PV20; | ||
LD01 --> PV21; | ||
LD02 --> PV22; | ||
``` | ||
|
||
The file provinces.hrc may look like this: | ||
```hrc | ||
LD01 | ||
@PV20 | ||
@PV21 | ||
LD02 | ||
@PV22 | ||
``` | ||
|
||
It can also be created programmatically: | ||
```python | ||
import piargus as pa | ||
|
||
hierarchy = pa.TreeHierarchy(total_code="NL01") | ||
hierarchy.create_node(["NL01", "LD01", "PV20"]) | ||
hierarchy.create_node(["NL01", "LD01", "PV21"]) | ||
hierarchy.create_node(["NL01", "LD02", "PV22"]) | ||
hierarchy.to_hrc('provinces.hrc') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
User guide | ||
---------- | ||
|
||
.. toctree:: | ||
Check warning on line 4 in docs/source/userguide.rst GitHub Actions / build
|
||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
installation | ||
tutorial | ||
hierarchies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters