Skip to content

Commit 25abfc6

Browse files
committed
refactor: support non-built-in shape and strides objects
--- 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 eb8260d commit 25abfc6

File tree

1 file changed

+4
-3
lines changed
  • lib/node_modules/@stdlib/ndarray/base/ctor/lib

1 file changed

+4
-3
lines changed

lib/node_modules/@stdlib/ndarray/base/ctor/lib/main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only
2828
var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' );
2929
var iterationOrder = require( '@stdlib/ndarray/base/iteration-order' );
3030
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
31+
var slice = require( '@stdlib/array/base/slice' );
3132
var Boolean = require( '@stdlib/boolean/ctor' );
3233
var isColumnMajorContiguous = require( './is_column_major_contiguous.js' );
3334
var isRowMajorContiguous = require( './is_row_major_contiguous.js' );
@@ -90,7 +91,7 @@ function ndarray( dtype, buffer, shape, strides, offset, order ) {
9091
// Compute the number of elements...
9192
len = 1;
9293
for ( i = 0; i < shape.length; i++ ) {
93-
len *= shape[ i ];
94+
len *= shape[ i ]; // TODO: consider supporting accessor arrays here
9495
}
9596
// Compute the number of bytes...
9697
if ( buffer.BYTES_PER_ELEMENT ) {
@@ -370,7 +371,7 @@ setReadOnlyAccessor( ndarray.prototype, 'order', function get() {
370371
* // returns [ 3, 2 ]
371372
*/
372373
setReadOnlyAccessor( ndarray.prototype, 'shape', function get() {
373-
return this._shape.slice();
374+
return slice( this._shape, 0, this._shape.length );
374375
});
375376

376377
/**
@@ -392,7 +393,7 @@ setReadOnlyAccessor( ndarray.prototype, 'shape', function get() {
392393
* // returns [ 2, 1 ]
393394
*/
394395
setReadOnlyAccessor( ndarray.prototype, 'strides', function get() {
395-
return this._strides.slice();
396+
return slice( this._strides, 0, this._strides.length );
396397
});
397398

398399
/**

0 commit comments

Comments
 (0)