Skip to content

Commit 2c722f8

Browse files
author
Ricky Reusser
committed
Drop mocha/chai and clean up example
1 parent c7c2d4b commit 2c722f8

File tree

4 files changed

+68
-62
lines changed

4 files changed

+68
-62
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

examples/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
var ndarray = require('ndarray');
44
var linspace = require('../');
5+
var show = require('ndarray-show');
56

6-
console.log(linspace(ndarray([], [2]), 3, 10, {endpoint: false}));
7+
console.log(show(linspace(ndarray([], [2]), 3, 10, {endpoint: false})));
78

8-
console.log(linspace(ndarray([], [2]), 4, 10, {dtype: 'int8'}));
9+
console.log(show(linspace(ndarray([], [2]), 4, 10, {dtype: 'int8'})));

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Fill an ndarray with equally spaced values",
55
"main": "index.js",
66
"scripts": {
7-
"test": "semistandard && mocha test/*",
7+
"test": "semistandard && node test/index.js",
88
"lint": "semistandard",
99
"lint-fix": "semistandard --fix"
1010
},
@@ -19,12 +19,12 @@
1919
"author": "Ricky Reusser",
2020
"license": "MIT",
2121
"devDependencies": {
22-
"chai": "^3.4.1",
23-
"mocha": "^2.3.4",
22+
"assert": "^1.4.1",
2423
"ndarray": "^1.0.18",
2524
"ndarray-show": "^2.0.0",
2625
"ndarray-tests": "^1.3.0",
27-
"semistandard": "^9.1.0"
26+
"semistandard": "^9.1.0",
27+
"tape": "^4.8.0"
2828
},
2929
"dependencies": {
3030
"isndarray": "^1.0.0",

test/index.js

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,77 @@
1-
/* global describe, it */
21
'use strict';
32

43
var ndarray = require('ndarray');
54
var ndt = require('ndarray-tests');
65
var linspace = require('../');
7-
var assert = require('chai').assert;
8-
// var show = require('ndarray-show');
6+
var test = require('tape');
97

10-
describe('linspace', function () {
11-
describe('failure modes', function () {
12-
it('fails if the first argument is not a ndarray', function () {
13-
assert.throws(function () {
14-
linspace(0, 10);
15-
}, Error, /must be a ndarray/);
16-
});
8+
test('fails if the first argument is not a ndarray', function (t) {
9+
t.throws(function () {
10+
linspace(0, 10);
11+
}, Error, /must be a ndarray/);
12+
t.end();
13+
});
1714

18-
it('throws an error if the axis not a number', function () {
19-
assert.throws(function () {
20-
linspace(ndarray([], [2, 2]), 0, 1, {axis: '4'});
21-
}, Error, 'Axis must be a nonegative integer');
22-
});
15+
test('throws an error if the axis not a number', function (t) {
16+
t.throws(function () {
17+
linspace(ndarray([], [2, 2]), 0, 1, {axis: '4'});
18+
}, Error, 'Axis must be a nonegative integer');
19+
t.end();
20+
});
2321

24-
it('throws an error if the axis is greater than the dimension', function () {
25-
assert.throws(function () {
26-
linspace(ndarray([], [2, 2]), 0, 1, {axis: 4});
27-
}, Error, 'must be <= dimension');
28-
});
22+
test('throws an error if the axis is greater than the dimension', function (t) {
23+
t.throws(function () {
24+
linspace(ndarray([], [2, 2]), 0, 1, {axis: 4});
25+
}, Error, 'must be <= dimension');
26+
t.end();
27+
});
2928

30-
it('fails if the endpoint is not a boolean', function () {
31-
assert.throws(function () {
32-
linspace(ndarray([], [1]), 0, 10, {endpoint: 7});
33-
}, Error, /must be a boolean/);
34-
});
35-
});
29+
test('fails if the endpoint is not a boolean', function (t) {
30+
t.throws(function () {
31+
linspace(ndarray([], [1]), 0, 10, {endpoint: 7});
32+
}, Error, /must be a boolean/);
33+
t.end();
34+
});
3635

37-
it('create a new linspace with an endpoint', function () {
38-
var x = linspace(ndarray([], [11]), 0, 10);
39-
var y = ndarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
40-
assert(ndt.equal(x, y, 1e-8));
41-
});
36+
test('create a new linspace with an endpoint', function (t) {
37+
var x = linspace(ndarray([], [11]), 0, 10);
38+
var y = ndarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
39+
t.assert(ndt.equal(x, y, 1e-8));
40+
t.end();
41+
});
4242

43-
it('create a new linspace without an endpoint', function () {
44-
var x = linspace(ndarray([], [10]), 0, 10, {endpoint: false});
45-
var y = ndarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
46-
assert(ndt.equal(x, y, 1e-8));
47-
});
43+
test('create a new linspace without an endpoint', function (t) {
44+
var x = linspace(ndarray([], [10]), 0, 10, {endpoint: false});
45+
var y = ndarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
46+
t.assert(ndt.equal(x, y, 1e-8));
47+
t.end();
48+
});
4849

49-
it('fills in more than one dimension', function () {
50-
var x = linspace(ndarray([], [2, 2]), 0, 1);
51-
var y = ndarray([0, 0, 1, 1], [2, 2]);
52-
assert(ndt.equal(x, y, 1e-8));
53-
});
50+
test('fills in more than one dimension', function (t) {
51+
var x = linspace(ndarray([], [2, 2]), 0, 1);
52+
var y = ndarray([0, 0, 1, 1], [2, 2]);
53+
t.assert(ndt.equal(x, y, 1e-8));
54+
t.end();
55+
});
5456

55-
it('accepts a different axis', function () {
56-
var x = linspace(ndarray([], [2, 2]), 0, 1, {axis: 1});
57-
var y = ndarray([0, 1, 0, 1], [2, 2]);
58-
assert(ndt.equal(x, y, 1e-8));
59-
});
57+
test('accepts a different axis', function (t) {
58+
var x = linspace(ndarray([], [2, 2]), 0, 1, {axis: 1});
59+
var y = ndarray([0, 1, 0, 1], [2, 2]);
60+
t.assert(ndt.equal(x, y, 1e-8));
61+
t.end();
62+
});
6063

61-
it('uses the first point if only one point requested and endpoint = true', function () {
62-
var x = linspace(ndarray([], [1]), 1, 2, {endpoint: true});
63-
var y = ndarray([1], [1]);
64-
assert(ndt.equal(x, y));
65-
});
64+
test('uses the first point if only one point requested an endpoint = true', function (t) {
65+
var x = linspace(ndarray([], [1]), 1, 2, {endpoint: true});
66+
var y = ndarray([1], [1]);
67+
t.assert(ndt.equal(x, y));
68+
t.end();
69+
});
6670

67-
it('uses the first point if only one point requested and endpoint = false', function () {
68-
var x = linspace(ndarray([], [1]), 1, 2, {endpoint: false});
69-
var y = ndarray([1], [1]);
70-
assert(ndt.equal(x, y));
71-
});
71+
test('uses the first point if only one point requested an endpoint = false', function (t) {
72+
var x = linspace(ndarray([], [1]), 1, 2, {endpoint: false});
73+
var y = ndarray([1], [1]);
74+
t.assert(ndt.equal(x, y));
75+
t.end();
7276
});
7377

0 commit comments

Comments
 (0)