Skip to content

Commit

Permalink
Merge pull request #133 from nomic-ai/09-03-typing_updates
Browse files Browse the repository at this point in the history
typing exports take 3
  • Loading branch information
bmschmidt authored Sep 3, 2024
2 parents 64755c1 + 48b2d53 commit b7ee74f
Show file tree
Hide file tree
Showing 22 changed files with 1,316 additions and 1,017 deletions.
2,203 changes: 1,245 additions & 958 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"regl": "^2.1.0"
},
"devDependencies": {
"@playwright/test": "^1.41.2",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@playwright/test": "^1.46.1",
"@sveltejs/vite-plugin-svelte": "^3.1.2",
"@types/d3": "^7.4.3",
"@types/d3-geo": "^3.1.0",
"@types/d3-scale-chromatic": "^3.0.3",
Expand All @@ -80,18 +80,18 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-formatter-summary-chart": "^0.3.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^51.0.1",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-unicorn": "^55.0.0",
"glslify": "^7.1.1",
"glslify-hex": "^2.1.1",
"glslify-loader": "^2.0.0",
"rollup-plugin-glslify": "^1.3.1",
"svelte": "^4.2.12",
"svelte": "^4.2.19",
"terser": "^5.28.1",
"typedoc": "^0.25.8",
"typescript": "^5.3.3",
"typedoc": "^0.26.6",
"typescript": "^5.5.4",
"uvu": "^0.5.6",
"vite": "^5.1.4"
"vite": "^5.4.3"
}
}
2 changes: 1 addition & 1 deletion src/Deeptable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Tile, Rectangle, p_in_rect } from './tile';
import { max, bisectLeft, extent } from 'd3-array';
import type * as DS from './shared';
import type * as DS from './types';
import {
RecordBatch,
StructRowProxy,
Expand Down
2 changes: 1 addition & 1 deletion src/aesthetics/Aesthetic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isConstantChannel } from '../typing';
import { Type, Vector } from 'apache-arrow';
import { StructRowProxy } from 'apache-arrow/row/struct';
import { isNumber } from 'lodash';
import type * as DS from '../shared';
import type * as DS from '../types';
import { Scatterplot } from '../scatterplot';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/aesthetics/AestheticSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { dimensions } from './StatefulAesthetic';
import type { Scatterplot } from '../scatterplot';
import type { Deeptable } from '../Deeptable';
import { StatefulAesthetic } from './StatefulAesthetic';
import type { Encoding } from '../shared';
import type * as DS from '../shared';
import type { Encoding } from '../types';
import type * as DS from '../types';

type AesMap = {
[K in keyof typeof dimensions]: StatefulAesthetic<
Expand Down
2 changes: 1 addition & 1 deletion src/aesthetics/BooleanAesthetic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as DS from '../shared';
import type * as DS from '../types';
import { Aesthetic, Datum } from './Aesthetic';
import { Scatterplot } from '../scatterplot';
import type { TextureSet } from './AestheticSet';
Expand Down
2 changes: 1 addition & 1 deletion src/aesthetics/ColorAesthetic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as DS from '../shared';
import type * as DS from '../types';

import { range as arange, shuffler } from 'd3-array';
import { isConstantChannel } from '../typing';
Expand Down
2 changes: 1 addition & 1 deletion src/aesthetics/ScaledAesthetic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as DS from '../shared';
import type * as DS from '../types';
import { Aesthetic, Datum } from './Aesthetic';
import { Scatterplot } from '../scatterplot';
import type { TextureSet } from './AestheticSet';
Expand Down
2 changes: 1 addition & 1 deletion src/aesthetics/StatefulAesthetic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as DS from '../shared';
import type * as DS from '../types';

import { Size, Jitter_speed, Jitter_radius, X, Y } from './ScaledAesthetic';

Expand Down
24 changes: 23 additions & 1 deletion src/deepscatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,26 @@ export { Deeptable } from './Deeptable';
export { LabelMaker } from './label_rendering';
export { dictionaryFromArrays } from './utilityFunctions';
export { Tile } from './tile';
export * as types from './shared.d';
export type {
APICall,
CompletePrefs,
Encoding,
RowFunction,
LabelOptions,
Labelset,
Labelcall,
Label,
DataSpec,
Dimension,
NumericScaleChannel,
ColorScaleChannel,
ConstantChannel,
LambdaChannel,
BooleanChannel,
LinearColorScale,
CategoricalColorScale,
OpChannel,
TileProxy,
DeeptableCreateParams,
Transformation,
} from './types';
2 changes: 1 addition & 1 deletion src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BackgroundOptions, APICall } from './shared';
import type { BackgroundOptions, APICall } from './types';

export const default_background_options: BackgroundOptions = {
color: 'gray',
Expand Down
2 changes: 1 addition & 1 deletion src/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ReglRenderer } from './regl_rendering';
import { StructRowProxy } from 'apache-arrow';
import { Rectangle } from './tile';
import type { Deeptable } from './Deeptable';
import type * as DS from './shared';
import type * as DS from './types';
import type { Scatterplot } from './scatterplot';
import { PositionalAesthetic } from './aesthetics/ScaledAesthetic';
type Annotation = {
Expand Down
2 changes: 1 addition & 1 deletion src/label_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Scatterplot } from './scatterplot';
import { Timer, timer } from 'd3-timer';
import { select } from 'd3-selection';
import { drag } from 'd3-drag';
import type * as DS from './shared';
import type * as DS from './types';
import { Color } from './aesthetics/ColorAesthetic';

const handler = drag<SVGRectElement, BBox>();
Expand Down
2 changes: 1 addition & 1 deletion src/regl_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import vertex_shader from './glsl/general.vert';
import frag_shader from './glsl/general.frag';
import { AestheticSet } from './aesthetics/AestheticSet';
import { rgb } from 'd3-color';
import type * as DS from './shared';
import type * as DS from './types';
import type { Tile } from './tile';
import REGL from 'regl';
import { Deeptable } from './Deeptable';
Expand Down
2 changes: 1 addition & 1 deletion src/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Zoom } from './interaction';
import type { AestheticSet } from './aesthetics/AestheticSet';
import { timer, Timer } from 'd3-timer';
import { Deeptable } from './Deeptable';
import type * as DS from './shared.d';
import type * as DS from './types';
import { Table } from 'apache-arrow';
import { StatefulAesthetic } from './aesthetics/StatefulAesthetic';
import { PositionalAesthetic } from './aesthetics/ScaledAesthetic';
Expand Down
2 changes: 1 addition & 1 deletion src/scatterplot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
FunctionSelectParams,
IdSelectParams,
} from './selection';
import type * as DS from './shared';
import type * as DS from './types';

// DOM elements that deepscatter uses.

Expand Down
33 changes: 15 additions & 18 deletions src/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ import { Deeptable } from './Deeptable';
import { Scatterplot } from './scatterplot';
import { Tile } from './tile';
import { getTileFromRow } from './tixrixqid';
import type * as DS from './shared.d';
import {
Bool,
StructRowProxy,
Utf8,
Vector,
makeData,
} from 'apache-arrow';
import type * as DS from './types';
import { Bool, StructRowProxy, Utf8, Vector, makeData } from 'apache-arrow';
import { range } from 'd3-array';
interface SelectParams {
name: string;
Expand Down Expand Up @@ -500,13 +494,19 @@ export class DataSelection {
return this;
}

async removePoints(name: string, points: StructRowProxy[]): Promise<DataSelection> {
async removePoints(
name: string,
points: StructRowProxy[],
): Promise<DataSelection> {
return this.add_or_remove_points(name, points, 'remove');
}

// Non-editable behavior:
// if a single point is added, will also adjust the cursor.
async addPoints(name: string, points: StructRowProxy[]): Promise<DataSelection> {
async addPoints(
name: string,
points: StructRowProxy[],
): Promise<DataSelection> {
return this.add_or_remove_points(name, points, 'add');
}

Expand Down Expand Up @@ -537,9 +537,7 @@ export class DataSelection {
// return columns;
// }

public moveCursorToPoint(
point: StructRowProxy,
) {
public moveCursorToPoint(point: StructRowProxy) {
// The point contains a field called 'ix', which increases in each tile;
// we use this for moving because it lets us do binary search for relevant tile.
const rowNumber = point[Symbol.for('rowIndex')] as number;
Expand Down Expand Up @@ -576,9 +574,8 @@ export class DataSelection {
newName: string,
points: StructRowProxy[],
which: 'add' | 'remove',
) : Promise<DataSelection>{

const matches : Record<string, number[]>= {};
): Promise<DataSelection> {
const matches: Record<string, number[]> = {};
for (const point of points) {
const t = getTileFromRow(point, this.deeptable);
const rowNum = point[Symbol.for('rowIndex')] as number;
Expand All @@ -598,12 +595,12 @@ export class DataSelection {
// Then if there are matches.
if (matches[tile.key] !== undefined) {
const mask = Bitmask.from_arrow(original);
for (const rowNum of matches[tile.key]) {
for (const rowNum of matches[tile.key]) {
if (which === 'add') {
mask.set(rowNum);
} else {
mask.unset(rowNum);
}
}
}
return mask.to_arrow();
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type Rectangle = {
// }

import type { TileBufferManager } from './regl_rendering';
import type { ArrowBuildable, LazyTileManifest, TileManifest } from './shared';
import type { ArrowBuildable, LazyTileManifest, TileManifest } from './types';
import { isCompleteManifest } from './typing';

export type RecordBatchCache =
Expand Down Expand Up @@ -135,7 +135,6 @@ export class Tile {
* generated by applying the transformation function associated with it.
*
*
*
* @param colname The name of the column to retrive.
* @returns An Arrow Vector of the column.
*/
Expand Down
7 changes: 3 additions & 4 deletions src/shared.d.ts → src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export type BoolTransformation = (
* https://vega.github.io/vega-lite/docs/encoding.html
*/

type SignedInt = Int8 | Int16 | Int32;
export type WebGlValue = number | [number, number, number];

// The type in JSON. This does not include Date because only
Expand Down Expand Up @@ -376,7 +375,7 @@ export type CategoricalColorScale = {
range: Colorname[];
};

type LinearColorScale = {
export type LinearColorScale = {
field: string;
domain: [number, number]; // TODO: | [number, number, number]
// TODO: implement some codegen for these values
Expand Down Expand Up @@ -594,8 +593,8 @@ export type RowFunction<T> = (
plot?: Scatterplot | undefined,
) => T;

type ZoomRow = [number, number, number];
type ZoomMatrix = [ZoomRow, ZoomRow, ZoomRow];
// type ZoomRow = [number, number, number];
// type ZoomMatrix = [ZoomRow, ZoomRow, ZoomRow];

///////////

Expand Down
2 changes: 1 addition & 1 deletion src/typing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as DS from './shared.d';
import type * as DS from './types';
const transforms = new Set(['linear', 'sqrt', 'log', 'literal']);

export function isTransform(input: unknown): input is DS.Transform {
Expand Down
2 changes: 1 addition & 1 deletion src/wrap_arrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from 'apache-arrow';
import { Deeptable } from './Deeptable';
import { add_or_delete_column } from './Deeptable';
import type * as DS from './shared';
import type * as DS from './types';
import { extent } from 'd3-array';
import { Rectangle } from './tile';

Expand Down
13 changes: 4 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"include": [
"src/**/*.ts",
"src/shared.d.ts"
],
"exclude": [
"node_modules/**/*"
],
"include": ["src/**/*.ts", "src/types.ts"],
"exclude": ["node_modules/**/*"],
"compilerOptions": {
"declarationMap": true,
"declaration": true,
Expand All @@ -22,8 +17,8 @@
"rootDir": "./src",
"lib": ["DOM"],
"noEmitOnError": true,
"emitDeclarationOnly": true,
"emitDeclarationOnly": true
},
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Recommended"
}
}

0 comments on commit b7ee74f

Please sign in to comment.