Skip to content

Commit

Permalink
fix: xyIntegralOptions extends xyIntegrationOptions (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
jobo322 authored Mar 13, 2024
1 parent d15216e commit 3b85a72
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
21 changes: 2 additions & 19 deletions src/xy/xyIntegral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,14 @@ import { DataXY } from 'cheminfo-types';
import { xGetFromToIndex } from '../x';

import { xyCheck } from './xyCheck';
import { XYIntegrationOptions } from './xyIntegration';

export interface XYIntegralOptions {
export interface XYIntegralOptions extends XYIntegrationOptions {
/**
* Integrate from the larger value to the smallest value
* @default false
* */
reverse?: boolean;
/**
* First value for xyIntegration in the X scale
*/
from?: number;
/**
* First point for xyIntegration
* @default 0
* */
fromIndex?: number;
/**
* Last point for xyIntegration
* @default x.length-1
* */
toIndex?: number;
/**
* Last value for xyIntegration in the X scale
*/
to?: number;
}

/**
Expand Down
24 changes: 22 additions & 2 deletions src/xy/xyIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,27 @@ import { DataXY } from 'cheminfo-types';
import { xGetFromToIndex } from '../x';

import { xyCheck } from './xyCheck';
import { XYIntegralOptions } from './xyIntegral';

export interface XYIntegrationOptions {
/**
* First value for xyIntegration in the X scale
*/
from?: number;
/**
* First point for xyIntegration
* @default 0
* */
fromIndex?: number;
/**
* Last point for xyIntegration
* @default x.length-1
* */
toIndex?: number;
/**
* Last value for xyIntegration in the X scale
*/
to?: number;
}

/**
* Calculate integration
Expand All @@ -14,7 +34,7 @@ import { XYIntegralOptions } from './xyIntegral';
*/
export function xyIntegration(
data: DataXY,
options: XYIntegralOptions = {},
options: XYIntegrationOptions = {},
): number {
xyCheck(data, { minLength: 1 });
const { x, y } = data;
Expand Down

0 comments on commit 3b85a72

Please sign in to comment.