Logarithm · log
---
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["Logarithm · log<br/>🟢5"]:::ok
subgraph G_ds["Dataset"]
direction LR
v_ds_sc["log(DS, sc)"]:::ok
end
subgraph G_comp["Component"]
direction LR
v_comp_sc["log(comp, sc)"]:::ok
v_comp_comp["log(comp, comp)"]:::ok
v_sc_comp["log(sc, comp)"]:::ok
end
subgraph G_sc["Scalar"]
direction LR
v_sc_sc["log(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, integer · Gives number
Comes from · number, integer — 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
log(DS, sc) 🟢 · number, integer → number
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
the logarithm of every measure of
DS_1to base 2, the number being the first operand.- Manual:
Logarithm, Example 1, output verbatim. The parameter table calls
opthe base andnumthe number, but the page’s examples read the first operand as the number: “log ( 1024, 2 )gives10”.- Expected:
Me_11024, 64 and 32 give 10.0, 6.0 and 5.0, which agrees with the scalar example;Me_2has the page’s values, printed with all the digits of a double, such as -0.4064071941354039. The output follows the examples, so it is not an erratum.
DS_r := log ( DS_1, 2 );
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 1024 | 0.7545 |
| 10 | B | 64 | 13.45 |
| 11 | A | 32 | 1.87 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 10.0 | -0.4064071941354039 |
| 10 | B | 6.0 | 3.749534267669262 |
| 11 | A | 5.0 | 0.9030382701129122 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
log(comp, sc) 🟢 · number, integer → number
Manual example 2 🟢 pandas ✅ · DuckDB ✅
- Tests:
logof a component to base 2, insidecalc, where the result replaces the measureMe_1.- Manual:
Logarithm, Example 2, output verbatim. As in Example 1, the first operand is the number and the second the base: “
log ( 1024, 2 )gives10”, although the parameter table says the opposite.- Expected:
Me_1 = log(Me_1, 2)gives 10.0, 6.0 and 5.0 for 1024, 64 and 32;Me_2is unchanged.
DS_r := DS_1 [ calc Me_1 := log (Me_1, 2) ];
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 1024 | 0.7545 |
| 10 | B | 64 | 13.45 |
| 11 | A | 32 | 1.87 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 10.0 | 0.7545 |
| 10 | B | 6.0 | 13.45 |
| 11 | A | 5.0 | 1.87 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
log(comp, comp) 🟢 · number, integer → number
Number then base 🟢 pandas ✅ · DuckDB ✅
- Tests:
logwith the number and the base both in components, insidecalc.- Manual:
Logarithm: “
log ( 1024, 2 )gives10”, although the page’s table and its sentence “calculates the logarithm of num base op” put the base first.- Expected:
Me_3 = log(Me_1, Me_2), read as the page’s examples read it, the number first and the base second: base 2 of 8 is 3, base 10 of 100 is 2 and base 3 of 81 is 4, a Number although both operands are Integers; the other components are kept.
DS_r := DS_1[calc Me_3 := log(Me_1, Me_2)];
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 8 | 2 |
| 2 | 100 | 10 |
| 3 | 81 | 3 |
| Id_1 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|
| 1 | 8 | 2 | 3.000000 |
| 2 | 100 | 10 | 2.000000 |
| 3 | 81 | 3 | 4.000000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
log(sc, comp) 🟢 · number, integer → number
Component base 🟢 pandas ✅ · DuckDB ✅
- Tests:
logof a scalar number with the base in a component, insidecalc.- Manual:
Logarithm: “
log ( 1024, 2 )gives10”, although the page’s table and its sentence “calculates the logarithm of num base op” put the base first. The page types the second operand ascomponent<integer> | integer, so that operand may be a component while the first is a scalar.- Expected:
Me_2 = log(1024, Me_1), read as the page’s examples read it: base 2 gives 10.0, base 4 gives 5.0 and base 32 gives 2.0, a Number although both operands are Integers; the other components are kept.
DS_r := DS_1[calc Me_2 := log(1024, Me_1)];
| Id_1 | Me_1 |
|---|---|
| 1 | 2 |
| 2 | 4 |
| 3 | 32 |
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2 | 10.000000 |
| 2 | 4 | 5.000000 |
| 3 | 32 | 2.000000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
log(sc, sc) 🟢 · number, integer → number
Integer operands 🟢 pandas ✅ · DuckDB ✅
- Tests:
logof two integers:log(SC_1, SC_2)withSC_1= 1024 andSC_2= 2.- Manual:
Logarithm: “
log ( 1024, 2 )gives10”, and “The result has type number.”- Expected:
SC_r = 10.0, a Number although both operands are Integers.
SC_r := log(SC_1, SC_2);
| SC_1 | SC_2 |
|---|---|
| 1024 | 2 |
Name |
Type |
Value |
|---|---|---|
|
Number |
|
Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗