mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for distributions-poisson-quantile (#37955)
This commit is contained in:
parent
1a82bc43d0
commit
8c64582b6d
@ -0,0 +1,75 @@
|
||||
import quantile from 'distributions-poisson-quantile';
|
||||
|
||||
const number = quantile(0);
|
||||
number.toExponential();
|
||||
|
||||
const numberArr = quantile([0]);
|
||||
numberArr.values();
|
||||
|
||||
const noDTypeNumberArr = quantile([0], {});
|
||||
noDTypeNumberArr.values();
|
||||
|
||||
const int8 = quantile([0], { dtype: 'int8' });
|
||||
int8.byteLength;
|
||||
|
||||
const uint8 = quantile([0], { dtype: 'uint8' });
|
||||
uint8.byteLength;
|
||||
|
||||
const uint8_clamped = quantile([0], { dtype: 'uint8_clamped' });
|
||||
uint8_clamped.byteLength;
|
||||
|
||||
const int16 = quantile([0], { dtype: 'int16' });
|
||||
int16.byteLength;
|
||||
|
||||
const uint16 = quantile([0], { dtype: 'uint16' });
|
||||
uint16.byteLength;
|
||||
|
||||
const int32 = quantile([0], { dtype: 'int32' });
|
||||
int32.byteLength;
|
||||
|
||||
const uint32 = quantile([0], { dtype: 'uint32' });
|
||||
uint32.byteLength;
|
||||
|
||||
const float32 = quantile([0], { dtype: 'float32' });
|
||||
float32.byteLength;
|
||||
|
||||
const float64 = quantile([0], { dtype: 'float64' });
|
||||
float64.byteLength;
|
||||
|
||||
const noOptionsFloat64 = quantile(new Float32Array(1));
|
||||
noOptionsFloat64.byteLength;
|
||||
|
||||
const noDTypeFloat64 = quantile(new Float32Array(1), {});
|
||||
noDTypeFloat64.byteLength;
|
||||
|
||||
const undefDTypeFloat64 = quantile(new Float32Array(1), { dtype: undefined });
|
||||
undefDTypeFloat64.byteLength;
|
||||
|
||||
const matrixLike = {
|
||||
data: {},
|
||||
shape: {},
|
||||
offset: 0,
|
||||
strides: {},
|
||||
dtype: '',
|
||||
length: 0,
|
||||
};
|
||||
|
||||
const matrix = quantile(matrixLike);
|
||||
matrix.dtype;
|
||||
matrix.ndims;
|
||||
matrix.shape;
|
||||
matrix.offset;
|
||||
matrix.strides;
|
||||
matrix.length;
|
||||
matrix.nbytes;
|
||||
matrix.data;
|
||||
matrix.set(0, 0, 0);
|
||||
matrix.iset(0, 0);
|
||||
matrix.mset([0], [0], 0);
|
||||
matrix.sset('', 0);
|
||||
matrix.get(0, 0);
|
||||
matrix.iget(0);
|
||||
matrix.mget([0], [0]);
|
||||
matrix.sget('');
|
||||
matrix.toString();
|
||||
matrix.toJSON();
|
||||
81
types/distributions-poisson-quantile/index.d.ts
vendored
Normal file
81
types/distributions-poisson-quantile/index.d.ts
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
// Type definitions for distributions-poisson-quantile 0.0
|
||||
// Project: https://github.com/distributions-io/poisson-quantile#readme
|
||||
// Definitions by: Daniel McNally <https://github.com/sangaman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
declare function quantile(p: number, options?: Options): number;
|
||||
declare function quantile(p: number[], options?: Options & { dtype?: undefined }): number[];
|
||||
declare function quantile(p: Data, options?: Options & { dtype?: 'float64' }): Float64Array;
|
||||
declare function quantile(p: Data, options: Options & { dtype: 'int8' }): Int8Array;
|
||||
declare function quantile(p: Data, options: Options & { dtype: 'uint8' }): Uint8Array;
|
||||
declare function quantile(p: Data, options: Options & { dtype: 'uint8_clamped' }): Uint8ClampedArray;
|
||||
declare function quantile(p: Data, options: Options & { dtype: 'int16' }): Int16Array;
|
||||
declare function quantile(p: Data, options: Options & { dtype: 'uint16' }): Uint16Array;
|
||||
declare function quantile(p: Data, options: Options & { dtype: 'int32' }): Int32Array;
|
||||
declare function quantile(p: Data, options: Options & { dtype: 'uint32' }): Uint32Array;
|
||||
declare function quantile(p: Data, options: Options & { dtype: 'float32' }): Float32Array;
|
||||
declare function quantile(p: MatrixLike, options?: Options): Matrix;
|
||||
|
||||
/**
|
||||
* Evaluates the quantile function for a Poisson distribution.
|
||||
* @param p input value
|
||||
* @param options function options
|
||||
* @returns quantile function value(s)
|
||||
*/
|
||||
declare function quantile(p: number | Data | MatrixLike, options?: Options): number | Data | Matrix;
|
||||
|
||||
type Data = number[]|Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array;
|
||||
|
||||
type DataType = 'int8' | 'uint8' | 'uint8_clamped' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'float32' | 'float64';
|
||||
|
||||
type MatrixCallback = (d: number, i: number, j: number, idx: number) => number;
|
||||
|
||||
// derived from https://github.com/dstructs/matrix
|
||||
interface Matrix {
|
||||
readonly dtype: DataType;
|
||||
readonly ndims: number;
|
||||
readonly shape: number[];
|
||||
offset: number;
|
||||
strides: number[];
|
||||
readonly length: number;
|
||||
readonly nbytes: number;
|
||||
readonly data: Data;
|
||||
set: (i: number, j: number, value: number) => Matrix;
|
||||
iset: (idx: number, value: number) => Matrix;
|
||||
mset: (idx: number[], colsOrValue: number[] | Matrix, value?: number | Matrix | MatrixCallback) => Matrix;
|
||||
sset: (subsequence: string, value: number | Matrix | MatrixCallback) => Matrix;
|
||||
get: (i: number, j: number) => Matrix;
|
||||
iget: (index: number) => Matrix;
|
||||
mget: (idx: number[], cols?: number[]) => Matrix[];
|
||||
sget: (subsequence: string) => Matrix;
|
||||
toString: () => string;
|
||||
toJSON: () => string;
|
||||
}
|
||||
|
||||
// derived from https://github.com/validate-io/matrix-like
|
||||
interface MatrixLike {
|
||||
data: object;
|
||||
shape: object;
|
||||
offset: number;
|
||||
strides: object;
|
||||
dtype: string;
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
/** mean parameter, default=1 */
|
||||
lambda?: number;
|
||||
/** boolean indicating if the function should return a new data structure, default=true */
|
||||
copy?: boolean;
|
||||
/** accessor function for accessing array values */
|
||||
accessor?: (d: Data, i: number) => any;
|
||||
/** deep get/set key path */
|
||||
path?: string;
|
||||
/** deep get/set key path separator, default="." */
|
||||
sep?: string;
|
||||
/** output data type, default="float64" */
|
||||
dtype?: DataType;
|
||||
}
|
||||
|
||||
export = quantile;
|
||||
24
types/distributions-poisson-quantile/tsconfig.json
Normal file
24
types/distributions-poisson-quantile/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"distributions-poisson-quantile-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/distributions-poisson-quantile/tslint.json
Normal file
1
types/distributions-poisson-quantile/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user