UNPKG

@modelx/model

Version:

Deep Learning Classification, LSTM Time Series, Regression and Multi-Layered Perceptrons with Tensorflow

46 lines (43 loc) 1.63 kB
import { FeatureEmbedding, } from './index'; import * as tf from '@tensorflow/tfjs'; export function toBeWithinRange(received, floor, ceiling) { const pass = received >= floor && received <= ceiling; if (pass) { return { message: () => `expected ${received} not to be within range ${floor} - ${ceiling}`, pass: true, }; } else { return { message: () => `expected ${received} to be within range ${floor} - ${ceiling}`, pass: false, }; } }; expect.extend({ toBeWithinRange, }); describe('toBeWithinRage', () => { it('numeric ranges', () => { expect(100).toBeWithinRange(90, 110); expect(101).not.toBeWithinRange(0, 100); expect({ apples: 6, bananas: 3 }).toEqual({ apples: expect.toBeWithinRange(1, 10), bananas: expect.not.toBeWithinRange(11, 20), }); }); // it('should add to existing data', async () => { // const addToExisting = await FeatureEmbedding.getFeatureDataSet({ // inputMatrixFeatures: [['new1', 'new2', 'old1', 'old2']], // initialIdToFeature: { 1: 'old1', 2: 'old2' }, // initialFeatureToId: { old1: 1, old2: 2 }, // }); // console.log('addToExisting', addToExisting); // expect(addToExisting.numberOfFeatures).toBe(5); // expect(addToExisting.featureIds).toMatchObject([[3, 4, 1, 2]]); // expect(addToExisting.featureToId).toMatchObject({ PAD: 0, old1: 1, old2: 2, new1: 3, new2: 4 }); // expect(addToExisting.idToFeature).toMatchObject({ '0': 'PAD', '1': 'old1', '2': 'old2', '3': 'new1', '4': 'new2' }); // }); });