← log operator page · numeric/log/comp_sc/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

log of a component to base 2, inside calc, where the result replaces the measure Me_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 ) gives 10", 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_2 is unchanged.

script.vtl ⇩

DS_r := DS_1 [ calc Me_1 := log (Me_1, 2) ];

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
10A10240.7545
10B6413.45
11A321.87

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
        {"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2
10A10.00.7545
10B6.013.45
11A5.01.87

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Id_2", "type": "String", "role": "Identifier"},
        {"name": "Me_1", "type": "Number", "role": "Measure"},
        {"name": "Me_2", "type": "Number", "role": "Measure"}
      ]
    }
  ]
}