Power · power
---
config:
flowchart:
useMaxWidth: false
---
flowchart TB
classDef ok fill:#d4edda,stroke:#28a745,color:#000
classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
O["Power · power<br/>🟢5"]:::ok
subgraph G_ds["Dataset"]
direction LR
v_ds_sc["power(DS, sc)"]:::ok
end
subgraph G_comp["Component"]
direction LR
v_comp_sc["power(comp, sc)"]:::ok
v_comp_comp["power(comp, comp)"]:::ok
v_sc_comp["power(sc, comp)"]:::ok
end
subgraph G_sc["Scalar"]
direction LR
v_sc_sc["power(sc, sc)"]:::ok
end
O --- G_ds
O --- G_comp
O --- G_sc
style G_ds fill:#f8f9fa,stroke:#495057,stroke-width:2px
style G_comp fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 8 5
style G_sc fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 2 3
click v_ds_sc href "#form-ds-sc"
click v_comp_sc href "#form-comp-sc"
click v_comp_comp href "#form-comp-comp"
click v_sc_comp href "#form-sc-comp"
click v_sc_sc href "#form-sc-sc"
Types
Takes number · Gives number
Comes from · number — 44 operators in 6 blocks 🟢44
General purpose operators (2) 🟢2
String operators (3) 🟢3
Numeric operators (17) 🟢17
Time operators (9) 🟢9
Aggregate and Analytic operators (10) 🟢10
Data validation operators (3) 🟢3
Comes from · operators that return any type (their input's) — 37 operators in 8 blocks 🟢37
General purpose operators (5) 🟢5
Join operators (4) 🟢4
Time operators (3) 🟢3
Set operators (4) 🟢4
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Conditional operators (3) 🟢3
Goes to · number — 33 operators in 7 blocks 🟢33
General purpose operators (1) 🟢1
Numeric operators (17) 🟢17
Time operators (2) 🟢2
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Data validation operators (2) 🟢2
Definitions (VTL-DL) (2) 🟢2
Goes to · operators that take any scalar — 48 operators in 8 blocks 🟢48
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Comparison operators (11) 🟢11
Set operators (4) 🟢4
Aggregate and Analytic operators (10) 🟢10
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Forms
power(DS, sc) 🟢 · number → number
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
every measure of
DS_1raised to a scalar power.- Manual:
Power, Example 1, output verbatim: “The operator power raises a number (the base) to another one (the exponent).”
- Expected:
power(DS_1, 2):Me_1(3, 4, 5) gives 9.0, 16.0 and 25.0;Me_2(0.7545, 13.45, 1.87) gives 0.56927, 180.9025 and 3.4969.
DS_r := power(DS_1, 2);
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 3 | 0.7545 |
| 10 | B | 4 | 13.45 |
| 11 | A | 5 | 1.87 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 9.0 | 0.56927 |
| 10 | B | 16.0 | 180.9025 |
| 11 | A | 25.0 | 3.4969 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
power(comp, sc) 🟢 · number → number
Manual example 2 🟢 pandas ✅ · DuckDB ✅
- Tests:
poweron a component insidecalc, where the result replaces the measureMe_1.- Manual:
Power, Example 2, output verbatim: “The operator power raises a number (the base) to another one (the exponent).”
- Expected:
Me_1 = power(Me_1, 2)is 9.0, 16.0 and 25.0, a Number;Me_2is unchanged.
DS_r := DS_1[ calc Me_1 := power(Me_1, 2) ];
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 3 | 0.7545 |
| 10 | B | 4 | 13.45 |
| 11 | A | 5 | 1.87 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 9.0 | 0.7545 |
| 10 | B | 16.0 | 13.45 |
| 11 | A | 25.0 | 1.87 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
power(comp, comp) 🟢 · number → number
Negative and fractional exponents 🟢 pandas ✅ · DuckDB ✅
- Tests:
powerwith the exponent in a Number component, insidecalc.- Manual:
Power types
exponentascomponent<number> | number, and “power ( 5, -1 )gives0.2”.- Expected:
Me_3 = power(Me_1, Me_2):2^3.0 = 8.0,5^-1.0 = 0.2and4^0.5 = 2.0, a Number; the other components are kept.
DS_r := DS_1[calc Me_3 := power(Me_1, Me_2)];
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2 | 3.0 |
| 2 | 5 | -1.0 |
| 3 | 4 | 0.5 |
| Id_1 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|
| 1 | 2 | 3.000000 | 8.000000 |
| 2 | 5 | -1.000000 | 0.200000 |
| 3 | 4 | 0.500000 | 2.000000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
power(sc, comp) 🟢 · number → number
Integer exponents 🟢 pandas ✅ · DuckDB ✅
- Tests:
powerof a scalar base with the exponent in a component, insidecalc.- Manual:
Power types
exponentascomponent<number> | number, so it may be a component while the base is a scalar.- Expected:
Me_2 = power(2, Me_1):2^3 = 8,2^-1 = 0.5and2^10 = 1024, a Number although both operands are Integers; the other components are kept.
DS_r := DS_1[calc Me_2 := power(2, Me_1)];
| Id_1 | Me_1 |
|---|---|
| 1 | 3 |
| 2 | -1 |
| 3 | 10 |
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 3 | 8.000000 |
| 2 | -1 | 0.500000 |
| 3 | 10 | 1024.000000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
power(sc, sc) 🟢 · number → number
Integer operands 🟢 pandas ✅ · DuckDB ✅
- Tests:
powerof two integers:power(SC_1, SC_2)withSC_1= 5 andSC_2= 2.- Manual:
Power: “
power ( 5, 2 )gives25”, and “The result has type number.”- Expected:
SC_r = 25.0, a Number although both operands are Integers.
SC_r := power(SC_1, SC_2);
| SC_1 | SC_2 |
|---|---|
| 5 | 2 |
Name |
Type |
Value |
|---|---|---|
|
Number |
|
Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗