diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4da968a6..93c4bdef 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -8,6 +8,7 @@ Athan Reines Brendan Graetz Bruno Fenzl Christopher Dambamuromo +Dan Rose Dominik Moritz Dorrin Sotoudeh Frank Kovacs diff --git a/array/lib/main.js b/array/lib/main.js index 798f774d..8a4496fc 100644 --- a/array/lib/main.js +++ b/array/lib/main.js @@ -38,7 +38,7 @@ var isAllowedCast = require( './../../base/assert/is-allowed-data-type-cast' ); var createBuffer = require( './../../base/buffer' ); var getType = require( './../../base/buffer-dtype' ); var arrayShape = require( '@stdlib/array/shape' ); -var flattenArray = require( '@stdlib/utils/flatten-array' ); +var flatten = require( '@stdlib/array/base/flatten' ); var format = require( '@stdlib/string/format' ); var isArrayLikeObject = require( './is_array_like_object.js' ); var getDefaults = require( './defaults.js' ); @@ -122,6 +122,7 @@ function array() { var ndims; var nopts; var opts; + var osh; var len; var ord; var FLG; @@ -280,6 +281,7 @@ function array() { len = buffer.length; } else if ( opts.flatten && isArray( buffer ) ) { shape = arrayShape( buffer ); + osh = shape; // cache a reference to the inferred shape ndims = shape.length; len = numel( shape ); } else { @@ -313,7 +315,7 @@ function array() { } } else if ( buffer ) { if ( btype === 'generic' && opts.flatten ) { - buffer = flattenArray( buffer ); + buffer = flatten( buffer, osh || arrayShape( buffer ), false ); } if ( buffer.length !== len ) { throw new RangeError( 'invalid arguments. Array shape is incompatible with provided data source. Number of data source elements does not match array shape.' );