Public
Edited
Nov 19, 2020
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tests_bad_unicode_chars = [
tests.bad_unicode_chars(utf8_text, {
id: 'badchar1'
}),
tests.bad_unicode_chars(latin1_text, {
expected: 8,
level: 'info',
id: 'badchar2'
}),
tests.bad_unicode_chars(utf8_data, {
expected: 0,
level: 'info',
id: 'badchar3'
}),
tests.bad_unicode_chars(latin1_data, {
expected: 8,
level: 'error',
id: 'badchar4'
})
]
Insert cell
Insert cell
Insert cell
tests_detect_separator = [
tests.detect_separator(utf8_text, { expected: 'comma', id: 'sep1' }),
tests.detect_separator(latin1_text, { expected: 'tab', id: 'sep2' })
]
Insert cell
Insert cell
Insert cell
tests_empty_rows = [
tests.empty_rows(struct_messy, { expected: 1, id: 'emptyrow1' }),
tests.empty_rows(struct_clean, { id: 'emptyrow2' })
]
Insert cell
Insert cell
Insert cell
tests_unnamed_columns = [
tests.unnamed_columns(struct_messy, { expected: 2, id: 'uncol1' }),
tests.unnamed_columns(struct_clean, { id: 'uncol2' })
]
Insert cell
Insert cell
Insert cell
tests_data_dimensions = [
tests.data_dimensions(struct_messy, { expected: [2, 4], id: 'dim1' }),
tests.data_dimensions(struct_clean, { expected: [1, 2], id: 'dim2' })
]
Insert cell
Insert cell
Insert cell
tests_not_trimmed = {
let dat = add_variable(["foo ", " bar ", "cool", "y o"]);
return [
tests.not_trimmed(dat, { expected: 1, id: 'trim2' }),
tests.not_trimmed(base_data, 'char', { id: 'trim1' })
];
}
Insert cell
Insert cell
Insert cell
tests_discrepancies = {
let dat = add_variable(["a", "a", "b", "b"]);
return [
tests.discrepancy(base_data, 'group', 'num', { expected: 2, id: 'discr1' }),
tests.discrepancy(dat, 'group', 'v', { id: 'discr2' })
];
}
Insert cell
Insert cell
Insert cell
tests_n_distinct = [
tests.n_distinct(base_data, 'char', { expected: 4 }),
tests.n_distinct(base_data, 'group', { expected: 2 })
]
Insert cell
Insert cell
Insert cell
tests_duplicates = {
const dat = add_variable(['aa', 'aa', 'Aa', 'aa ']);
const dat2 = add_variable(['foo', 'fii', 'fo0', 'f11']);
const dat3 = add_variable(['afoo', 'bfii', 'afo0', 'bf11']);
return [
tests.duplicates(base_data, 'char', { id: 'dup1' }),
tests.duplicates(dat, 'v', { id: 'dup2', expected: 3 }),
tests.duplicates(dat2, 'v', { id: 'dup3', expected: 1 }),
tests.duplicates(dat3, 'v', { id: 'dup4', expected: 2, max_dist: 2 })
];
}
Insert cell
Insert cell
Insert cell
tests_date_format = {
let dat = add_variable([
'2020-03-14',
'2020-03-15',
'2020-03-16',
'2020-03-17'
]);
let dat2 = add_variable([
'2020-03-14',
'2020-03-15',
'2020-03-16',
'17/03/2020'
]);
return [
tests.date_format(base_data, 'date', { id: 'dateformat1' }),
tests.date_format(base_data, 'date', {
format: '%d/%m/%Y',
id: 'dateformat2'
}),
tests.date_format(dat, 'v', {
format: '%Y-%m-%d',
id: 'dateformat4',
expected: 0
}),
tests.date_format(dat2, 'v', {
format: '%d/%m/%Y',
id: 'dateformat5',
expected: 3
})
];
}
Insert cell
Insert cell
Insert cell
tests_date_before = {
let dat = add_variable([
'14/03/2020',
'15/03/2020',
'2020-03-16',
'17/03/2020'
]);
return [
tests.date_before(base_data, 'date', {
date: '2020-05-10',
id: 'datebef1',
expected: 2
}),
tests.date_before(base_data, 'date', {
date: '2020-03-17',
id: 'datebef2',
expected: 1
}),
tests.date_before(base_data, 'date', {
date: new Date(2020, 3, 18),
id: 'datebef3',
expected: 2
}),
tests.date_before(base_data, 'date', {
date: d3.utcParse('%d/%m/%Y')('16/03/2020'),
id: 'datebef4',
expected: 1
}),
tests.date_before(dat, 'v', {
date: '2020-03-17',
format: '%d/%m/%Y',
id: 'datebef5',
expected: 2
})
];
}
Insert cell
Insert cell
Insert cell
tests_date_after = {
let dat = add_variable([
'03/14/2020',
'03/15/2020',
'2020-03-16',
'03/17/2020'
]);
return [
tests.date_after(base_data, 'date', {
date: '2020-05-10',
id: 'dateaft1',
expected: 2
}),
tests.date_after(base_data, 'date', {
date: '2020-07-10',
id: 'dateaft2'
}),
tests.date_after(base_data, 'date', {
date: new Date(2020, 3, 18),
id: 'dateaft4',
expected: 2
}),
tests.date_after(base_data, 'date', {
date: d3.utcParse('%d/%m/%Y')('16/03/2020'),
id: 'dateaft4',
expected: 3
}),
tests.date_after(dat, 'v', {
date: '2020-03-15',
format: '%m/%d/%Y',
id: 'dateaft5',
expected: 1
})
];
}
Insert cell
tests.results(tests_date_after)
Insert cell
Insert cell
tests_look_for_values = [
tests.look_for_values(base_data, 'char', { value: 'foo', id: 'lookfor1' }),
tests.look_for_values(base_data, 'char', {
value: 'foob',
expected: false,
id: 'lookfor2'
}),
tests.look_for_values(base_data, 'char', {
value: ['foo', 'foob'],
expected: false,
id: 'lookfor3'
}),
tests.look_for_values(base_data, 'char', {
value: ['foo', 'yo'],
expected: true,
id: 'lookfor4'
}),
tests.look_for_values(base_data, 'char', {
value: [/fo.*/, /bar/],
expected: true,
id: 'lookfor5'
}),
tests.look_for_values(base_data, 'char', {
value: [/foo/, /.*baz/],
expected: false,
id: 'lookfor6'
})
]
Insert cell
Insert cell
Insert cell
base_data.map(d => d.char)
Insert cell
tests_allowed_values = {
return [
tests.allowed_values(base_data, 'char', {
values: ["a", "foo", "yo", "bar"],
expected: 0
}),
tests.allowed_values(base_data, 'char', {
values: ["foo", "bar"],
expected: 2
})
];
}
Insert cell
tests.results(tests_allowed_values)
Insert cell
Insert cell
tests_numeric_range = [
tests.numeric_range(base_data, 'num', { range: [0, 1000], id: 'numrange1' }),
tests.numeric_range(base_data, 'num', {
range: [-Infinity, +Infinity],
id: 'numrange2'
}),
tests.numeric_range(base_data, 'num', {
range: [100, 200],
id: 'numrange3',
expected: 4
})
]
Insert cell
Insert cell
Insert cell
tests_nan_values = {
let dat = add_variable([NaN, 2, NaN, 4]);
return [
tests.NaN_values(base_data, 'num', {
expected: 0
}),
tests.NaN_values(dat, 'v', {
expected: 2
})
];
}
Insert cell
Insert cell
Insert cell
tests_custom = my_test(base_data)
Insert cell
Insert cell
tests.results(tests_custom)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more