← log operator page · numeric/log/ds_sc/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

the logarithm of every measure of DS_1 to base 2, the number being the first operand.

Manual:

Logarithm, Example 1, output verbatim. The parameter table calls op the base and num the number, but the page's examples read the first operand as the number: "log ( 1024, 2 ) gives 10".

Expected:

Me_1 1024, 64 and 32 give 10.0, 6.0 and 5.0, which agrees with the scalar example; Me_2 has 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.

script.vtl ⇩

DS_r := log ( DS_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.0-0.4064071941354039
10B6.03.749534267669262
11A5.00.9030382701129122

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"}
      ]
    }
  ]
}