ml-spectra-processing
Advanced tools
Comparing version 8.1.0 to 8.2.0
@@ -134,10 +134,2 @@ import { DoubleArray } from 'cheminfo-types'; | ||
} | ||
export interface DataXYZ { | ||
/** Array of x values */ | ||
x?: DoubleArray; | ||
/** Array of y values */ | ||
y?: DoubleArray; | ||
/** Array of z values */ | ||
z?: DoubleArray; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -26,2 +26,10 @@ import { xFindClosestIndex } from './xFindClosestIndex'; | ||
} | ||
if (fromIndex < 0) | ||
fromIndex = 0; | ||
if (toIndex < 0) | ||
toIndex = 0; | ||
if (fromIndex >= x.length) | ||
fromIndex = x.length - 1; | ||
if (toIndex >= x.length) | ||
toIndex = x.length - 1; | ||
if (fromIndex > toIndex) | ||
@@ -28,0 +36,0 @@ [fromIndex, toIndex] = [toIndex, fromIndex]; |
@@ -1,2 +0,1 @@ | ||
import { DataXYZ } from '..'; | ||
/** | ||
@@ -7,3 +6,5 @@ * Throw an error in no an object of x,y arrays | ||
*/ | ||
export declare function xyCheck(data?: DataXYZ): void; | ||
export declare function xyCheck(data: any, options?: { | ||
minLength?: number; | ||
}): void; | ||
//# sourceMappingURL=xyCheck.d.ts.map |
@@ -7,10 +7,16 @@ import { isAnyArray } from 'is-any-array'; | ||
*/ | ||
export function xyCheck(data = {}) { | ||
if (!isAnyArray(data.x) || !isAnyArray(data.y)) { | ||
export function xyCheck(data, options = {}) { | ||
const { minLength } = options; | ||
if (typeof data !== 'object' || !isAnyArray(data.x) || !isAnyArray(data.y)) { | ||
throw new Error('Data must be an object of x and y arrays'); | ||
} | ||
if (data.x.length !== data.y.length) { | ||
throw new Error('The x and y arrays mush have the same length'); | ||
throw new Error('The x and y arrays must have the same length'); | ||
} | ||
if (minLength) { | ||
if (data.x.length < minLength) { | ||
throw new Error(`data.x must have a length of at least ${minLength}`); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=xyCheck.js.map |
@@ -1,2 +0,2 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
/** | ||
@@ -8,6 +8,5 @@ * Finds all the max values | ||
* @param data - Object that contains property x (an ordered increasing array) and y (an array). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
export declare function xyMaximaY(data?: DataXYZ, options?: {}): { | ||
export declare function xyMaximaY(data: DataXY): { | ||
x: number; | ||
@@ -14,0 +13,0 @@ y: number; |
@@ -8,11 +8,7 @@ import { xyCheck } from './xyCheck'; | ||
* @param data - Object that contains property x (an ordered increasing array) and y (an array). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function xyMaximaY(data = {}, options = {}) { | ||
xyCheck(data); | ||
export function xyMaximaY(data) { | ||
xyCheck(data, { minLength: 2 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 3) | ||
return []; | ||
let maxima = []; | ||
@@ -19,0 +15,0 @@ let startEqualIndex = -1; |
@@ -1,2 +0,2 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
/** | ||
@@ -9,9 +9,9 @@ * Finds the max value in a zone | ||
*/ | ||
export declare function xyMaxY(data?: DataXYZ, options?: { | ||
export declare function xyMaxY(data: DataXY, options?: { | ||
/** | ||
* First value for xyIntegration in the X scale | ||
* First value for xyMaxY in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyIntegration | ||
* First point for xyMaxY | ||
* @default 0 | ||
@@ -21,3 +21,3 @@ * */ | ||
/** | ||
* Last point for xyIntegration | ||
* Last point for xyMaxY | ||
* @default x.length-1 | ||
@@ -27,3 +27,3 @@ * */ | ||
/** | ||
* Last value for xyIntegration in the X scale | ||
* Last value for xyMaxY in the X scale | ||
*/ | ||
@@ -30,0 +30,0 @@ to?: number; |
@@ -10,7 +10,5 @@ import { xGetFromToIndex } from '../x/xGetFromToIndex'; | ||
*/ | ||
export function xyMaxY(data = {}, options = {}) { | ||
export function xyMaxY(data, options = {}) { | ||
xyCheck(data); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) | ||
return 0; | ||
const { fromIndex, toIndex } = xGetFromToIndex(x, options); | ||
@@ -17,0 +15,0 @@ let currentxyMaxY = y[fromIndex]; |
@@ -1,2 +0,2 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
/** | ||
@@ -8,9 +8,9 @@ * Finds the max y value in a range and return a {x,y} point | ||
*/ | ||
export declare function xyMaxYPoint(data?: DataXYZ, options?: { | ||
export declare function xyMaxYPoint(data: DataXY, options?: { | ||
/** | ||
* First value for xyIntegration in the X scale | ||
* First value for xyMaxYPoint in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyIntegration | ||
* First point for xyMaxYPoint | ||
* @default 0 | ||
@@ -20,3 +20,3 @@ * */ | ||
/** | ||
* Last point for xyIntegration | ||
* Last point for xyMaxYPoint | ||
* @default x.length-1 | ||
@@ -26,3 +26,3 @@ * */ | ||
/** | ||
* Last value for xyIntegration in the X scale | ||
* Last value for xyMaxYPoint in the X scale | ||
*/ | ||
@@ -29,0 +29,0 @@ to?: number; |
@@ -9,7 +9,7 @@ import { xGetFromToIndex } from '../x/xGetFromToIndex'; | ||
*/ | ||
export function xyMaxYPoint(data = {}, options = {}) { | ||
xyCheck(data); | ||
export function xyMaxYPoint(data, options = {}) { | ||
xyCheck(data, { minLength: 1 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) { | ||
return { x: 0, y: 0, index: 0 }; | ||
if (x.length === 1) { | ||
return { x: x[0], y: y[0], index: 0 }; | ||
} | ||
@@ -16,0 +16,0 @@ const { fromIndex, toIndex } = xGetFromToIndex(x, options); |
@@ -8,6 +8,5 @@ import { DataXY } from 'cheminfo-types'; | ||
* @param data - Object that contains property X (an ordered increasing array) and y (an arraY). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
export declare function xyMinimaY(data: DataXY, options?: {}): { | ||
export declare function xyMinimaY(data: DataXY): { | ||
x: number; | ||
@@ -14,0 +13,0 @@ y: number; |
@@ -8,11 +8,7 @@ import { xyCheck } from './xyCheck'; | ||
* @param data - Object that contains property X (an ordered increasing array) and y (an arraY). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function xyMinimaY(data, options = {}) { | ||
xyCheck(data); | ||
export function xyMinimaY(data) { | ||
xyCheck(data, { minLength: 2 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 3) | ||
return []; | ||
let maxima = []; | ||
@@ -19,0 +15,0 @@ let startEqualIndex = -1; |
import { DataXY } from 'cheminfo-types'; | ||
/** | ||
* Finds the max y value in a range and return a {x,y} point | ||
* Finds the min y value in a range and return a {x,y} point | ||
* | ||
@@ -8,3 +8,22 @@ * @param data - Object that contains property x (an ordered increasing array) and y (an array) | ||
*/ | ||
export declare function xyMinYPoint(data: DataXY, options?: {}): 0 | { | ||
export declare function xyMinYPoint(data: DataXY, options?: { | ||
/** | ||
* First value for xyMinYPoint in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyMinYPoint | ||
* @default 0 | ||
* */ | ||
fromIndex?: number; | ||
/** | ||
* Last point for xyMinYPoint | ||
* @default x.length-1 | ||
* */ | ||
toIndex?: number; | ||
/** | ||
* Last value for xyMinYPoint in the X scale | ||
*/ | ||
to?: number; | ||
}): { | ||
x: number; | ||
@@ -11,0 +30,0 @@ y: number; |
import { xGetFromToIndex } from '../x/xGetFromToIndex'; | ||
import { xyCheck } from './xyCheck'; | ||
/** | ||
* Finds the max y value in a range and return a {x,y} point | ||
* Finds the min y value in a range and return a {x,y} point | ||
* | ||
@@ -10,6 +10,6 @@ * @param data - Object that contains property x (an ordered increasing array) and y (an array) | ||
export function xyMinYPoint(data, options = {}) { | ||
xyCheck(data); | ||
xyCheck(data, { minLength: 1 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) | ||
return 0; | ||
if (x.length === 1) | ||
return { x: x[0], y: y[0], index: 0 }; | ||
const { fromIndex, toIndex } = xGetFromToIndex(x, options); | ||
@@ -16,0 +16,0 @@ let current = { x: x[fromIndex], y: y[fromIndex], index: fromIndex }; |
@@ -134,10 +134,2 @@ import { DoubleArray } from 'cheminfo-types'; | ||
} | ||
export interface DataXYZ { | ||
/** Array of x values */ | ||
x?: DoubleArray; | ||
/** Array of y values */ | ||
y?: DoubleArray; | ||
/** Array of z values */ | ||
z?: DoubleArray; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -29,2 +29,10 @@ "use strict"; | ||
} | ||
if (fromIndex < 0) | ||
fromIndex = 0; | ||
if (toIndex < 0) | ||
toIndex = 0; | ||
if (fromIndex >= x.length) | ||
fromIndex = x.length - 1; | ||
if (toIndex >= x.length) | ||
toIndex = x.length - 1; | ||
if (fromIndex > toIndex) | ||
@@ -31,0 +39,0 @@ [fromIndex, toIndex] = [toIndex, fromIndex]; |
@@ -1,2 +0,1 @@ | ||
import { DataXYZ } from '..'; | ||
/** | ||
@@ -7,3 +6,5 @@ * Throw an error in no an object of x,y arrays | ||
*/ | ||
export declare function xyCheck(data?: DataXYZ): void; | ||
export declare function xyCheck(data: any, options?: { | ||
minLength?: number; | ||
}): void; | ||
//# sourceMappingURL=xyCheck.d.ts.map |
@@ -10,11 +10,17 @@ "use strict"; | ||
*/ | ||
function xyCheck(data = {}) { | ||
if (!(0, is_any_array_1.isAnyArray)(data.x) || !(0, is_any_array_1.isAnyArray)(data.y)) { | ||
function xyCheck(data, options = {}) { | ||
const { minLength } = options; | ||
if (typeof data !== 'object' || !(0, is_any_array_1.isAnyArray)(data.x) || !(0, is_any_array_1.isAnyArray)(data.y)) { | ||
throw new Error('Data must be an object of x and y arrays'); | ||
} | ||
if (data.x.length !== data.y.length) { | ||
throw new Error('The x and y arrays mush have the same length'); | ||
throw new Error('The x and y arrays must have the same length'); | ||
} | ||
if (minLength) { | ||
if (data.x.length < minLength) { | ||
throw new Error(`data.x must have a length of at least ${minLength}`); | ||
} | ||
} | ||
} | ||
exports.xyCheck = xyCheck; | ||
//# sourceMappingURL=xyCheck.js.map |
@@ -1,2 +0,2 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
/** | ||
@@ -8,6 +8,5 @@ * Finds all the max values | ||
* @param data - Object that contains property x (an ordered increasing array) and y (an array). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
export declare function xyMaximaY(data?: DataXYZ, options?: {}): { | ||
export declare function xyMaximaY(data: DataXY): { | ||
x: number; | ||
@@ -14,0 +13,0 @@ y: number; |
@@ -11,11 +11,7 @@ "use strict"; | ||
* @param data - Object that contains property x (an ordered increasing array) and y (an array). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function xyMaximaY(data = {}, options = {}) { | ||
(0, xyCheck_1.xyCheck)(data); | ||
function xyMaximaY(data) { | ||
(0, xyCheck_1.xyCheck)(data, { minLength: 2 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 3) | ||
return []; | ||
let maxima = []; | ||
@@ -22,0 +18,0 @@ let startEqualIndex = -1; |
@@ -1,2 +0,2 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
/** | ||
@@ -9,9 +9,9 @@ * Finds the max value in a zone | ||
*/ | ||
export declare function xyMaxY(data?: DataXYZ, options?: { | ||
export declare function xyMaxY(data: DataXY, options?: { | ||
/** | ||
* First value for xyIntegration in the X scale | ||
* First value for xyMaxY in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyIntegration | ||
* First point for xyMaxY | ||
* @default 0 | ||
@@ -21,3 +21,3 @@ * */ | ||
/** | ||
* Last point for xyIntegration | ||
* Last point for xyMaxY | ||
* @default x.length-1 | ||
@@ -27,3 +27,3 @@ * */ | ||
/** | ||
* Last value for xyIntegration in the X scale | ||
* Last value for xyMaxY in the X scale | ||
*/ | ||
@@ -30,0 +30,0 @@ to?: number; |
@@ -13,7 +13,5 @@ "use strict"; | ||
*/ | ||
function xyMaxY(data = {}, options = {}) { | ||
function xyMaxY(data, options = {}) { | ||
(0, xyCheck_1.xyCheck)(data); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) | ||
return 0; | ||
const { fromIndex, toIndex } = (0, xGetFromToIndex_1.xGetFromToIndex)(x, options); | ||
@@ -20,0 +18,0 @@ let currentxyMaxY = y[fromIndex]; |
@@ -1,2 +0,2 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
/** | ||
@@ -8,9 +8,9 @@ * Finds the max y value in a range and return a {x,y} point | ||
*/ | ||
export declare function xyMaxYPoint(data?: DataXYZ, options?: { | ||
export declare function xyMaxYPoint(data: DataXY, options?: { | ||
/** | ||
* First value for xyIntegration in the X scale | ||
* First value for xyMaxYPoint in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyIntegration | ||
* First point for xyMaxYPoint | ||
* @default 0 | ||
@@ -20,3 +20,3 @@ * */ | ||
/** | ||
* Last point for xyIntegration | ||
* Last point for xyMaxYPoint | ||
* @default x.length-1 | ||
@@ -26,3 +26,3 @@ * */ | ||
/** | ||
* Last value for xyIntegration in the X scale | ||
* Last value for xyMaxYPoint in the X scale | ||
*/ | ||
@@ -29,0 +29,0 @@ to?: number; |
@@ -12,7 +12,7 @@ "use strict"; | ||
*/ | ||
function xyMaxYPoint(data = {}, options = {}) { | ||
(0, xyCheck_1.xyCheck)(data); | ||
function xyMaxYPoint(data, options = {}) { | ||
(0, xyCheck_1.xyCheck)(data, { minLength: 1 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) { | ||
return { x: 0, y: 0, index: 0 }; | ||
if (x.length === 1) { | ||
return { x: x[0], y: y[0], index: 0 }; | ||
} | ||
@@ -19,0 +19,0 @@ const { fromIndex, toIndex } = (0, xGetFromToIndex_1.xGetFromToIndex)(x, options); |
@@ -8,6 +8,5 @@ import { DataXY } from 'cheminfo-types'; | ||
* @param data - Object that contains property X (an ordered increasing array) and y (an arraY). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
export declare function xyMinimaY(data: DataXY, options?: {}): { | ||
export declare function xyMinimaY(data: DataXY): { | ||
x: number; | ||
@@ -14,0 +13,0 @@ y: number; |
@@ -11,11 +11,7 @@ "use strict"; | ||
* @param data - Object that contains property X (an ordered increasing array) and y (an arraY). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function xyMinimaY(data, options = {}) { | ||
(0, xyCheck_1.xyCheck)(data); | ||
function xyMinimaY(data) { | ||
(0, xyCheck_1.xyCheck)(data, { minLength: 2 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 3) | ||
return []; | ||
let maxima = []; | ||
@@ -22,0 +18,0 @@ let startEqualIndex = -1; |
import { DataXY } from 'cheminfo-types'; | ||
/** | ||
* Finds the max y value in a range and return a {x,y} point | ||
* Finds the min y value in a range and return a {x,y} point | ||
* | ||
@@ -8,3 +8,22 @@ * @param data - Object that contains property x (an ordered increasing array) and y (an array) | ||
*/ | ||
export declare function xyMinYPoint(data: DataXY, options?: {}): 0 | { | ||
export declare function xyMinYPoint(data: DataXY, options?: { | ||
/** | ||
* First value for xyMinYPoint in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyMinYPoint | ||
* @default 0 | ||
* */ | ||
fromIndex?: number; | ||
/** | ||
* Last point for xyMinYPoint | ||
* @default x.length-1 | ||
* */ | ||
toIndex?: number; | ||
/** | ||
* Last value for xyMinYPoint in the X scale | ||
*/ | ||
to?: number; | ||
}): { | ||
x: number; | ||
@@ -11,0 +30,0 @@ y: number; |
@@ -7,3 +7,3 @@ "use strict"; | ||
/** | ||
* Finds the max y value in a range and return a {x,y} point | ||
* Finds the min y value in a range and return a {x,y} point | ||
* | ||
@@ -14,6 +14,6 @@ * @param data - Object that contains property x (an ordered increasing array) and y (an array) | ||
function xyMinYPoint(data, options = {}) { | ||
(0, xyCheck_1.xyCheck)(data); | ||
(0, xyCheck_1.xyCheck)(data, { minLength: 1 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) | ||
return 0; | ||
if (x.length === 1) | ||
return { x: x[0], y: y[0], index: 0 }; | ||
const { fromIndex, toIndex } = (0, xGetFromToIndex_1.xGetFromToIndex)(x, options); | ||
@@ -20,0 +20,0 @@ let current = { x: x[fromIndex], y: y[fromIndex], index: fromIndex }; |
{ | ||
"name": "ml-spectra-processing", | ||
"version": "8.1.0", | ||
"version": "8.2.0", | ||
"description": "Various method to process spectra", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -146,10 +146,1 @@ import { DoubleArray } from 'cheminfo-types'; | ||
} | ||
export interface DataXYZ { | ||
/** Array of x values */ | ||
x?: DoubleArray; | ||
/** Array of y values */ | ||
y?: DoubleArray; | ||
/** Array of z values */ | ||
z?: DoubleArray; | ||
} |
@@ -50,4 +50,9 @@ import { DoubleArray } from 'cheminfo-types'; | ||
} | ||
if (fromIndex < 0) fromIndex = 0; | ||
if (toIndex < 0) toIndex = 0; | ||
if (fromIndex >= x.length) fromIndex = x.length - 1; | ||
if (toIndex >= x.length) toIndex = x.length - 1; | ||
if (fromIndex > toIndex) [fromIndex, toIndex] = [toIndex, fromIndex]; | ||
return { fromIndex, toIndex }; | ||
} |
import { isAnyArray } from 'is-any-array'; | ||
import { DataXYZ } from '..'; | ||
/** | ||
@@ -10,9 +8,15 @@ * Throw an error in no an object of x,y arrays | ||
*/ | ||
export function xyCheck(data: DataXYZ = {}) { | ||
if (!isAnyArray(data.x) || !isAnyArray(data.y)) { | ||
export function xyCheck(data: any, options: { minLength?: number } = {}) { | ||
const { minLength } = options; | ||
if (typeof data !== 'object' || !isAnyArray(data.x) || !isAnyArray(data.y)) { | ||
throw new Error('Data must be an object of x and y arrays'); | ||
} | ||
if ((data.x as number[]).length !== (data.y as number[]).length) { | ||
throw new Error('The x and y arrays mush have the same length'); | ||
throw new Error('The x and y arrays must have the same length'); | ||
} | ||
if (minLength) { | ||
if (data.x.length < minLength) { | ||
throw new Error(`data.x must have a length of at least ${minLength}`); | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
@@ -10,10 +10,7 @@ import { xyCheck } from './xyCheck'; | ||
* @param data - Object that contains property x (an ordered increasing array) and y (an array). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function xyMaximaY(data: DataXYZ = {}, options = {}) { | ||
xyCheck(data); | ||
export function xyMaximaY(data: DataXY) { | ||
xyCheck(data, { minLength: 2 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 3) return []; | ||
let maxima = []; | ||
@@ -20,0 +17,0 @@ let startEqualIndex = -1; |
@@ -1,2 +0,3 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
import { xGetFromToIndex } from '../x/xGetFromToIndex'; | ||
@@ -13,10 +14,10 @@ | ||
export function xyMaxY( | ||
data: DataXYZ = {}, | ||
data: DataXY, | ||
options: { | ||
/** | ||
* First value for xyIntegration in the X scale | ||
* First value for xyMaxY in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyIntegration | ||
* First point for xyMaxY | ||
* @default 0 | ||
@@ -26,3 +27,3 @@ * */ | ||
/** | ||
* Last point for xyIntegration | ||
* Last point for xyMaxY | ||
* @default x.length-1 | ||
@@ -32,3 +33,3 @@ * */ | ||
/** | ||
* Last value for xyIntegration in the X scale | ||
* Last value for xyMaxY in the X scale | ||
*/ | ||
@@ -40,3 +41,2 @@ to?: number; | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) return 0; | ||
@@ -43,0 +43,0 @@ const { fromIndex, toIndex } = xGetFromToIndex(x, options); |
@@ -1,2 +0,3 @@ | ||
import { DataXYZ } from '..'; | ||
import { DataXY } from 'cheminfo-types'; | ||
import { xGetFromToIndex } from '../x/xGetFromToIndex'; | ||
@@ -12,10 +13,10 @@ | ||
export function xyMaxYPoint( | ||
data: DataXYZ = {}, | ||
data: DataXY, | ||
options: { | ||
/** | ||
* First value for xyIntegration in the X scale | ||
* First value for xyMaxYPoint in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyIntegration | ||
* First point for xyMaxYPoint | ||
* @default 0 | ||
@@ -25,3 +26,3 @@ * */ | ||
/** | ||
* Last point for xyIntegration | ||
* Last point for xyMaxYPoint | ||
* @default x.length-1 | ||
@@ -31,3 +32,3 @@ * */ | ||
/** | ||
* Last value for xyIntegration in the X scale | ||
* Last value for xyMaxYPoint in the X scale | ||
*/ | ||
@@ -37,6 +38,6 @@ to?: number; | ||
): { x: number; y: number; index: number } { | ||
xyCheck(data); | ||
xyCheck(data, { minLength: 1 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) { | ||
return { x: 0, y: 0, index: 0 }; | ||
if (x.length === 1) { | ||
return { x: x[0], y: y[0], index: 0 }; | ||
} | ||
@@ -43,0 +44,0 @@ |
@@ -10,10 +10,7 @@ import { DataXY } from 'cheminfo-types'; | ||
* @param data - Object that contains property X (an ordered increasing array) and y (an arraY). | ||
* @param options - Options. | ||
* @returns - Array of points. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function xyMinimaY(data: DataXY, options = {}) { | ||
xyCheck(data); | ||
export function xyMinimaY(data: DataXY) { | ||
xyCheck(data, { minLength: 2 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 3) return []; | ||
let maxima = []; | ||
@@ -20,0 +17,0 @@ let startEqualIndex = -1; |
@@ -7,3 +7,3 @@ import { DataXY } from 'cheminfo-types'; | ||
/** | ||
* Finds the max y value in a range and return a {x,y} point | ||
* Finds the min y value in a range and return a {x,y} point | ||
* | ||
@@ -13,6 +13,28 @@ * @param data - Object that contains property x (an ordered increasing array) and y (an array) | ||
*/ | ||
export function xyMinYPoint(data: DataXY, options = {}) { | ||
xyCheck(data); | ||
export function xyMinYPoint( | ||
data: DataXY, | ||
options: { | ||
/** | ||
* First value for xyMinYPoint in the X scale | ||
*/ | ||
from?: number; | ||
/** | ||
* First point for xyMinYPoint | ||
* @default 0 | ||
* */ | ||
fromIndex?: number; | ||
/** | ||
* Last point for xyMinYPoint | ||
* @default x.length-1 | ||
* */ | ||
toIndex?: number; | ||
/** | ||
* Last value for xyMinYPoint in the X scale | ||
*/ | ||
to?: number; | ||
} = {}, | ||
) { | ||
xyCheck(data, { minLength: 1 }); | ||
const { x, y } = data; | ||
if (x === undefined || y === undefined || x.length < 2) return 0; | ||
if (x.length === 1) return { x: x[0], y: y[0], index: 0 }; | ||
@@ -19,0 +41,0 @@ const { fromIndex, toIndex } = xGetFromToIndex(x, options); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
861850
16451