Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spectrum-generator

Package Overview
Dependencies
Maintainers
7
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spectrum-generator - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

src/__tests__/roundingProblems.test.js

11

History.md

@@ -0,1 +1,12 @@

## [4.0.1](https://github.com/cheminfo/spectrum-generator/compare/v4.0.0...v4.0.1) (2020-04-18)
### Bug Fixes
* example SpectrumGenerator ([cf49ce1](https://github.com/cheminfo/spectrum-generator/commit/cf49ce1db859e542bb6324006ed338546b4d390f))
* examples ([4a8289b](https://github.com/cheminfo/spectrum-generator/commit/4a8289bafc894d27158c7c4bbadc0d74f1c84206))
* rouding problem in spectrum generation yield to zero values ([fcb1521](https://github.com/cheminfo/spectrum-generator/commit/fcb1521014441290b345d758412c9922f714a156))
# [4.0.0](https://github.com/cheminfo/spectrum-generator/compare/v3.2.2...v4.0.0) (2020-03-18)

@@ -2,0 +13,0 @@

8

lib/index.js

@@ -159,4 +159,3 @@ 'use strict';

);
const middlePoint = (xPosition - this.from) / this.interval;
const middlePoint = Math.round((xPosition - this.from) / this.interval);
// PEAK SHAPE MAY BE ASYMMETRC (widthLeft and widthRight) !

@@ -169,4 +168,3 @@ // we calculate the left part of the shape

);
if (shapeIndex >= 0 && shapeIndex < this.shapeHalfLength) {
if (shapeIndex >= 0 && shapeIndex <= this.shapeHalfLength) {
this.data.y[index] += this.shape.data[shapeIndex] * intensity;

@@ -176,3 +174,3 @@ }

// we calculate the right part of the gaussian
for (let index = Math.ceil(middlePoint); index <= lastPoint; index++) {
for (let index = middlePoint; index <= lastPoint; index++) {
let ratio = ((this.data.x[index] - xPosition) / widthRight) * 2;

@@ -179,0 +177,0 @@

{
"name": "spectrum-generator",
"version": "4.0.0",
"version": "4.0.1",
"description": "generate a spectrum from discrete peaks",

@@ -42,20 +42,20 @@ "main": "lib/index.js",

"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
"@types/jest": "^25.1.4",
"@babel/plugin-transform-modules-commonjs": "^7.9.0",
"@types/jest": "^25.2.1",
"cheminfo-build": "^1.1.0",
"convert-to-jcamp": "^2.0.1",
"eslint": "^6.8.0",
"eslint-config-cheminfo": "^2.0.4",
"eslint-plugin-import": "^2.20.1",
"eslint-config-cheminfo": "^3.0.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-prettier": "^3.1.3",
"esm": "^3.2.25",
"jest": "^25.1.0",
"ml-spectra-processing": "^2.0.1",
"prettier": "^1.19.1",
"rollup": "^2.0.6"
"jest": "^25.3.0",
"ml-spectra-processing": "^2.2.0",
"prettier": "^2.0.4",
"rollup": "^2.6.1"
},
"dependencies": {
"d3-random": "^2.1.0",
"ml-array-normed": "^1.1.0",
"ml-array-normed": "^1.3.1",
"ml-peak-shape-generator": "^0.4.0",

@@ -62,0 +62,0 @@ "ml-xsadd": "2.0.0"

@@ -119,2 +119,3 @@ export interface SpectrumGeneratorOptions {

* nbPoints: 101,
* peakWidthFct: (x) => 1 + 3 * x / 1000 },
* noise: {

@@ -121,0 +122,0 @@ * percent: 10,

@@ -52,3 +52,7 @@ /* eslint-disable jest/expect-expect */

const spectrum = generator.getSpectrum();
expect(spectrum).toMatchSnapshot();
const sumX = spectrum.x.reduce((previous, value) => previous + value);
const sumY = spectrum.y.reduce((previous, value) => previous + value);
expect(sumX).toBe(10050);
expect(sumY).toBeCloseTo(4257.612704089137, 4);
});

@@ -144,3 +148,7 @@

const spectrum = generator.getSpectrum({ threshold: 0.001 });
expect(spectrum).toMatchSnapshot();
const sumX = spectrum.x.reduce((previous, value) => previous + value);
const sumY = spectrum.y.reduce((previous, value) => previous + value);
expect(sumX).toBeCloseTo(5028, 4);
expect(sumY).toBeCloseTo(265.9928557821358, 4);
});

@@ -147,0 +155,0 @@

@@ -104,4 +104,3 @@ import normed from 'ml-array-normed';

);
const middlePoint = (xPosition - this.from) / this.interval;
const middlePoint = Math.round((xPosition - this.from) / this.interval);
// PEAK SHAPE MAY BE ASYMMETRC (widthLeft and widthRight) !

@@ -114,4 +113,3 @@ // we calculate the left part of the shape

);
if (shapeIndex >= 0 && shapeIndex < this.shapeHalfLength) {
if (shapeIndex >= 0 && shapeIndex <= this.shapeHalfLength) {
this.data.y[index] += this.shape.data[shapeIndex] * intensity;

@@ -121,3 +119,3 @@ }

// we calculate the right part of the gaussian
for (let index = Math.ceil(middlePoint); index <= lastPoint; index++) {
for (let index = middlePoint; index <= lastPoint; index++) {
let ratio = ((this.data.x[index] - xPosition) / widthRight) * 2;

@@ -124,0 +122,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc