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 Feb 13, 2024
1 parent aa47e20 commit 17dc074
Show file tree
Hide file tree
Showing 95 changed files with 7,803 additions and 843 deletions.
2 changes: 1 addition & 1 deletion base/bifurcate-entries-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var cnt = context.count;

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var bifurcateEntriesBy = require( '@stdlib/array/base/bifurcate-entries-by' );

function predicate( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-entries-by/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var bifurcateEntriesBy = require( './../lib' );

function predicate( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-entries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var out = bifurcateEntries( x, filter );

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var bifurcateEntries = require( '@stdlib/array/base/bifurcate-entries' );

// Define an initial array of values:
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-entries/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var bifurcateEntries = require( './../lib' );

// Define an initial array of values:
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-indices-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var cnt = context.count;

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var bifurcateIndicesBy = require( '@stdlib/array/base/bifurcate-indices-by' );

function predicate( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-indices-by/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var bifurcateIndicesBy = require( './../lib' );

function predicate( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-indices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var out = bifurcateIndices( x, filter );

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var bifurcateIndices = require( '@stdlib/array/base/bifurcate-indices' );

// Define an initial array of values:
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-indices/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var bifurcateIndices = require( './../lib' );

// Define an initial array of values:
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-values-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var cnt = context.count;

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var bifurcateValuesBy = require( '@stdlib/array/base/bifurcate-values-by' );

function predicate( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-values-by/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var bifurcateValuesBy = require( './../lib' );

function predicate( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-values/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var out = bifurcateValues( x, filter );

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var bifurcateValues = require( '@stdlib/array/base/bifurcate-values' );

// Define an initial array of values:
Expand Down
2 changes: 1 addition & 1 deletion base/bifurcate-values/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var bifurcateValues = require( './../lib' );

// Define an initial array of values:
Expand Down
7 changes: 7 additions & 0 deletions base/fancy-slice-assign/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
// MODULES //

var isMostlySafeCast = require( './../../../base/assert/is-mostly-safe-data-type-cast' );
var isRealDataType = require( './../../../base/assert/is-real-data-type' );
var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' );
var normalizeSlice = require( '@stdlib/slice/base/normalize-slice' );
var sliceLength = require( '@stdlib/slice/base/length' );
var dtype = require( './../../../dtype' );
var convert = require( './../../../convert' );
var gcopy = require( '@stdlib/blas/base/gcopy' ).ndarray;
var format = require( '@stdlib/string/format' );

Expand Down Expand Up @@ -92,6 +95,10 @@ function sliceAssign( x, y, s, strict ) {
if ( !isMostlySafeCast( xdt, ydt ) ) {
throw new TypeError( format( 'invalid argument. Input array values cannot be safely cast to the output array data type. Data types: [%s, %s].', xdt, ydt ) );
}
// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...
if ( isComplexDataType( ydt ) && isRealDataType( xdt ) ) {
x = convert( x, ydt );
}
// Normalize the slice object base on the output array length:
ns = normalizeSlice( s, ylen, true );

Expand Down
128 changes: 117 additions & 11 deletions base/fancy-slice-assign/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
// MODULES //

var tape = require( 'tape' );
var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' );
var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' );
var AccessorArray = require( './../../../base/accessor' );
var Float64Array = require( './../../../float64' );
var Float32Array = require( './../../../float32' );
var Complex128Array = require( './../../../complex128' );
var Complex64Array = require( './../../../complex64' );
var Int32Array = require( './../../../int32' );
var zeros = require( './../../../zeros' );
var Slice = require( '@stdlib/slice/ctor' );
Expand Down Expand Up @@ -261,15 +266,15 @@ tape( 'the function performs slice assignment with support for broadcasting (flo
t.deepEqual( actual, expected, 'returns expected value' );

x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
y = zeros( 3, 'float64' );
y = zeros( 3, 'float32' ); // downcast

expected = new Float64Array( [ 3.0, 2.0, 1.0 ] );
expected = new Float32Array( [ 3.0, 2.0, 1.0 ] );
actual = sliceAssign( x, y, new Slice( null, null, -1 ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.deepEqual( actual, expected, 'returns expected value' );

x = new Float64Array( [ 1, 3 ] );
x = new Float64Array( [ 1.0, 3.0 ] );
y = zeros( 3, 'float64' );

expected = new Float64Array( [ 3.0, 0.0, 1.0 ] );
Expand All @@ -278,16 +283,16 @@ tape( 'the function performs slice assignment with support for broadcasting (flo
t.strictEqual( actual, y, 'returns expected value' );
t.deepEqual( actual, expected, 'returns expected value' );

x = new Float64Array( [ 1, 3 ] );
y = zeros( 3, 'float64' );
x = new Float64Array( [ 1.0, 3.0 ] );
y = zeros( 3, 'float32' ); // downcast

expected = new Float64Array( [ 1.0, 0.0, 3.0 ] );
expected = new Float32Array( [ 1.0, 0.0, 3.0 ] );
actual = sliceAssign( x, y, new Slice( null, null, 2 ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.deepEqual( actual, expected, 'returns expected value' );

x = new Float64Array( [ 2, 3 ] );
x = new Float64Array( [ 2.0, 3.0 ] );
y = zeros( 3, 'float64' );

expected = new Float64Array( [ 0.0, 2.0, 3.0 ] );
Expand All @@ -296,7 +301,7 @@ tape( 'the function performs slice assignment with support for broadcasting (flo
t.strictEqual( actual, y, 'returns expected value' );
t.deepEqual( actual, expected, 'returns expected value' );

x = new Float64Array( [ 2 ] );
x = new Float64Array( [ 2.0 ] );
y = zeros( 3, 'float64' );

expected = new Float64Array( [ 0.0, 2.0, 0.0 ] );
Expand All @@ -305,7 +310,7 @@ tape( 'the function performs slice assignment with support for broadcasting (flo
t.strictEqual( actual, y, 'returns expected value' );
t.deepEqual( actual, expected, 'returns expected value' );

x = new Float64Array( [ 1 ] );
x = new Float64Array( [ 1.0 ] );
y = zeros( 3, 'float64' );

expected = new Float64Array( [ 0.0, 0.0, 0.0 ] );
Expand All @@ -315,7 +320,7 @@ tape( 'the function performs slice assignment with support for broadcasting (flo
t.deepEqual( actual, expected, 'returns expected value' );

// Broadcasting:
x = new Float64Array( [ 1 ] );
x = new Float64Array( [ 1.0 ] );
y = zeros( 3, 'float64' );

expected = new Float64Array( [ 1.0, 1.0, 1.0 ] );
Expand All @@ -324,7 +329,7 @@ tape( 'the function performs slice assignment with support for broadcasting (flo
t.strictEqual( actual, y, 'returns expected value' );
t.deepEqual( actual, expected, 'returns expected value' );

x = new Float64Array( [ 3 ] );
x = new Float64Array( [ 3.0 ] );
y = zeros( 3, 'float64' );

expected = new Float64Array( [ 3.0, 0.0, 3.0 ] );
Expand All @@ -333,6 +338,107 @@ tape( 'the function performs slice assignment with support for broadcasting (flo
t.strictEqual( actual, y, 'returns expected value' );
t.deepEqual( actual, expected, 'returns expected value' );

// Upcasting:
x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
y = zeros( 3, 'complex128' );

expected = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] );
actual = sliceAssign( x, y, new Slice(), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' );

t.end();
});

tape( 'the function performs slice assignment with support for broadcasting (complex128)', function test( t ) {
var expected;
var actual;
var x;
var y;

x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
y = zeros( 3, 'complex128' );

expected = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
actual = sliceAssign( x, y, new Slice(), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' );

x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
y = zeros( 3, 'complex128' );

expected = new Complex128Array( [ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] );
actual = sliceAssign( x, y, new Slice( null, null, -1 ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' );

x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] );
y = zeros( 3, 'complex64' ); // downcast

expected = new Complex64Array( [ 3.0, 4.0, 0.0, 0.0, 1.0, 2.0 ] );
actual = sliceAssign( x, y, new Slice( null, null, -2 ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' );

x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] );
y = zeros( 3, 'complex128' );

expected = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0 ] );
actual = sliceAssign( x, y, new Slice( null, null, 2 ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' );

x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] );
y = zeros( 3, 'complex128' );

expected = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] );
actual = sliceAssign( x, y, new Slice( 1, null ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' );

x = new Complex128Array( [ 1.0, 2.0 ] );
y = zeros( 3, 'complex64' ); // downcast

expected = new Complex64Array( [ 0.0, 0.0, 1.0, 2.0, 0.0, 0.0 ] );
actual = sliceAssign( x, y, new Slice( 1, y.length-1 ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' );

x = new Complex128Array( [ 1.0, 2.0 ] );
y = zeros( 3, 'complex128' );

expected = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
actual = sliceAssign( x, y, new Slice( 1, 1 ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' );

// Broadcasting:
x = new Complex128Array( [ 1.0, 2.0 ] );
y = zeros( 3, 'complex128' );

expected = new Complex128Array( [ 1.0, 2.0, 1.0, 2.0, 1.0, 2.0 ] );
actual = sliceAssign( x, y, new Slice(), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' );

x = new Complex128Array( [ 3.0, 4.0 ] );
y = zeros( 3, 'complex64' ); // downcast

expected = new Complex64Array( [ 3.0, 4.0, 0.0, 0.0, 3.0, 4.0 ] );
actual = sliceAssign( x, y, new Slice( null, null, 2 ), false );

t.strictEqual( actual, y, 'returns expected value' );
t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' );

t.end();
});

Expand Down
2 changes: 1 addition & 1 deletion base/group-entries-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var cnt = context.count;

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var groupEntriesBy = require( '@stdlib/array/base/group-entries-by' );
function indicator( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/group-entries-by/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var groupEntriesBy = require( './../lib' );

function indicator( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/group-entries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ var out = groupEntries( x, groups );

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var groupEntries = require( '@stdlib/array/base/group-entries' );
// Define an initial array of values:
Expand Down
2 changes: 1 addition & 1 deletion base/group-entries/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var groupEntries = require( './../lib' );

// Define an initial array of values:
Expand Down
2 changes: 1 addition & 1 deletion base/group-indices-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var cnt = context.count;

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var groupIndicesBy = require( '@stdlib/array/base/group-indices-by' );
function indicator( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/group-indices-by/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( './../../../base/take' );
var take = require( './../../../base/take-indexed' );
var groupIndicesBy = require( './../lib' );

function indicator( v ) {
Expand Down
2 changes: 1 addition & 1 deletion base/group-indices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ var out = groupIndices( x, groups );

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var take = require( '@stdlib/array/base/take' );
var take = require( '@stdlib/array/base/take-indexed' );
var groupIndices = require( '@stdlib/array/base/group-indices' );
// Define an initial array of values:
Expand Down
Loading

0 comments on commit 17dc074

Please sign in to comment.