Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove shape from type definitions #114

Merged
merged 1 commit into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/GSDPeak.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Shape1D } from 'ml-peak-shape-generator';

export interface GSDPeak {
id?: string;
x: number;
Expand All @@ -18,8 +16,6 @@ export interface GSDPeak {
*/
ddY: number;

shape: Shape1D;

inflectionPoints: {
from: { x: number; index: number };
to: { x: number; index: number };
Expand Down
7 changes: 3 additions & 4 deletions src/gsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {

import { GSDPeak } from './GSDPeak';
import { MakeMandatory } from './utils/MakeMandatory';
import { MakeOptional } from './utils/MakeOptional';
import { optimizeTop } from './utils/optimizeTop';

export interface GSDOptions {
Expand Down Expand Up @@ -49,7 +48,7 @@ export interface GSDOptions {
realTopDetection?: boolean;
}
export type GSDPeakID = MakeMandatory<GSDPeak, 'id'>;
export type GSDPeakIDOptionalShape = MakeOptional<GSDPeak, 'shape'>;

/**
* Global spectra deconvolution
* @param data - Object data with x and y arrays. Values in x has to be growing
Expand Down Expand Up @@ -213,7 +212,7 @@ export function gsd(data: DataXY, options: GSDOptions = {}): GSDPeakID[] {

let lastK = -1;

const peaks: GSDPeakIDOptionalShape[] = [];
const peaks: GSDPeakID[] = [];
for (const minddYIndex of minddY) {
let deltaX = x[minddYIndex];
let possible = -1;
Expand Down Expand Up @@ -271,5 +270,5 @@ export function gsd(data: DataXY, options: GSDOptions = {}): GSDPeakID[] {
return a.x - b.x;
});

return peaks as GSDPeakID[];
return peaks;
}
3 changes: 1 addition & 2 deletions src/post/broadenPeaks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { getShape1D, Shape1D } from 'ml-peak-shape-generator';

import { GSDBroadenPeak } from '../GSDBroadenPeak';
import { GSDPeak } from '../GSDPeak';
import { MakeOptional } from '../utils/MakeOptional';

type GSDPeakOptionalShape = MakeOptional<GSDPeak, 'shape'>;
type GSDPeakOptionalShape = GSDPeak & { shape?: Shape1D };

type GSDBroadenPeakWithID = GSDBroadenPeak & { id: string };
type GSDBroadenPeakWithShape = GSDBroadenPeak & { shape: Shape1D };
Expand Down
3 changes: 1 addition & 2 deletions src/post/joinBroadPeaks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { OptimizationOptions } from 'ml-spectra-fitting';

import { GSDPeak } from '../GSDPeak';
import { GSDPeakOptimized } from '../GSDPeakOptimized';
import { MakeOptional } from '../utils/MakeOptional';
import { addMissingIDs } from '../utils/addMissingIDs';
import { addMissingShape } from '../utils/addMissingShape';

Expand Down Expand Up @@ -36,7 +35,7 @@ export interface JoinBroadPeaksOptions {
* This function tries to join the peaks that seems to belong to a broad signal in a single broad peak.
*/

export type GSDPeakOptionalShape = MakeOptional<GSDPeak, 'shape'>;
export type GSDPeakOptionalShape = GSDPeak & { shape?: Shape1D };

export function joinBroadPeaks<T extends GSDPeakOptionalShape>(
peakList: T[],
Expand Down