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

ckmeans-native

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ckmeans-native - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

4

CHANGELOG.md

@@ -10,1 +10,5 @@ # Changelog

- Remove unneeded artifacts
### 1.1.0
- Fix performance bug to get back to O(kn log(n)) complexity

2

package.json
{
"name": "ckmeans-native",
"version": "1.0.2",
"version": "1.1.0",
"description": "Ckmeans - Fast Univariate Clustering (Native Version)",

@@ -5,0 +5,0 @@ "repository": "schnerd/ckmeans",

@@ -1,6 +0,66 @@

const ckmeans = require('./ckmeans');
const _ckmeans = require('./ckmeans');
test('should find clusters', function () {
const result = ckmeans([1, 2, 4, 5, 12, 43, 52, 123, 234, 1244], 6);
expect(Array.from(result)).toEqual([1, 12, 43, 123, 234, 1244]);
const ckmeans = (...args) => Array.from(_ckmeans(...args));
test('single value', function () {
expect(ckmeans([1], 1)).toEqual([1]);
});
test('same values', function () {
expect(ckmeans([1, 1, 1, 1], 1)).toEqual([1]);
});
test('case 1', function () {
expect(ckmeans([-1, 2, -1, 2, 4, 5, 6, -1, 2, -1], 3)).toEqual([-1, 2, 4]);
});
test('case 2', function () {
expect(ckmeans([-1, 2, -1, 2, 4, 5, 6, -1, 2, -1], 3)).toEqual([-1, 2, 4]);
});
test('case 3', function () {
expect(ckmeans([1, 2, 3], 3)).toEqual([1, 2, 3]);
});
test('case 4', function () {
expect(ckmeans([0, 3, 4], 2)).toEqual([0, 3]);
});
test('case 5', function () {
expect(ckmeans([-3, 0, 4], 2)).toEqual([-3, 4]);
});
test('case 6', function () {
expect(ckmeans([1, 2, 2, 3], 3)).toEqual([1, 2, 3]);
});
test('case 7', function () {
expect(ckmeans([1, 2, 2, 3, 3], 3)).toEqual([1, 2, 3]);
});
test('case 8', function () {
expect(ckmeans([1, 2, 3, 2, 3], 3)).toEqual([1, 2, 3]);
});
test('case 9', function () {
expect(ckmeans([3, 2, 3, 2, 1], 3)).toEqual([1, 2, 3]);
});
test('case 10', function () {
expect(ckmeans([3, 2, 3, 5, 2, 1], 3)).toEqual([1, 3, 5]);
});
test('case 11', function () {
expect(ckmeans([0, 1, 2, 100, 101, 103], 2)).toEqual([0, 100]);
});
test('case 12', function () {
expect(ckmeans([0, 1, 2, 50, 100, 101, 103], 3)).toEqual([0, 50, 100]);
});
test('floating point impercision edge case', function () {
expect(ckmeans([64.64249127327881, 64.64249127328245, 57.79216426169771], 2)).toEqual([
57.79216426169771,
64.64249127327881,
]);
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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