Skip to content

Commit 2d6182c

Browse files
kgryteNeerajpathak07
authored andcommitted
fix: treat generic accessor arrays similar to built-in generic arrays
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent f144276 commit 2d6182c

File tree

1 file changed

+3
-3
lines changed
  • lib/node_modules/@stdlib/ndarray/array/lib

1 file changed

+3
-3
lines changed

lib/node_modules/@stdlib/ndarray/array/lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function array() {
165165
btype = getDType( buffer );
166166
FLG = true;
167167
} else {
168-
btype = getBufferDType( buffer );
168+
btype = getBufferDType( buffer ) || 'generic'; // fallback to a "generic" dtype when provided, e.g., a generic accessor array as a data source
169169
FLG = false;
170170
}
171171
}
@@ -208,7 +208,7 @@ function array() {
208208
if ( btype && !isAllowedCast( btype, dtype, opts.casting ) ) {
209209
throw new Error( format( 'invalid option. Data type cast is not allowed. Casting mode: `%s`. From: `%s`. To: `%s`.', opts.casting, btype, dtype ) );
210210
}
211-
} else if ( btype ) {
211+
} else if ( btype ) { // btype !== void 0
212212
// TODO: reconcile difference in behavior when provided a generic array and no `dtype` option. Currently, we cast here, but do not allow casting a generic array (by default) when explicitly providing a `dtype` option.
213213

214214
// Only cast generic array data sources when not provided an ndarray...
@@ -320,7 +320,7 @@ function array() {
320320
}
321321
}
322322
} else if ( buffer ) {
323-
if ( btype === 'generic' && opts.flatten ) {
323+
if ( btype === 'generic' && opts.flatten && isArray( buffer ) ) {
324324
buffer = flatten( buffer, osh || arrayShape( buffer ), order === 'column-major' );
325325
}
326326
if ( buffer.length !== len ) {

0 commit comments

Comments
 (0)