Skip to content

Commit 71d561c

Browse files
committedOct 10, 2023
refactor: use accessor utilities
1 parent db91a38 commit 71d561c

File tree

1 file changed

+9
-6
lines changed
  • lib/node_modules/@stdlib/ndarray/zeros-like/lib

1 file changed

+9
-6
lines changed
 

‎lib/node_modules/@stdlib/ndarray/zeros-like/lib/main.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ var shape2strides = require( '@stdlib/ndarray/base/shape2strides' );
2828
var strides2offset = require( '@stdlib/ndarray/base/strides2offset' );
2929
var buffer = require( '@stdlib/ndarray/base/buffer' );
3030
var numel = require( '@stdlib/ndarray/base/numel' );
31+
var getDType = require( '@stdlib/ndarray/dtype' );
32+
var getShape = require( '@stdlib/ndarray/shape' );
33+
var getOrder = require( '@stdlib/ndarray/order' );
3134
var ndarray = require( '@stdlib/ndarray/ctor' );
3235
var format = require( '@stdlib/string/format' );
3336

@@ -91,7 +94,7 @@ function zerosLike( x ) {
9194
if ( hasOwnProp( options, 'dtype' ) ) {
9295
dtype = options.dtype;
9396
} else {
94-
dtype = x.dtype;
97+
dtype = getDType( x );
9598
}
9699
if ( hasOwnProp( options, 'shape' ) ) {
97100
sh = options.shape;
@@ -102,12 +105,12 @@ function zerosLike( x ) {
102105
throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );
103106
}
104107
} else {
105-
sh = x.shape;
108+
sh = getShape( x );
106109
}
107110
if ( hasOwnProp( options, 'order' ) ) {
108111
order = options.order;
109112
} else {
110-
order = x.order;
113+
order = getOrder( x );
111114
}
112115
if ( hasOwnProp( options, 'mode' ) ) {
113116
opts.mode = options.mode;
@@ -119,9 +122,9 @@ function zerosLike( x ) {
119122
opts.readonly = options.readonly;
120123
}
121124
} else {
122-
dtype = x.dtype;
123-
sh = x.shape;
124-
order = x.order;
125+
dtype = getDType( x );
126+
sh = getShape( x );
127+
order = getOrder( x );
125128
}
126129
ndims = sh.length;
127130
if ( ndims > 0 ) {

0 commit comments

Comments
 (0)