Logical negation · not

🟢 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["Logical negation · not<br/>🟢3"]:::ok
    subgraph G_ds["Dataset"]
        direction LR
        v_ds["not DS"]:::ok
    end
    subgraph G_comp["Component"]
        direction LR
        v_comp["not comp"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_sc["not 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 boolean · Gives boolean

Comes from · boolean — 19 operators in 4 blocks 🟢19
General purpose operators (1) 🟢1
Comparison operators (12) 🟢12
Boolean operators (3) 🟢3
Data validation operators (3) 🟢3
Comes from · operators that return any type (their input's) — 38 operators in 8 blocks 🟢38
General purpose operators (6) 🟢6
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 · boolean — 26 operators in 8 blocks 🟢26
General purpose operators (1) 🟢1
Join operators (4) 🟢4
Boolean operators (3) 🟢3
Aggregate and Analytic operators (10) 🟢10
Data validation operators (1) 🟢1
Conditional operators (2) 🟢2
Clause operators (2) 🟢2
Definitions (VTL-DL) (3) 🟢3
Goes to · operators that take any scalar — 38 operators in 8 blocks 🟢38
General purpose operators (6) 🟢6
Comparison operators (11) 🟢11
Set operators (4) 🟢4
Aggregate and Analytic operators (7) 🟢7
Data validation operators (1) 🟢1
Conditional operators (1) 🟢1
Clause operators (7) 🟢7
Definitions (VTL-DL) (1) 🟢1

Forms

not DS 🟢 · boolean → boolean

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

not DS_1 on a data set with one boolean measure.

Manual:

Logical negation, Example 1, output verbatim: “not false gives true” and “not true gives false”.

Expected:

the page’s six data points: Me_1 is the negation of the operand’s Me_1 on each one.

script.vtl
DS_r:= not DS_1;
Input DS_1
Id_1Id_2Id_3Id_4Me_1
M15B2013True
M64B2013False
M65B2013True
F15U2013False
F64U2013False
F65U2013True
Expected DS_r
Id_1Id_2Id_3Id_4Me_1
M15B2013false
M64B2013true
M65B2013false
F15U2013true
F64U2013true
F65U2013false

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

True false and null values 🟢 pandas ✅ · DuckDB ✅
Tests:

not DS_1: a data set with Me_1 true, false and null.

Manual:

Logical negation: “not false gives true”, “not true gives false” and “not null gives null”; the page’s sentence “returns true if op is false, otherwise true” has a typo (“otherwise true” would make not true true) and ignores null, and the listed rows govern.

Expected:

Me_1 is false, true and null: not true is false, not false is true and not null is null.

script.vtl
DS_r := not DS_1;
Input DS_1
Id_1Me_1
1true
2false
3
Expected DS_r
Id_1Me_1
1false
2true
3

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

not comp 🟢 · boolean → boolean

Manual example 2 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_1 [ calc Me_2 := not Me_1 ]: a new measure that negates the component Me_1.

Manual:

Logical negation, Example 2, output verbatim: “not false gives true” and “not true gives false”.

Expected:

the page’s six data points: Me_1 is kept and Me_2 is its negation on each one.

script.vtl
DS_r:= DS_1 [ calc Me_2 := not Me_1 ];
Input DS_1
Id_1Id_2Id_3Id_4Me_1
M15B2013True
M64B2013False
M65B2013True
F15U2013False
F64U2013False
F65U2013True
Expected DS_r
Id_1Id_2Id_3Id_4Me_1Me_2
M15B2013truefalse
M64B2013falsetrue
M65B2013truefalse
F15U2013falsetrue
F64U2013falsetrue
F65U2013truefalse

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

True false and null values 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_1[calc Me_2 := not Me_1]: a component Me_1 that is true, false and null.

Manual:

Logical negation: “not false gives true”, “not true gives false” and “not null gives null”; the page’s sentence “returns true if op is false, otherwise true” has a typo (“otherwise true” would make not true true) and ignores null, and the listed rows govern.

Expected:

Me_2 is false, true and null: not true is false, not false is true and not null is null.

script.vtl
DS_r := DS_1[calc Me_2 := not Me_1];
Input DS_1
Id_1Me_1
1true
2false
3
Expected DS_r
Id_1Me_1Me_2
1truefalse
2falsetrue
3

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

not sc 🟢 · boolean → boolean

True and false operands 🟢 pandas ✅ · DuckDB ✅
Tests:

not SC_true and not SC_false: the two boolean values, with SC_true = true and SC_false = false.

Manual:

Logical negation: “not false gives true”, “not true gives false” and “not null gives null”; the page’s sentence “returns true if op is false, otherwise true” has a typo (“otherwise true” would make not true true) and ignores null, and the listed rows govern.

Expected:

SC_1 is false and SC_2 is true, both Booleans.

script.vtl
SC_1 := not SC_true;
SC_2 := not SC_false;
Input scalars
SC_trueSC_false
truefalse
Expected scalars

Name

Type

Value

SC_1

Boolean

"false"

SC_2

Boolean

"true"

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

Null operand 🟢 pandas ✅ · DuckDB ✅
Tests:

not SC_1 with SC_1 null: the operand is null.

Manual:

Logical negation: “not false gives true”, “not true gives false” and “not null gives null”; the page’s sentence “returns true if op is false, otherwise true” has a typo (“otherwise true” would make not true true) and ignores null, and the listed rows govern.

Expected:

SC_r is null, a Boolean, as in the row “not null gives null”.

script.vtl
SC_r := not SC_1;
Input scalars
SC_1
Expected scalars

Name

Type

Value

SC_r

Boolean

null

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