Skip to content

Commit

Permalink
Add mock bigint data
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Sep 6, 2024
1 parent ac0b148 commit 1768b3e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/app/src/providers/mock/mock-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export function makeMockFile(): GroupWithChildren {
scalar('raw_large', undefined), // generated dynamically by `MockProvider`
dataset('raw_png', opaqueType(), [], PNG_RED_DOT),
scalar('scalar_num', 0, { attributes: [scalarAttr('attr', 0)] }),
scalar('scalar_bigint', BigInt(Number.MAX_SAFE_INTEGER) + 1n, {
attributes: [
scalarAttr('attr', BigInt(Number.MAX_SAFE_INTEGER) + 1n),
],
}),
scalar('scalar_str', 'foo', {
attributes: [scalarAttr('attr', 'foo')],
}),
Expand Down Expand Up @@ -108,6 +113,7 @@ export function makeMockFile(): GroupWithChildren {
group('nD_datasets', [
array('oneD_linear'),
array('oneD'),
array('oneD_bigint'),
array('oneD_cplx'),
array('oneD_compound', {
type: printableCompoundType({
Expand All @@ -121,6 +127,7 @@ export function makeMockFile(): GroupWithChildren {
array('oneD_bool'),
array('oneD_enum', { type: enumType(uintType(8), ENUM_MAPPING) }),
array('twoD'),
array('twoD_bigint'),
array('twoD_cplx'),
array('twoD_compound', {
type: printableCompoundType({
Expand Down
15 changes: 15 additions & 0 deletions packages/shared/src/mock-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const range9 = () => range(1, 11);

const oneD = () => ndarray(range1().map((val) => val ** 2));

const oneD_bigint = () =>
ndarray(
range8().map((_, i) => BigInt(Number.MAX_SAFE_INTEGER) + BigInt(i - 5)),
);

const oneD_bool = () =>
ndarray([true, false, false, true, true, true, false, true, false, false]);

Expand Down Expand Up @@ -89,6 +94,7 @@ const threeD_rgb = () =>
export const mockValues = {
oneD,
oneD_linear: () => ndarray(range1()),
oneD_bigint,
oneD_cplx,
oneD_compound,
oneD_bool,
Expand All @@ -103,6 +109,15 @@ export const mockValues = {
shapeTwoD,
);
},
twoD_bigint: () => {
const { data: dataOneDBigInt } = oneD_bigint();
return ndarray(
range5().flatMap((_, i) =>
dataOneDBigInt.map((val) => val + 1n + BigInt(i) * 10n),
),
[3, 5],
);
},
twoD_cplx: () =>
ndarray(
[
Expand Down

0 comments on commit 1768b3e

Please sign in to comment.