← log operator page · numeric/log/comp_comp/number_then_base

Number then base 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

log with the number and the base both in components, inside calc.

Manual:

Logarithm: "log ( 1024, 2 ) gives 10", 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.

script.vtl ⇩

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

input/DS_1.csv ⇩

Id_1Me_1Me_2
182
210010
3813

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1Me_2Me_3
1823.000000
2100102.000000
38134.000000

expected/DS_r.json ⇩

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