How to use the numjs.arange function in numjs

To help you get started, we’ve selected a few numjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github huan / node-facenet / src / cache / embedding-cache.spec.ts View on Github external
test('Cache', async t => {
  const EXPECTED_EMBEDDING = nj.arange(128)

  const sandbox = sinon.createSandbox()

  const embeddingStub = sandbox.stub(
    Facenet.prototype,
    'embedding',
  )
  // embeddingStub.returns(Promise.resolve(EXPECTED_EMBEDDING))
  embeddingStub.callsFake(() => {
    // console.log('fake')
    return Promise.resolve(EXPECTED_EMBEDDING)
  })

  const hitSpy  = sandbox.spy()
  const missSpy = sandbox.spy()
github huan / node-facenet / src / face.spec.ts View on Github external
const IMAGE_DATA  = fixtureImageData3x3()
  const BOX         = [0, 0, 2, 2]
  const CONFIDENCE  = 1
  const MARKS       = [
    [0, 0], [0, 1],
    [0, 0],
    [1, 0], [1, 1],
  ]
  const EXPECTED_IMAGE_ARRAY_2_2 = [
    1, 1, 1, 255,
    2, 2, 2, 255,
    4, 4, 4, 255,
    5, 5, 5, 255,
  ]
  const EMBEDDING = nj.arange(128)

  // tslint:disable-next-line:max-line-length
  const JSON_TEXT = '{"confidence":1,"embedding":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127],"imageData":"AQEB/wICAv8EBAT/BQUF/w==","landmark":{"leftEye":{"x":0,"y":0},"rightEye":{"x":0,"y":1},"nose":{"x":0,"y":0},"leftMouthCorner":{"x":1,"y":0},"rightMouthCorner":{"x":1,"y":1}},"location":{"x":0,"y":0,"w":2,"h":2},"md5":"86858903fdb2a1aa7006792506bd8100"}'

  t.test('get embedding()', async t => {
    const face = new Face(IMAGE_DATA)
    await face.init({ boundingBox: BOX })
    t.notOk(face.embedding, 'should be empty embedding before set')
    face.embedding = EMBEDDING
    t.equal(face.embedding, EMBEDDING, 'should get back the embedding right')
  })

  t.test('toJSON()', async t => {
    const face = new Face(IMAGE_DATA)
    await face.init({
      boundingBox : BOX,