Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Oct 8, 2023
1 parent a2cf83f commit 4e784e7
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 46 deletions.
2 changes: 1 addition & 1 deletion base/empty-like/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function emptyLike( x ) {
var dt;

dt = getDType( x );
sh = getShape( x );
sh = getShape( x, true );
ord = getOrder( x );

ndims = sh.length;
Expand Down
4 changes: 2 additions & 2 deletions base/expand-dimensions/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ function expandDimensions( x, axis ) {
var N;
var i;

sh = getShape( x );
st = getStrides( x );
sh = getShape( x, false );
st = getStrides( x, false );
ord = getOrder( x );
N = sh.length;

Expand Down
2 changes: 1 addition & 1 deletion base/maybe-broadcast-array/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function maybeBroadcastArray( arr, shape ) {
var i;

N = shape.length;
sh = getShape( arr );
sh = getShape( arr, false );

// Check whether we need to broadcast the input array...
if ( sh.length === N ) {
Expand Down
4 changes: 2 additions & 2 deletions base/ndarraylike2object/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function ndarraylike2object( x ) {
var dt;

xbuf = getData( x );
sh = getShape( x );
sh = getShape( x, true );
dt = getDType( x );

bool = isAccessorArray( xbuf );
Expand All @@ -91,7 +91,7 @@ function ndarraylike2object( x ) {
'data': xbuf,
'length': numel( sh ),
'shape': sh,
'strides': getStrides( x ),
'strides': getStrides( x, true ),
'offset': getOffset( x ),
'order': getOrder( x ),
'accessorProtocol': bool,
Expand Down
14 changes: 10 additions & 4 deletions base/prepend-singleton-dimensions/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
// MODULES //

var isReadOnly = require( './../../../base/assert/is-read-only' );
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var getStrides = require( './../../../base/strides' );
var getOffset = require( './../../../base/offset' );
var getOrder = require( './../../../base/order' );
var getData = require( './../../../base/data-buffer' );


// MAIN //
Expand Down Expand Up @@ -67,8 +73,8 @@ function prependSingletonDimensions( x, n ) { // eslint-disable-line id-length
var N;
var i;

sh = x.shape;
st = x.strides;
sh = getShape( x, false );
st = getStrides( x, false );
N = sh.length;

strides = [];
Expand All @@ -86,11 +92,11 @@ function prependSingletonDimensions( x, n ) { // eslint-disable-line id-length
}
if ( isReadOnly( x ) ) {
// If provided a read-only view, the returned array should also be read-only...
return new x.constructor( x.dtype, x.data, shape, strides, x.offset, x.order, { // eslint-disable-line max-len
return new x.constructor( getDType( x ), getData( x ), shape, strides, getOffset( x ), getOrder( x ), { // eslint-disable-line max-len
'readonly': true
});
}
return new x.constructor( x.dtype, x.data, shape, strides, x.offset, x.order ); // eslint-disable-line max-len
return new x.constructor( getDType( x ), getData( x ), shape, strides, getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len
}


Expand Down
14 changes: 10 additions & 4 deletions base/remove-singleton-dimensions/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
// MODULES //

var isReadOnly = require( './../../../base/assert/is-read-only' );
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var getStrides = require( './../../../base/strides' );
var getOffset = require( './../../../base/offset' );
var getOrder = require( './../../../base/order' );
var getData = require( './../../../base/data-buffer' );


// MAIN //
Expand Down Expand Up @@ -73,8 +79,8 @@ function removeSingletonDimensions( x ) {
var N;
var i;

sh = x.shape;
st = x.strides;
sh = getShape( x, false );
st = getStrides( x, false );
N = sh.length;

strides = [];
Expand All @@ -93,11 +99,11 @@ function removeSingletonDimensions( x ) {
}
if ( isReadOnly( x ) ) {
// If provided a read-only view, the returned array should also be read-only...
return new x.constructor( x.dtype, x.data, shape, strides, x.offset, x.order, { // eslint-disable-line max-len
return new x.constructor( getDType( x ), getData( x ), shape, strides, getOffset( x ), getOrder( x ), { // eslint-disable-line max-len
'readonly': true
});
}
return new x.constructor( x.dtype, x.data, shape, strides, x.offset, x.order ); // eslint-disable-line max-len
return new x.constructor( getDType( x ), getData( x ), shape, strides, getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len
}


Expand Down
15 changes: 10 additions & 5 deletions base/serialize-meta-data/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ var bytesPerElement = require( './../../../base/bytes-per-element' );
var dtypes = require( './../../../dtypes' ).enum;
var orders = require( './../../../orders' ).enum;
var modes = require( './../../../index-modes' ).enum;
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var getStrides = require( './../../../base/strides' );
var getOffset = require( './../../../base/offset' );
var getOrder = require( './../../../base/order' );


// VARIABLES //
Expand Down Expand Up @@ -142,9 +147,9 @@ function serialize( x ) {
return x.__array_meta_dataview__(); // eslint-disable-line no-underscore-dangle
}
// Extract meta data known to be attached to ndarray-like objects:
dt = x.dtype;
sh = x.shape;
st = x.strides;
dt = getDType( x );
sh = getShape( x, false );
st = getStrides( x, false );
N = sh.length; // ndims

// Extract meta data which may be available on ndarray-like objects (e.g., stdlib ndarray instances):
Expand Down Expand Up @@ -183,11 +188,11 @@ function serialize( x ) {
}
// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)
o += s;
v.setBigInt64( o, BigInt( x.offset*nbytes ), IS_LITTLE_ENDIAN );
v.setBigInt64( o, BigInt( getOffset( x )*nbytes ), IS_LITTLE_ENDIAN );

// Order: (byteoffset: 19+(ndims*16); bytelength: 1)
o += 8;
v.setInt8( o, ORDERS[ x.order ] );
v.setInt8( o, ORDERS[ getOrder( x ) ] );

// Index mode: (byteoffset: 20+(ndims*16); bytelength: 1)
o += 1;
Expand Down
15 changes: 10 additions & 5 deletions base/serialize-meta-data/lib/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ var bytesPerElement = require( './../../../base/bytes-per-element' );
var dtypes = require( './../../../dtypes' ).enum;
var orders = require( './../../../orders' ).enum;
var modes = require( './../../../index-modes' ).enum;
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var getStrides = require( './../../../base/strides' );
var getOffset = require( './../../../base/offset' );
var getOrder = require( './../../../base/order' );


// VARIABLES //
Expand Down Expand Up @@ -145,9 +150,9 @@ function serialize( x ) {
return x.__array_meta_dataview__(); // eslint-disable-line no-underscore-dangle
}
// Extract meta data known to be attached to ndarray-like objects:
dt = x.dtype;
sh = x.shape;
st = x.strides;
dt = getDType( x);
sh = getShape( x, false );
st = getStrides( x, false );
N = sh.length; // ndims

// Extract meta data which may be available on ndarray-like objects (e.g., stdlib ndarray instances):
Expand Down Expand Up @@ -187,11 +192,11 @@ function serialize( x ) {
}
// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)
o += s;
float64ToInt64Bytes( x.offset*nbytes, bytes, 1, o );
float64ToInt64Bytes( getOffset( x )*nbytes, bytes, 1, o );

// Order: (byteoffset: 19+(ndims*16); bytelength: 1)
o += 8;
v.setInt8( o, ORDERS[ x.order ] );
v.setInt8( o, ORDERS[ getOrder( x ) ] );

// Index mode: (byteoffset: 20+(ndims*16); bytelength: 1)
o += 1;
Expand Down
8 changes: 5 additions & 3 deletions base/slice-assign/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var identity = require( '@stdlib/utils/identity-function' ); // TODO: remove onc
var castReturn = require( '@stdlib/complex/base/cast-return' );
var complexCtors = require( '@stdlib/complex/ctors' );
var slice = require( './../../../base/slice' );
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var format = require( '@stdlib/string/format' );


Expand Down Expand Up @@ -99,8 +101,8 @@ function sliceAssign( x, y, s, strict ) {
var xdt;
var ydt;

xdt = x.dtype;
ydt = y.dtype;
xdt = getDType( x );
ydt = getDType( y );

// Safe casts are always allowed...
if ( isSafeCast( xdt, ydt ) ) {
Expand All @@ -124,7 +126,7 @@ function sliceAssign( x, y, s, strict ) {
view = slice( y, s, strict, true );

// Broadcast the input array:
x = broadcast( x, view.shape );
x = broadcast( x, getShape( view, true ) );

// Set elements from `x` in `y`:
unary( [ x, view ], fcn );
Expand Down
22 changes: 14 additions & 8 deletions base/slice/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ var sliceShape = require( '@stdlib/slice/base/shape' );
var take = require( '@stdlib/array/base/take' );
var zeros = require( '@stdlib/array/base/zeros' );
var numel = require( './../../../base/numel' );
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var getStrides = require( './../../../base/strides' );
var getOffset = require( './../../../base/offset' );
var getOrder = require( './../../../base/order' );
var getData = require( './../../../base/data-buffer' );
var format = require( '@stdlib/string/format' );
var sliceStart = require( './slice_start.js' );
var slice2strides = require( './slice_strides.js' );
Expand Down Expand Up @@ -90,11 +96,11 @@ function slice( x, s, strict, writable ) {
var ns;

// Retrieve array meta data:
dtype = x.dtype;
shape = x.shape;
strides = x.strides;
offset = x.offset;
order = x.order;
dtype = getDType( x );
shape = getShape( x, true );
strides = getStrides( x, true );
offset = getOffset( x );
order = getOrder( x );
ndims = shape.length;

// Ensure that the number of array dimensions matches the number of slices:
Expand All @@ -106,7 +112,7 @@ function slice( x, s, strict, writable ) {

// If provided a zero-dimensional input array, return a zero-dimensional array view...
if ( ndims === 0 ) {
return new ctor( dtype, x.data, shape, strides, offset, order, {
return new ctor( dtype, getData( x ), shape, strides, offset, order, {
'readonly': !writable
});
}
Expand Down Expand Up @@ -147,15 +153,15 @@ function slice( x, s, strict, writable ) {

// If all dimensions were reduced, return a zero-dimensional array...
if ( sh.length === 0 ) {
return new ctor( dtype, x.data, [], [ 0 ], offset, order, {
return new ctor( dtype, getData( x ), [], [ 0 ], offset, order, {
'readonly': !writable
});
}
// Update strides according to slice steps:
strides = slice2strides( ns, strides, sdims ); // TODO: @stdlib/ndarray/base/slice2strides???

// Return a slice view:
return new ctor( dtype, x.data, sh, strides, offset, order, {
return new ctor( dtype, getData( x ), sh, strides, offset, order, {
'readonly': !writable
});
}
Expand Down
12 changes: 9 additions & 3 deletions base/transpose/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
// MODULES //

var strides2offset = require( './../../../base/strides2offset' );
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var getStrides = require( './../../../base/strides' );
var getOrder = require( './../../../base/order' );
var getData = require( './../../../base/data-buffer' );


// MAIN //
Expand Down Expand Up @@ -59,12 +64,12 @@ function transpose( x ) {
var st;
var N;

sh = x.shape; // WARNING: we assume that `sh` is a copy, which is true of `ndarray` instances!
sh = getShape( x, true );
N = sh.length;
if ( N < 2 ) {
throw new Error( 'invalid argument. Must provide an ndarray having two or more dimensions.' );
}
st = x.strides; // WARNING: we assume that `st` is a copy, which is true of `ndarray` instances!
st = getStrides( x, true );

tmp = sh[ N-2 ];
sh[ N-2 ] = sh[ N-1 ];
Expand All @@ -74,7 +79,8 @@ function transpose( x ) {
st[ N-2 ] = st[ N-1 ];
st[ N-1 ] = tmp;

return new x.constructor( x.dtype, x.data, sh, st, strides2offset( sh, st ), x.order ); // eslint-disable-line max-len
// FIXME: handling of offset seems incorrect. Should also handle READ-ONLY arrays.
return new x.constructor( getDType( x ), getData( x ), sh, st, strides2offset( sh, st ), getOrder( x ) ); // eslint-disable-line max-len
}


Expand Down
11 changes: 7 additions & 4 deletions base/zeros-like/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
var shape2strides = require( './../../../base/shape2strides' );
var strides2offset = require( './../../../base/strides2offset' );
var buffer = require( './../../../base/buffer' );
var format = require( '@stdlib/string/format' );
var numel = require( './../../../base/numel' );
var getDType = require( './../../../base/dtype' );
var getShape = require( './../../../base/shape' );
var getOrder = require( './../../../base/order' );
var format = require( '@stdlib/string/format' );


// MAIN //
Expand Down Expand Up @@ -60,9 +63,9 @@ function zerosLike( x ) {
var st;
var dt;

dt = x.dtype;
sh = x.shape;
ord = x.order;
dt = getDType( x );
sh = getShape( x, true );
ord = getOrder( x );

ndims = sh.length;
if ( ndims > 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit 4e784e7

Please sign in to comment.