diff --git a/lib/main.js b/lib/main.js index 16676d5..236259d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var copy = require( '@stdlib/array-base-copy-indexed' ); var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -96,7 +96,7 @@ function broadcastArray( x, inShape, outShape ) { N = outShape.length; M = inShape.length; if ( N < M ) { - throw new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' ); + throw new Error( format('1hN0Z') ); } // Prepend additional dimensions... data = x; @@ -117,7 +117,7 @@ function broadcastArray( x, inShape, outShape ) { d = inShape[ j ]; dim = outShape[ i ]; if ( dim !== 0 && dim < d ) { - throw new Error( format( 'invalid argument. Input array cannot be broadcast to the specified shape, as the specified shape has a dimension whose size is less than the size of the corresponding dimension in the input array. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) ); + throw new Error( format( '1hN5F', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) ); } if ( d === dim ) { // As the dimension sizes are equal, the stride is one, meaning that each element in the array should be iterated over as normal... @@ -127,7 +127,7 @@ function broadcastArray( x, inShape, outShape ) { st[ i ] = 0; } else { // At this point, we know that `dim > d` and that `d` does not equal `1` (e.g., `dim=3` and `d=2`); in which case, the shapes are considered incompatible (even for desired shapes which are multiples of array dimensions, as might be desired when "tiling" an array; e.g., `dim=4` and `d=2`)... - throw new Error( format( 'invalid argument. Input array and the specified shape are broadcast incompatible. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) ); + throw new Error( format( '1hN5G', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) ); } } // Return broadcast results: diff --git a/package.json b/package.json index 61b0707..5454e88 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-copy-indexed": "^0.2.2", "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" },