21
21
// MODULES //
22
22
23
23
var normalizeMultiSlice = require ( '@stdlib/slice/base/normalize-multi-slice' ) ;
24
+ var nonreducedDimensions = require ( '@stdlib/slice/base/nonreduced-dimensions' ) ;
24
25
var sliceShape = require ( '@stdlib/slice/base/shape' ) ;
25
26
var take = require ( '@stdlib/array/base/take' ) ;
26
27
var vind2bind = require ( '@stdlib/ndarray/base/vind2bind' ) ;
27
28
var numel = require ( '@stdlib/ndarray/base/numel' ) ;
28
29
var format = require ( '@stdlib/string/format' ) ;
29
- var nonreducedDimensions = require ( '@stdlib/slice/base/nonreduced-dimensions' ) ;
30
30
var sliceStart = require ( './slice_start.js' ) ;
31
31
var sliceStrides = require ( './slice_strides.js' ) ;
32
32
var options = require ( './array_options.js' ) ;
@@ -58,6 +58,7 @@ function sliceView( target, property, receiver, slice ) {
58
58
var sdims ;
59
59
var ctor ;
60
60
var sh ;
61
+ var ns ;
61
62
62
63
// Verify that we were successfully able to create a multi-slice:
63
64
if ( slice === null ) {
@@ -76,17 +77,17 @@ function sliceView( target, property, receiver, slice ) {
76
77
throw new RangeError ( format ( 'invalid operation. Number of array dimensions does not match the number of slice dimensions. Array shape: (%s). Slice dimensions: %u.' , shape . join ( ',' ) , slice . ndims ) ) ;
77
78
}
78
79
// Normalize the slice object based on the array shape:
79
- slice = normalizeMultiSlice ( slice , shape , true ) ;
80
+ ns = normalizeMultiSlice ( slice , shape , true ) ;
80
81
81
82
// In strict mode, if the slice exceeds array bounds, raise an exception...
82
- if ( slice . code && strict ) {
83
+ if ( ns . code && strict ) {
83
84
throw new RangeError ( format ( 'invalid operation. Slice exceeds array bounds. Array shape: (%s).' , shape . join ( ',' ) ) ) ;
84
85
}
85
86
// Resolve the output array constructor:
86
87
ctor = receiver . constructor ;
87
88
88
89
// Compute the slice shape:
89
- sh = sliceShape ( slice ) ;
90
+ sh = sliceShape ( ns ) ;
90
91
91
92
// Resolve the indices of the non-reduced dimensions:
92
93
sdims = nonreducedDimensions ( slice ) ;
@@ -96,7 +97,7 @@ function sliceView( target, property, receiver, slice ) {
96
97
return empty ( ctor , dtype , take ( sh , sdims ) , order ) ;
97
98
}
98
99
// Resolve the index offset of the first element:
99
- offset = vind2bind ( shape , strides , offset , order , sliceStart ( slice , shape , strides , 0 ) , 'throw' ) ;
100
+ offset = vind2bind ( shape , strides , offset , order , sliceStart ( ns , shape , strides , 0 ) , 'throw' ) ;
100
101
101
102
// Remove reduced dimensions from the slice shape:
102
103
sh = take ( sh , sdims ) ;
@@ -106,7 +107,7 @@ function sliceView( target, property, receiver, slice ) {
106
107
return new ctor ( dtype , target . data , [ ] , [ 0 ] , offset , order , options ( ) ) ; // eslint-disable-line max-len
107
108
}
108
109
// Update strides according to slice steps:
109
- strides = sliceStrides ( slice , strides , sdims ) ;
110
+ strides = sliceStrides ( ns , strides , sdims ) ;
110
111
111
112
// Return a slice view:
112
113
return new ctor ( dtype , target . data , sh , strides , offset , order , options ( ) ) ; // eslint-disable-line max-len
0 commit comments