Skip to content

Commit

Permalink
fix typing on arrow table imports (#159)
Browse files Browse the repository at this point in the history
It is possible to instantiate a deeptable from an arrow table without an associated scatterplot, but the types didn't reflect that.
<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> Update `fromArrowTable` and `wrapArrowTable` to support `null` `Scatterplot`, allowing `Deeptable` instantiation without a scatterplot.
> 
>   - **Behavior**:
>     - `fromArrowTable` in `Deeptable.ts` now accepts `Scatterplot | null` for `plot` parameter, allowing `Deeptable` instantiation without a scatterplot.
>     - `wrapArrowTable` in `wrap_arrow.ts` updated to handle `null` `Scatterplot` parameter.
>   - **Documentation**:
>     - Updated docstrings in `Deeptable.ts` and `wrap_arrow.ts` to reflect optional `plot` parameter.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=nomic-ai%2Fdeepscatter&utm_source=github&utm_medium=referral)<sup> for 2f74881. It will automatically update as commits are pushed.</sup>


<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
bmschmidt authored Oct 11, 2024
1 parent 549198c commit 4eca5a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/Deeptable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,19 @@ export class Deeptable {
}

/**
* Generate an ArrowDeeptable from a single Arrow table.
* Generate a deeptable from a single Arrow table.
*
* @param table A single Arrow table
* @param prefs The API Call to use for rendering.
* @param plot The Scatterplot to use.
* @param plot Optionally: the scatterplot to bind the deeptable to.
* If null, the deeptable can be used independently (including in node environments),
* or bound to a scatterplot later.
* @returns
*/
static fromArrowTable(table: Table, plot: Scatterplot): Deeptable {
static fromArrowTable(
table: Table,
plot: Scatterplot | null = null,
): Deeptable {
return wrapArrowTable(tableToIPC(table), plot);
}

Expand Down
14 changes: 10 additions & 4 deletions src/wrap_arrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ import type * as DS from './types';
import { extent } from 'd3-array';
import { Rectangle } from './tile';

// This function is used to wrap an arrow table into a
// deeptable so that record batches can be fetched asynchronously.
// The point display order is the same as in the original file.
// It is exposed primarily as Deeptable.from
/**
* This function is used to wrap an arrow table into a
* deeptable so that record batches can be fetched asynchronously.
* The point display order is the same as in the original file.
* It is exposed primarily as Deeptable.fromArrowTable
* @param tbArray a Uint8 Array that deserializes to an Arrow table. incompatibility between Arrow
* versions makes it easier to simple force this transformation.
* @param plot Optionally, a Scatterplot.
* @returns
*/
export function wrapArrowTable(
tbArray: Uint8Array,
plot: Scatterplot | null,
Expand Down

0 comments on commit 4eca5a7

Please sign in to comment.