Skip to content

Revise point-cluster packages #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "point-cluster",
"name": "@plotly/point-cluster",
"version": "3.1.8",
"description": "Fast nd point clustering.",
"main": "index.js",
Expand All @@ -9,7 +9,7 @@
},
"repository": {
"type": "git",
"url": "git://github.com/dy/point-cluster.git"
"url": "git://github.com/plotly/point-cluster.git"
},
"keywords": [
"snap-points-2d",
Expand Down Expand Up @@ -41,9 +41,7 @@
"license": "MIT",
"dependencies": {
"array-bounds": "^1.0.1",
"array-normalize": "^1.1.4",
"binary-search-bounds": "^2.0.4",
"bubleify": "^2.0.0",
"clamp": "^1.0.1",
"defined": "^1.0.0",
"dtype": "^2.0.0",
Expand All @@ -55,12 +53,10 @@
},
"devDependencies": {
"almost-equal": "^1.1.0",
"bubleify": "^2.0.0",
"canvas-fit": "^1.5.0",
"gauss-random": "^1.0.1",
"math-float64-bits": "^1.0.1",
"math-float64-from-bits": "^1.0.0",
"math-uint8-bits": "^1.0.0",
"regl": "^1.3.1",
"snap-points-2d": "^3.2.0",
"tape": "^4.8.0"
}
Expand Down
49 changes: 3 additions & 46 deletions research.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@


const t = require('tape');
const cluster = require('./');
const random = require('gauss-random')
const bitsf64 = require('math-float64-from-bits')
const ui8bits = require('math-uint8-bits')
const f64bits = require('math-float64-bits')
// const f64bits = require('math-float64-bits')


t('packing 1e6 array', t => {
let y = new Float64Array(1e6)
let x = new Float64Array(1e6)

console.time(1)
y.subarray(0e5, 1e5)
y.subarray(1e5, 2e5)
Expand All @@ -31,17 +29,14 @@ t('float64 packing', t => {
// uint8 (level) + uint32 (id) + float32→normalized uint16 (x)

let f64 = new Float64Array(1)
let view = new DataView(f64.buffer)
let ui8 = new Uint8Array(f64.buffer)
let ui16 = new Uint16Array(f64.buffer)
let ui32 = new Uint32Array(f64.buffer)

// view.setUint8(7, parseInt('10000000', 2))
// view.setUint8(6, parseInt('00000000', 2))
// ui8[7] = 0xff
// ui16[2] = 0x1000
ui32[1] = 0x00ff0000 & 0x01 << 16 | 0x0000ffff & 0xffff
console.log(f64[0], f64bits(f64[0]))
console.log(f64[0] /* , f64bits(f64[0]) */)

let sign = '0' // ignore sign
let exp = '00000000000' // write levels as exponent
Expand Down Expand Up @@ -122,41 +117,3 @@ function data(N=1e6, f) {

return points
}



/*
// use x-sort if required
if (options.sort) {
// pack levels: uint8, x-coord: uint16 and id: uint32 to float64
let packed = new Float64Array(n)
let packedInt = new Uint32Array(packed.buffer)
for (let i = 0; i < n; i++) {
packedInt[i * 2] = i
packedInt[i * 2 + 1] = (0x3ff00000 & (levels[i] << 20) | 0x0000ffff & ((1 - points[i * 2]) * 0xffff))
}

// do native sort
packed.sort()

// unpack data back
let sortedLevels = new Uint8Array(n)
let sortedWeights = new Uint32Array(n)
let sortedIds = new Uint32Array(n)
let sortedPoints = new Float64Array(n * 2)
for (let i = 0; i < n; i++) {
let id = packedInt[(n - i - 1) * 2]
sortedLevels[i] = levels[id]
sortedWeights[i] = weights[id]
sortedIds[i] = ids[id]
sortedPoints[i * 2] = points[id * 2]
sortedPoints[i * 2 + 1] = points[id * 2 + 1]
}

ids = sortedIds
levels = sortedLevels
points = sortedPoints
weights = sortedWeights
}

*/