Comparing version
@@ -24,3 +24,3 @@ export type AgglomerationMethod = | ||
export interface Cluster { | ||
export class Cluster { | ||
children: Cluster[]; | ||
@@ -27,0 +27,0 @@ height: number; |
@@ -5,9 +5,12 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var mlDistanceEuclidean = require('ml-distance-euclidean'); | ||
var getDistanceMatrix = _interopDefault(require('ml-distance-matrix')); | ||
var getDistanceMatrix = require('ml-distance-matrix'); | ||
var mlMatrix = require('ml-matrix'); | ||
var Heap = _interopDefault(require('heap')); | ||
var Heap = require('heap'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var getDistanceMatrix__default = /*#__PURE__*/_interopDefaultLegacy(getDistanceMatrix); | ||
var Heap__default = /*#__PURE__*/_interopDefaultLegacy(Heap); | ||
class Cluster { | ||
@@ -57,3 +60,3 @@ constructor() { | ||
const heap = new Heap((a, b) => { | ||
const heap = new Heap__default['default']((a, b) => { | ||
return b.height - a.height; | ||
@@ -65,3 +68,3 @@ }); | ||
while (heap.size() < groups) { | ||
var first = heap.pop(); | ||
const first = heap.pop(); | ||
if (first.children.length === 0) { | ||
@@ -73,3 +76,3 @@ break; | ||
var root = new Cluster(); | ||
const root = new Cluster(); | ||
root.children = heap.toArray(); | ||
@@ -174,3 +177,3 @@ root.height = this.height; | ||
if (!isDistanceMatrix) { | ||
data = getDistanceMatrix(data, distanceFunction); | ||
data = getDistanceMatrix__default['default'](data, distanceFunction); | ||
} | ||
@@ -299,2 +302,3 @@ let distanceMatrix = new mlMatrix.Matrix(data); | ||
exports.Cluster = Cluster; | ||
exports.agnes = agnes; |
{ | ||
"name": "ml-hclust", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Hierarchical clustering algorithms", | ||
@@ -16,6 +16,8 @@ "main": "hclust.js", | ||
"compile": "rollup -c", | ||
"eslint": "eslint src", | ||
"eslint-fix": "eslint src --fix", | ||
"prepublishOnly": "npm run compile", | ||
"test": "npm run test-coverage && npm run eslint", | ||
"eslint": "eslint .", | ||
"eslint-fix": "npm run eslint -- --fix", | ||
"prepack": "npm run compile", | ||
"prettier": "prettier --check .", | ||
"prettier-write": "prettier --write .", | ||
"test": "npm run test-coverage && npm run eslint && npm run prettier", | ||
"test-only": "jest", | ||
@@ -45,10 +47,8 @@ "test-coverage": "jest --coverage" | ||
"devDependencies": { | ||
"@babel/plugin-transform-modules-commonjs": "^7.5.0", | ||
"eslint": "^6.0.1", | ||
"eslint-config-cheminfo": "^1.20.1", | ||
"eslint-plugin-import": "^2.18.0", | ||
"eslint-plugin-jest": "^22.7.2", | ||
"esm": "^3.2.25", | ||
"jest": "^24.8.0", | ||
"rollup": "^1.16.7" | ||
"@babel/plugin-transform-modules-commonjs": "^7.15.4", | ||
"eslint": "^7.32.0", | ||
"eslint-config-cheminfo": "^5.5.0", | ||
"jest": "^27.2.0", | ||
"prettier": "^2.4.1", | ||
"rollup": "^2.56.3" | ||
}, | ||
@@ -58,5 +58,5 @@ "dependencies": { | ||
"ml-distance-euclidean": "^2.0.0", | ||
"ml-distance-matrix": "^2.0.0", | ||
"ml-matrix": "^6.1.2" | ||
"ml-distance-matrix": "^2.0.1", | ||
"ml-matrix": "^6.8.0" | ||
} | ||
} |
# hclust | ||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![build status][ci-image]][ci-url] | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![npm download][download-image]][download-url] | ||
@@ -51,7 +52,9 @@ | ||
[npm-image]: https://img.shields.io/npm/v/ml-hclust.svg?style=flat-square | ||
[npm-image]: https://img.shields.io/npm/v/ml-hclust.svg | ||
[npm-url]: https://npmjs.org/package/ml-hclust | ||
[travis-image]: https://img.shields.io/travis/mljs/hclust/master.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/mljs/hclust | ||
[download-image]: https://img.shields.io/npm/dm/ml-hclust.svg?style=flat-square | ||
[codecov-image]: https://img.shields.io/codecov/c/github/mljs/hclust.svg | ||
[codecov-url]: https://codecov.io/gh/mljs/hclust | ||
[ci-image]: https://github.com/mljs/hclust/workflows/Node.js%20CI/badge.svg?branch=master | ||
[ci-url]: https://github.com/mljs/hclust/actions?query=workflow%3A%22Node.js+CI%22 | ||
[download-image]: https://img.shields.io/npm/dm/ml-hclust.svg | ||
[download-url]: https://npmjs.org/package/ml-hclust |
@@ -54,3 +54,3 @@ import Heap from 'heap'; | ||
while (heap.size() < groups) { | ||
var first = heap.pop(); | ||
const first = heap.pop(); | ||
if (first.children.length === 0) { | ||
@@ -62,3 +62,3 @@ break; | ||
var root = new Cluster(); | ||
const root = new Cluster(); | ||
root.children = heap.toArray(); | ||
@@ -65,0 +65,0 @@ root.height = this.height; |
@@ -6,1 +6,2 @@ export * from './agnes'; | ||
// export * from './chameleon'; | ||
export { default as Cluster } from './Cluster'; |
6
-25%750
0.54%60
5.26%27554
-10.15%9
-10%Updated
Updated