diff --git a/.github/.keepalive b/.github/.keepalive new file mode 100644 index 0000000..cf4a59c --- /dev/null +++ b/.github/.keepalive @@ -0,0 +1 @@ +2023-11-01T04:33:17.905Z diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b17435b..0037bdb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -182,7 +182,11 @@ jobs: fi # Trim leading and trailing whitespace: dep=$(echo "$dep" | xargs) - version="^$(npm view $dep version)" + version="$(npm view $dep version)" + if [[ -z "$version" ]]; then + continue + fi + version="^$version" jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp mv package.json.tmp package.json done @@ -192,7 +196,11 @@ jobs: fi # Trim leading and trailing whitespace: dep=$(echo "$dep" | xargs) - version="^$(npm view $dep version)" + version="$(npm view $dep version)" + if [[ -z "$version" ]]; then + continue + fi + version="^$version" jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp mv package.json.tmp package.json done diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 93c4bde..0dae4fe 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -37,3 +37,4 @@ Stephannie Jiménez Gacha Yernar Yergaziyev orimiles5 <97595296+orimiles5@users.noreply.github.com> rei2hu +Robert Gislason diff --git a/package.json b/package.json index da709dc..c19dffd 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "@stdlib/types": "^0.1.0" }, "devDependencies": { - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", + "@stdlib/array-float32": "^0.1.1", + "@stdlib/array-float64": "^0.1.1", "@stdlib/bench": "^0.1.0", "@stdlib/math-base-assert-is-nan": "^0.1.1", "@stdlib/math-base-special-pow": "^0.1.0", diff --git a/test/dist/test.js b/test/dist/test.js index 112ca90..a8a9c60 100644 --- a/test/dist/test.js +++ b/test/dist/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,303 +21,13 @@ // MODULES // var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var array = require( '@stdlib/ndarray-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ddot = require( './../../dist' ); +var main = require( './../../dist' ); // TESTS // -tape( 'main export is a function', function test( t ) { +tape( 'main export is defined', function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof ddot, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function has an arity of 2', function test( t ) { - t.strictEqual( ddot.length, 2, 'has expected arity' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a 1-dimensional ndarray containing double-precision floating-point numbers', function test( t ) { - var values; - var i; - - values = [ - 5, - '5', - true, - false, - null, - void 0, - {}, - [], - function noop() {}, - array( new Float32Array( 10 ) ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - var y = array( new Float64Array( 10 ) ); - - return function badValue() { - ddot( value, y ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a 1-dimensional ndarray containing double-precision floating-point numbers', function test( t ) { - var values; - var i; - - values = [ - 5, - '5', - true, - false, - null, - void 0, - {}, - [], - function noop() {}, - array( new Float32Array( 10 ) ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - var x = array( new Float64Array( 10 ) ); - - return function badValue() { - ddot( x, value ); - }; - } -}); - -tape( 'the function throws an error if provided unequal length vectors', function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - var x = array( new Float64Array( 10 ) ); - var y = array( new Float64Array( 100 ) ); - ddot( x, y ); - } -}); -tape( 'the function calculates the dot product of vectors `x` and `y`', function test( t ) { - var dot; - var x; - var y; - - x = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] ); - - x = array( x ); - y = array( y ); - - dot = ddot( x, y ); - t.strictEqual( dot, -17.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty vectors, the function returns `0`', function test( t ) { - var dot; - var x; - var y; - - x = new Float64Array(); - y = new Float64Array(); - - x = array( x ); - y = array( y ); - - dot = ddot( x, y ); - t.strictEqual( dot, 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports a strided vector for the first argument', function test( t ) { - var dot; - var x; - var y; - - x = new Float64Array([ - 2.0, // 0 - -3.0, - -5.0, // 1 - 7.0, - 6.0 // 2 - ]); - y = new Float64Array([ - 8.0, // 0 - 2.0, // 1 - -3.0 // 2 - ]); - - x = ndarray( 'float64', x, [ 3 ], [ 2 ], 0, 'row-major' ); - y = ndarray( 'float64', y, [ 3 ], [ 1 ], 0, 'row-major' ); - - dot = ddot( x, y ); - t.strictEqual( dot, -12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports a strided vector for the second argument', function test( t ) { - var dot; - var x; - var y; - - x = new Float64Array([ - 2.0, // 0 - -3.0, // 1 - -5.0 // 2 - ]); - y = new Float64Array([ - 8.0, // 0 - 2.0, - -3.0, // 1 - 3.0, - -4.0, // 2 - 1.0 - ]); - - x = ndarray( 'float64', x, [ 3 ], [ 1 ], 0, 'row-major' ); - y = ndarray( 'float64', y, [ 3 ], [ 2 ], 0, 'row-major' ); - - dot = ddot( x, y ); - t.strictEqual( dot, 45.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports negative strides', function test( t ) { - var dot; - var x; - var y; - - x = new Float64Array([ - 1.0, // 2 - 2.0, - 3.0, // 1 - 4.0, - 5.0 // 0 - ]); - y = new Float64Array([ - 6.0, // 2 - 7.0, // 1 - 8.0 // 0 - ]); - - x = ndarray( 'float64', x, [ 3 ], [ -2 ], x.length-1, 'row-major' ); - y = ndarray( 'float64', y, [ 3 ], [ -1 ], y.length-1, 'row-major' ); - - dot = ddot( x, y ); - t.strictEqual( dot, 67.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns', function test( t ) { - var dot; - var x; - var y; - - x = new Float64Array([ - 1.0, // 0 - 2.0, - 3.0, // 1 - 4.0, - 5.0 // 2 - ]); - y = new Float64Array([ - 6.0, // 2 - 7.0, // 1 - 8.0 // 0 - ]); - - x = ndarray( 'float64', x, [ 3 ], [ 2 ], 0, 'row-major' ); - y = ndarray( 'float64', y, [ 3 ], [ -1 ], y.length-1, 'row-major' ); - - dot = ddot( x, y ); - t.strictEqual( dot, 59.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports strided vectors having offsets', function test( t ) { - var dot; - var x; - var y; - - x = new Float64Array([ - 0.0, - 2.0, // 0 - -3.0, - -5.0, // 1 - 7.0, - 6.0 // 2 - ]); - y = new Float64Array([ - 0.0, - 0.0, - 8.0, // 0 - 2.0, // 1 - -3.0 // 2 - ]); - - x = ndarray( 'float64', x, [ 3 ], [ 2 ], 1, 'row-major' ); - y = ndarray( 'float64', y, [ 3 ], [ 1 ], 2, 'row-major' ); - - dot = ddot( x, y ); - t.strictEqual( dot, -12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports underlying data buffers with view offsets', function test( t ) { - var dot; - var x0; - var y0; - var x1; - var y1; - - x0 = new Float64Array([ - 1.0, - 2.0, // 0 - 3.0, - 4.0, // 1 - 5.0, - 6.0 // 2 - ]); - y0 = new Float64Array([ - 6.0, - 7.0, - 8.0, - 9.0, // 0 - 10.0, // 1 - 11.0 // 2 - ]); - - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); - - x1 = ndarray( 'float64', x1, [ 3 ], [ 2 ], 0, 'row-major' ); - y1 = ndarray( 'float64', y1, [ 3 ], [ 1 ], 0, 'row-major' ); - - dot = ddot( x1, y1 ); - t.strictEqual( dot, 124.0, 'returns expected value' ); - + t.strictEqual( main !== void 0, true, 'main export is defined' ); t.end(); });