Skip to content

Commit

Permalink
readd typecheck functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bmschmidt committed Feb 8, 2023
1 parent 3aad668 commit 85ea651
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
23 changes: 2 additions & 21 deletions src/Aesthetic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,9 @@ import {
import type Scatterplot from './deepscatter';
import type { Regl, Texture2D } from 'regl';
import type { TextureSet } from './AestheticSet';
/*import {
isOpChannel,
isLambdaChannel,
isConstantChannel,
FunctionalChannel,
ConstantBool,
BooleanChannel,
} from './';*/
import type {
Channel,
OpChannel,
LambdaChannel,
BasicChannel,
ConstantChannel,
OpArray,
JitterChannel,
JitterRadiusMethod,
} from './';
import { isOpChannel, isLambdaChannel, isConstantChannel } from './typing';
import type { QuadtileSet } from './Dataset';
import { Vector, tableToIPC, makeVector } from 'apache-arrow';
import { Vector } from 'apache-arrow';
import { StructRowProxy } from 'apache-arrow/row/struct';
import { isNumber } from 'lodash';
// import { Color } from './ColorAesthetic';
Expand All @@ -51,8 +34,6 @@ type DefaultChannel =
| LambdaChannel
| ConstantChannel;

type AllowedTypes = 'linear' | 'boolean' | 'categorical';

export abstract class Aesthetic<
GlValueType = number, // The type of the object passed to webgl. E.g [number, number, number] for [255, 0, 0] = red.
JSValueType = number, // The type of the object in *javascript* which the user interacts with. E.g string for "#FF0000" = red
Expand Down
2 changes: 1 addition & 1 deletion src/ColorAesthetic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Aesthetic, scales } from './Aesthetic';
import type { Regl, Texture2D } from 'regl';
import { range as arange, extent, shuffler } from 'd3-array';

import { isConstantChannel, isOpChannel } from './typing';
import {
scaleLinear,
scaleSqrt,
Expand Down
13 changes: 13 additions & 0 deletions src/typing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function isOpChannel(input: Channel): input is OpChannel {
return (input as OpChannel).op !== undefined;
}

export function isLambdaChannel(input: Channel): input is LambdaChannel {
return (input as LambdaChannel).lambda !== undefined;
}

export function isConstantChannel(
input: Channel | ColorChannel
): input is ConstantChannel {
return (input as ConstantChannel).constant !== undefined;
}

0 comments on commit 85ea651

Please sign in to comment.