Commit 95efd3e5 by Ryan McKinley Committed by GitHub

Chore: pad unknown values with undefined (#30808)

parent 11fa7c69
......@@ -38,14 +38,14 @@ describe('Apending DataFrame', () => {
};
const frame = new MutableDataFrame(dto);
expect(frame.fields[0].values.toArray()).toEqual([100, null, null]);
expect(frame.fields[0].values.toArray()).toEqual([100, undefined, undefined]);
// Set a value on the second row
frame.set(1, { time: 200, name: 'BB', value: 20 });
expect(frame.toArray()).toEqual([
{ time: 100, name: 'a', value: 1 }, // 1
{ time: 200, name: 'BB', value: 20 }, // 2
{ time: null, name: null, value: 3 }, // 3
{ time: undefined, name: undefined, value: 3 }, // 3
]);
// Add a time value that has an array type
......@@ -53,8 +53,8 @@ describe('Apending DataFrame', () => {
expect(frame.toArray()).toEqual([
{ time: 100, name: 'a', value: 1 }, // 1
{ time: 200, name: 'BB', value: 20 }, // 2
{ time: null, name: null, value: 3 }, // 3
{ time: 300, name: null, value: null }, // 5
{ time: undefined, name: undefined, value: 3 }, // 3
{ time: 300, name: undefined, value: undefined }, // 5
]);
// Make sure length survives a spread operator
......
......@@ -11,7 +11,7 @@ export type MutableField<T = any> = Field<T, MutableVector<T>>;
type MutableVectorCreator = (buffer?: any[]) => MutableVector;
export const MISSING_VALUE: any = null;
export const MISSING_VALUE: any = undefined; // Treated as connected in new graph panel
export class MutableDataFrame<T = any> extends FunctionalVector<T> implements DataFrame, MutableVector<T> {
name?: string;
......
......@@ -140,7 +140,7 @@ describe('Merge multiple to single', () => {
const expected: Field[] = [
createField('Time', FieldType.time, [1000, 1000, 500]),
createField('Temp', FieldType.number, [1, -1, 2]),
createField('Humidity', FieldType.number, [10, null, 5]),
createField('Humidity', FieldType.number, [10, undefined, 5]),
];
expect(unwrap(result[0].fields)).toEqual(expected);
......@@ -179,7 +179,7 @@ describe('Merge multiple to single', () => {
const expected: Field[] = [
createField('Time', FieldType.time, ['2019-10-01T11:10:23Z', '2019-09-01T11:10:23Z', '2019-11-01T11:10:23Z']),
createField('Temp', FieldType.number, [1, -1, 2]),
createField('Humidity', FieldType.number, [10, null, 5]),
createField('Humidity', FieldType.number, [10, undefined, 5]),
];
expect(unwrap(result[0].fields)).toEqual(expected);
......@@ -222,7 +222,7 @@ describe('Merge multiple to single', () => {
'Germany',
'Canada',
'Canada',
null,
undefined,
]),
createField('AgeGroup', FieldType.string, [
'50 or over',
......@@ -233,7 +233,7 @@ describe('Merge multiple to single', () => {
'25 - 34',
'18 - 24',
]),
createField('Sum', FieldType.number, [998, 1193, 1675, 146, 166, 219, null]),
createField('Sum', FieldType.number, [998, 1193, 1675, 146, 166, 219, undefined]),
createField('Count', FieldType.number, [2, 4, 1, 4, 4, 2, 3]),
];
......@@ -284,17 +284,17 @@ describe('Merge multiple to single', () => {
'35 - 49',
'35 - 49',
]),
createField('Count', FieldType.number, [1, 3, 2, 4, 2, null, null]),
createField('Count', FieldType.number, [1, 3, 2, 4, 2, undefined, undefined]),
createField('Country', FieldType.string, [
'Mexico',
null,
undefined,
'Canada',
'United States',
'United States',
'Germany',
'Canada',
]),
createField('Sum', FieldType.number, [1675, null, 219, 1193, 998, 146, 166]),
createField('Sum', FieldType.number, [1675, undefined, 219, 1193, 998, 146, 166]),
];
expect(unwrap(result[0].fields)).toEqual(expected);
......@@ -334,8 +334,18 @@ describe('Merge multiple to single', () => {
const expected: Field[] = [
createField('Time', FieldType.time, [100, 150, 200, 100, 125, 126, 100, 124, 149]),
createField('Temp', FieldType.number, [1, 4, 5, -1, 2, 3, 1, 4, 5]),
createField('Humidity', FieldType.number, [10, 14, 55, null, null, null, 22, 25, 30]),
createField('Enabled', FieldType.boolean, [null, null, null, true, false, true, null, null, null]),
createField('Humidity', FieldType.number, [10, 14, 55, undefined, undefined, undefined, 22, 25, 30]),
createField('Enabled', FieldType.boolean, [
undefined,
undefined,
undefined,
true,
false,
true,
undefined,
undefined,
undefined,
]),
];
expect(unwrap(result[0].fields)).toEqual(expected);
......
......@@ -33,7 +33,7 @@ Object {
"name": "Field 3",
"type": "number",
"values": Array [
null,
undefined,
4,
undefined,
NaN,
......@@ -45,9 +45,9 @@ Object {
"name": "Field 4",
"type": "number",
"values": Array [
null,
null,
null,
undefined,
undefined,
undefined,
7,
],
},
......
......@@ -67,7 +67,7 @@ describe('MeasurementCollector', () => {
"type": "number",
"values": Array [
0,
null,
undefined,
],
},
Object {
......@@ -79,7 +79,7 @@ describe('MeasurementCollector', () => {
"type": "number",
"values": Array [
1,
null,
undefined,
],
},
Object {
......@@ -203,7 +203,7 @@ describe('MeasurementCollector', () => {
"name": "f0",
"type": "number",
"values": Array [
null,
undefined,
],
},
Object {
......@@ -225,7 +225,7 @@ describe('MeasurementCollector', () => {
"name": "f2",
"type": "string",
"values": Array [
null,
undefined,
],
},
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment