Skip to content

Commit 8d3124d

Browse files
committed
docs: add comment
--- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 372443f commit 8d3124d

File tree

1 file changed

+7
-2
lines changed
  • lib/node_modules/@stdlib/ndarray/empty-like/lib

1 file changed

+7
-2
lines changed

lib/node_modules/@stdlib/ndarray/empty-like/lib/main.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var isPlainObject = require( '@stdlib/assert/is-plain-object' );
2626
var isNonNegativeIntegerArray = require( '@stdlib/assert/is-nonnegative-integer-array' ).primitives;
2727
var isEmptyCollection = require( '@stdlib/assert/is-empty-collection' );
2828
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
29+
var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' );
2930
var shape2strides = require( '@stdlib/ndarray/base/shape2strides' );
3031
var numel = require( '@stdlib/ndarray/base/numel' );
3132
var getDType = require( '@stdlib/ndarray/dtype' );
@@ -82,6 +83,7 @@ function emptyLike( x ) {
8283
var opts;
8384
var buf;
8485
var len;
86+
var dt;
8587
var st;
8688
var sh;
8789

@@ -135,11 +137,14 @@ function emptyLike( x ) {
135137
len = 1;
136138
st = [ 0 ];
137139
}
138-
if ( dtype === 'binary' ) {
140+
dt = resolveStr( dtype );
141+
if ( dt === 'binary' ) {
139142
buf = allocUnsafe( len );
140143
} else {
141-
buf = emptyArray( len, dtype );
144+
buf = emptyArray( len, dt );
142145
}
146+
// FIXME: add support for struct dtypes. Will need to do something similar to `array/empty` in so far as allocating an uninitialized array buffer, performing byte alignment, and creating a StructArray view atop the buffer.
147+
143148
return new ndarray( dtype, buf, sh, st, 0, order, opts );
144149
}
145150

0 commit comments

Comments
 (0)