ml-spectra-processing
Advanced tools
Comparing version 6.4.0 to 6.5.0
# Changelog | ||
## [6.5.0](https://www.github.com/mljs/spectra-processing/compare/v6.4.0...v6.5.0) (2021-05-04) | ||
### Features | ||
* optimize xySortX if already sorted ([e6dac65](https://www.github.com/mljs/spectra-processing/commit/e6dac65c584b9dcc64a5add1e9819051cf476db4)) | ||
### Bug Fixes | ||
* script to deploy documentation ([2c2cbee](https://www.github.com/mljs/spectra-processing/commit/2c2cbee01967156ab1a2578ae0f8c6fbe8a3fd02)) | ||
## [6.4.0](https://www.github.com/mljs/spectra-processing/compare/v6.3.0...v6.4.0) (2021-05-04) | ||
@@ -4,0 +16,0 @@ |
{ | ||
"name": "ml-spectra-processing", | ||
"version": "6.4.0", | ||
"version": "6.5.0", | ||
"description": "Various method to process spectra", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -0,3 +1,5 @@ | ||
import { xIsMonotone } from '../x/xIsMonotone'; | ||
/** | ||
*This function performs a quick sort of the x array while transforming the y array to preserve the coordinates. | ||
import { xIsMonotone } from '../x/xIsMonotone'; | ||
* This function performs a quick sort of the x array while transforming the y array to preserve the coordinates. | ||
* @param {DataXY} [data] Object that contains property x (Array) and y (Array) | ||
@@ -8,2 +10,17 @@ */ | ||
// no need to sort if it is already sorted | ||
if (xIsMonotone(x) && x.length > 1) { | ||
if (x[0] < x[1]) { | ||
return { | ||
x: Float64Array.from(x), | ||
y: Float64Array.from(y), | ||
}; | ||
} else { | ||
return { | ||
x: Float64Array.from(x).reverse(), | ||
y: Float64Array.from(y).reverse(), | ||
}; | ||
} | ||
} | ||
let xyObject = x | ||
@@ -16,6 +33,9 @@ .map((val, index) => ({ | ||
let response = { x: [], y: [] }; | ||
let response = { | ||
x: new Float64Array(x.length), | ||
y: new Float64Array(y.length), | ||
}; | ||
for (let i = 0; i < x.length; i++) { | ||
response.x.push(xyObject[i].x); | ||
response.y.push(xyObject[i].y); | ||
response.x[i] = xyObject[i].x; | ||
response.y[i] = xyObject[i].y; | ||
} | ||
@@ -22,0 +42,0 @@ |
Sorry, the diff of this file is too big to display
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
250327
6763