File tree Expand file tree Collapse file tree
lib/node_modules/@stdlib/ndarray/array/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ var isAllowedCast = require( '@stdlib/ndarray/base/assert/is-allowed-data-type-c
3838var createBuffer = require ( '@stdlib/ndarray/base/buffer' ) ;
3939var getType = require ( '@stdlib/ndarray/base/buffer-dtype' ) ;
4040var arrayShape = require ( '@stdlib/array/shape' ) ;
41- var flattenArray = require ( '@stdlib/utils/ flatten-array ' ) ;
41+ var flatten = require ( '@stdlib/array/base/ flatten' ) ;
4242var format = require ( '@stdlib/string/format' ) ;
4343var isArrayLikeObject = require ( './is_array_like_object.js' ) ;
4444var getDefaults = require ( './defaults.js' ) ;
@@ -122,6 +122,7 @@ function array() {
122122 var ndims ;
123123 var nopts ;
124124 var opts ;
125+ var osh ;
125126 var len ;
126127 var ord ;
127128 var FLG ;
@@ -280,6 +281,7 @@ function array() {
280281 len = buffer . length ;
281282 } else if ( opts . flatten && isArray ( buffer ) ) {
282283 shape = arrayShape ( buffer ) ;
284+ osh = shape ; // cache a reference to the inferred shape
283285 ndims = shape . length ;
284286 len = numel ( shape ) ;
285287 } else {
@@ -313,7 +315,7 @@ function array() {
313315 }
314316 } else if ( buffer ) {
315317 if ( btype === 'generic' && opts . flatten ) {
316- buffer = flattenArray ( buffer ) ;
318+ buffer = flatten ( buffer , osh || arrayShape ( buffer ) , false ) ;
317319 }
318320 if ( buffer . length !== len ) {
319321 throw new RangeError ( 'invalid arguments. Array shape is incompatible with provided data source. Number of data source elements does not match array shape.' ) ;
You can’t perform that action at this time.
0 commit comments