Natural logarithm · ln

🟢 3 of 3 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc3 (9e1c81a6) · pandas 2.3.3 · DuckDB 1.5.5
🟢 all ok🟡 partially implemented🛡️ refused with an error🔴 not implemented or crash🔵 engines differ ✅ match · ❌ wrong result · 🛡 guarded error (code) · 💥 crash · 📌 team decision
Dataset formsComponent formsScalar forms
        ---
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["Natural logarithm · ln<br/>🟢3"]:::ok
    subgraph G_ds["Dataset"]
        direction LR
        v_ds["ln(DS)"]:::ok
    end
    subgraph G_comp["Component"]
        direction LR
        v_comp["ln(comp)"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_sc["ln(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 href "#form-ds"
    click v_comp href "#form-comp"
    click v_sc href "#form-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
Clause operators (9) 🟢9
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
Clause operators (9) 🟢9

Forms

ln(DS) 🟢 · number → number

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

ln on every measure of DS_1.

Manual:

Natural logarithm, Example 1, output verbatim: “The operator ln calculates the natural logarithm of a number.”

Expected:

Me_1 148.413, 2980.95 and 7.38905 give 5.0, 8.0 and 2.0; Me_2 0.7545, 13.45 and 1.87 give -0.2817, 2.598979 and 0.625938, as the page prints them, shortened.

script.vtl
DS_r := ln(DS_1);
Input DS_1
Id_1Id_2Me_1Me_2
10A148.4130.7545
10B2980.9513.45
11A7.389051.87
Expected DS_r
Id_1Id_2Me_1Me_2
10A5.0-0.2817
10B8.02.598979
11A2.00.625938

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

ln(comp) 🟢 · number → number

Manual example 2 🟢 pandas ✅ · DuckDB ✅
Tests:

ln on a component inside calc, where the result replaces the measure Me_2.

Manual:

Natural logarithm, Example 2, output verbatim: “The operator ln calculates the natural logarithm of a number.”

Expected:

Me_2 = ln(Me_1) is 5.0, 8.0 and 2.0; Me_1 is unchanged.

script.vtl
DS_r := DS_1 [ calc Me_2 := ln ( Me_1 ) ];
Input DS_1
Id_1Id_2Me_1Me_2
10A148.4130.7545
10B2980.9513.45
11A7.389051.87
Expected DS_r
Id_1Id_2Me_1Me_2
10A148.4135.0
10B2980.958.0
11A7.389052.0

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

ln(sc) 🟢 · number → number

Integer operand 🟢 pandas ✅ · DuckDB ✅
Tests:

ln of an integer: ln(SC_1) with SC_1 = 148.

Manual:

Natural logarithm: “ln ( 148 ) gives 4.997...”, and “The result has type number.”

Expected:

SC_r = 4.997212 (ln 148 = ln 100 + ln 1.48 = 4.605170 + 0.392042), a Number although the operand is an Integer.

script.vtl
SC_r := ln(SC_1);
Input scalars
SC_1
148
Expected scalars

Name

Type

Value

SC_r

Number

"4.997212"

Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗