Skip to content

Commit 508cde5

Browse files
authored
fix: use updated dependencies (#19)
1 parent 587088a commit 508cde5

File tree

7 files changed

+214
-117
lines changed

7 files changed

+214
-117
lines changed

.gitignore

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
8-
# Runtime data
9-
pids
10-
*.pid
11-
*.seed
12-
*.pid.lock
13-
14-
# Directory for instrumented libs generated by jscoverage/JSCover
15-
lib-cov
16-
17-
# Coverage directory used by tools like istanbul
18-
coverage
19-
20-
# nyc test coverage
21-
.nyc_output
22-
23-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
24-
.grunt
25-
26-
# Bower dependency directory (https://bower.io/)
27-
bower_components
28-
29-
# node-waf configuration
30-
.lock-wscript
31-
32-
# Compiled binary addons (https://nodejs.org/api/addons.html)
33-
build/Release
34-
35-
# Dependency directories
36-
node_modules/
37-
jspm_packages/
38-
39-
# TypeScript v1 declaration files
40-
typings/
41-
42-
# Optional npm cache directory
43-
.npm
44-
45-
# Optional eslint cache
46-
.eslintcache
47-
48-
# Optional REPL history
49-
.node_repl_history
50-
51-
# Output of 'npm pack'
52-
*.tgz
53-
54-
# Yarn Integrity file
55-
.yarn-integrity
56-
57-
# dotenv environment variables file
58-
.env
59-
60-
# parcel-bundler cache (https://parceljs.org/)
61-
.cache
62-
63-
# next.js build output
64-
.next
65-
66-
# nuxt.js build output
67-
.nuxt
68-
69-
# vuepress build output
70-
.vuepress/dist
71-
72-
# Serverless directories
73-
.serverless
74-
75-
# FuseBox cache
76-
.fusebox/
77-
78-
lib
79-
lib-esm
80-
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# parcel-bundler cache (https://parceljs.org/)
61+
.cache
62+
63+
# next.js build output
64+
.next
65+
66+
# nuxt.js build output
67+
.nuxt
68+
69+
# vuepress build output
70+
.vuepress/dist
71+
72+
# Serverless directories
73+
.serverless
74+
75+
# FuseBox cache
76+
.fusebox/
77+
78+
lib
79+
lib-esm
80+
8181
.DS_Store

README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<img alt="NMReDATA" src="images/linear_assignment.svg">
88
</p>
99

10-
1110
This package is the implementation of Jonker-Volgenant shortest
1211
augmenting path algorithm based on the publication [On implementing 2D rectangular assignment algorithms](https://doi.org/10.1109/TAES.2016.140952)
1312

@@ -17,30 +16,28 @@ If the number of rows is <= the number of columns, then every row is assigned to
1716

1817
`$ npm i linear-sum-assignment`
1918

20-
2119
## Usage
2220

2321
```js
2422
import linearSumAssignment from 'linear-sum-assignment';
23+
import { xCostMatrix } from 'ml-spectra-processing';
2524

2625
/**
2726
* there is one more value in the experimental values, so one of
2827
* them will be not assigned.
2928
**/
30-
const xValueExperimental = [1, 2, 3, 4, 5, 7];
31-
const xValuePredicted = [3.1, 1.1, 1.9, 3.99, 5.2];
29+
const experimental = [1, 2, 3, 4, 5, 7];
30+
const predicted = [3.1, 1.1, 1.9, 3.99, 5.2];
3231

3332
/**
34-
* We will compute a cost matrix where xValueExperimental are
35-
* rows and xValuePredicted in columns.
33+
* We will compute a cost matrix where experimental are
34+
* rows and predicted in columns.
3635
* In this case we will look for the closest peak for each experimental peak value.
3736
**/
38-
const diff = xValueExperimental.map((experimental) => {
39-
return xValuePredicted.map((predicted) => {
40-
return Math.abs(predicted - experimental);
41-
});
42-
});
4337

38+
const diff = xCostMatrix(experimental, predicted, {
39+
fct: (a, b) => Math.abs(a - b),
40+
});
4441
const result = linearSumAssignment(diff, { maximaze: false });
4542
console.log(result);
4643
/**
@@ -57,16 +54,15 @@ console.log(result);
5754
],
5855
dualVariableForRows: Float64Array(6) [ 0, 0, 0, 0, 0, 0 ]
5956
}
60-
*/
57+
*/
6158
```
6259

63-
`rowAssignments` contains the index of the column assigned to each element in the rows (xValueExperimental). So the first element in xValueExperimental array is assigned to the second element of xValuePredicted.
64-
`columnAssignments` contains the index of the row assigned to
65-
each element in the columns. So the first element in
66-
xValuePredicted is assigned to third element in
67-
xValueExperimental.
68-
`dualVariableForColumns` and `dualVariableForRows` are the Lagrange multipliers or dual variables.
69-
`gain` the sum of the elements in the cost matrix.
60+
`rowAssignments` contains the index of the column assigned to each element in the rows (experimental).
61+
62+
`columnAssignments` contains the index of the row assigned to each element in the columns. So the first element in predicted is assigned to third element in experimental.
63+
`dualVariableForColumns` and `dualVariableForRows` are the Lagrange multipliers or dual variables.
64+
`gain` the sum of the elements in the cost matrix.
65+
7066
## License
7167

7268
[MIT](./LICENSE)

0 commit comments

Comments
 (0)