Skip to content

Commit

Permalink
fix: use a central source of possible patterns for multiplicities (#2352
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jobo322 committed May 12, 2023
1 parent d6e6232 commit fa4dc72
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -86,7 +86,7 @@
"multiplet-analysis": "^2.1.1",
"nmr-correlation": "^2.3.3",
"nmr-load-save": "^0.11.3",
"nmr-processing": "^9.4.0",
"nmr-processing": "^9.4.1",
"nmredata": "^0.9.2",
"numeral": "^2.0.6",
"openchemlib": "^8.3.0",
Expand Down
8 changes: 5 additions & 3 deletions src/component/panels/extra/utilities/MultiplicityUtilities.ts
@@ -1,3 +1,5 @@
import { splitPatterns } from 'nmr-processing';

import { Multiplets } from '../../../../data/constants/Multiplets';

function getMultiplicityNumber(string) {
Expand Down Expand Up @@ -33,9 +35,9 @@ function checkMultiplicity(multiplicity, rejected: Array<string> = []) {

return (
isBroad ||
multiplicity
.split('')
.every((_multiplet) => checkMultiplet(_multiplet, rejected))
splitPatterns(multiplicity).every((_multiplet) =>
checkMultiplet(_multiplet, rejected),
)
);
}

Expand Down
22 changes: 9 additions & 13 deletions src/data/constants/Multiplets.ts
@@ -1,19 +1,15 @@
import { MultiplicityPatterns } from 'nmr-processing';

export interface MultipletDefinition {
label: string;
value: string;
multiplicity: number | null;
}

export const Multiplets: MultipletDefinition[] = [
{ label: 'massive (m)', value: 'm', multiplicity: null },
{ label: 'singlet (s)', value: 's', multiplicity: 1 },
{ label: 'broad singlet (br s)', value: 'br s', multiplicity: 1 },
{ label: 'doublet (d)', value: 'd', multiplicity: 2 },
{ label: 'triplet (t)', value: 't', multiplicity: 3 },
{ label: 'quartet (q)', value: 'q', multiplicity: 4 },
{ label: 'quintet (i)', value: 'i', multiplicity: 5 },
{ label: 'sextet (x)', value: 'x', multiplicity: 6 },
{ label: 'septet (p)', value: 'p', multiplicity: 7 },
{ label: 'octet (o)', value: 'o', multiplicity: 8 },
{ label: 'nonet (n)', value: 'n', multiplicity: 9 },
];
export const Multiplets: MultipletDefinition[] = MultiplicityPatterns.map(
({ label, value, multiplicity }) => ({
label: `${label} (${value})`,
value,
multiplicity,
}),
);

0 comments on commit fa4dc72

Please sign in to comment.