diff --git a/lib/main.js b/lib/main.js index b4882c3..8496a36 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ var getOffset = require( '@stdlib/ndarray-base-offset' ); var getOrder = require( '@stdlib/ndarray-base-order' ); var getDType = require( '@stdlib/ndarray-base-dtype' ); var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -104,7 +104,7 @@ function broadcastArray( arr, shape ) { sh = getShape( arr, false ); M = sh.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('0i50Z') ); } // Initialize a strides array... strides = []; @@ -122,7 +122,7 @@ function broadcastArray( arr, shape ) { d = sh[ j ]; dim = shape[ 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( sh ).join( ', ' ), copy( shape ).join( ', ' ), i ) ); + throw new Error( format( '0i55F', copy( sh ).join( ', ' ), copy( shape ).join( ', ' ), i ) ); } if ( d === dim ) { strides[ i ] = st[ j ]; @@ -131,7 +131,7 @@ function broadcastArray( arr, shape ) { strides[ 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( sh ).join( ', ' ), copy( shape ).join( ', ' ), i ) ); + throw new Error( format( '0i55G', copy( sh ).join( ', ' ), copy( shape ).join( ', ' ), i ) ); } } return ndarray( getDType( arr ), getData( arr ), copy( shape ), strides, getOffset( arr ), getOrder( arr ) ); // eslint-disable-line max-len diff --git a/package.json b/package.json index 85dd6c0..26b0d41 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/ndarray-base-order": "^0.2.2", "@stdlib/ndarray-base-shape": "^0.2.2", "@stdlib/ndarray-base-strides": "^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" },