From 1b270d93b188f4af162106d75c9227b435d3020e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Jul 2023 22:34:29 +0000 Subject: [PATCH] Auto-generated commit --- CONTRIBUTORS | 1 + array/lib/main.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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.' );