Skip to content

Commit 1a77f53

Browse files
committed
Auto-generated commit
1 parent e01af87 commit 1a77f53

File tree

11 files changed

+68
-71
lines changed

11 files changed

+68
-71
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,8 @@ A total of 45 issues were closed in this release:
817817

818818
<details>
819819

820+
- [`b9709d8`](https://github.com/stdlib-js/stdlib/commit/b9709d8608a4cbfc6e5af6f293e5263708ae3430) - **test:** use accessors to resolve ndarray meta data _(by Athan Reines)_
821+
- [`24fe5a1`](https://github.com/stdlib-js/stdlib/commit/24fe5a1e1528667d2229445b1d9e5b4116225509) - **test:** explicitly serialize return value to a string _(by Athan Reines)_
820822
- [`a73a430`](https://github.com/stdlib-js/stdlib/commit/a73a430f8cf1e69a6bda08d1a4441b8985ef56ec) - **refactor:** improve type specificity _(by Athan Reines)_
821823
- [`7ab721b`](https://github.com/stdlib-js/stdlib/commit/7ab721ba37db35ef62c6b658ba6ddeef4f8bff64) - **test:** use accessor functions for accessing ndarray meta data _(by Athan Reines)_
822824
- [`1c769c9`](https://github.com/stdlib-js/stdlib/commit/1c769c983b0a4197ba30c9372568e03af00e9c00) - **test:** use accessors for retrieving ndarray meta data _(by Athan Reines)_

base/min-signed-integer-dtype/test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ tape( 'the function returns the minimum ndarray data type for storing a provided
6969
];
7070
for ( i = 0; i < values.length; i++ ) {
7171
actual = minSignedIntegerDataType( values[i] );
72-
t.strictEqual( actual, expected[ i ], 'returns expected value when provided '+values[i] );
72+
t.strictEqual( String( actual ), expected[ i ], 'returns expected value when provided '+values[i] );
7373
}
7474
t.end();
7575
});

base/min-unsigned-integer-dtype/test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ tape( 'the function returns the minimum ndarray data type for storing a provided
5959
];
6060
for ( i = 0; i < values.length; i++ ) {
6161
actual = minUnsignedIntegerDataType( values[i] );
62-
t.strictEqual( actual, expected[ i ], 'returns expected value when provided '+values[i] );
62+
t.strictEqual( String( actual ), expected[ i ], 'returns expected value when provided '+values[i] );
6363
}
6464
t.end();
6565
});

base/ndarraylike2ndarray/README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var array = require( '@stdlib/ndarray/array' );
4949

5050
var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] );
5151
var out = ndarraylike2ndarray( arr );
52-
// returns <ndarray>
52+
// returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
5353
```
5454

5555
</section>
@@ -73,24 +73,32 @@ var out = ndarraylike2ndarray( arr );
7373
<!-- eslint no-undef: "error" -->
7474

7575
```javascript
76+
var getDType = require( '@stdlib/ndarray/dtype' );
77+
var getShape = require( '@stdlib/ndarray/shape' );
78+
var getStrides = require( '@stdlib/ndarray/strides' );
79+
var getOffset = require( '@stdlib/ndarray/offset' );
80+
var getOrder = require( '@stdlib/ndarray/order' );
7681
var array = require( '@stdlib/ndarray/array' );
82+
var numel = require( '@stdlib/ndarray/numel' );
83+
var ndims = require( '@stdlib/ndarray/ndims' );
84+
var join = require( '@stdlib/array/base/join' );
7785
var ndarraylike2ndarray = require( '@stdlib/ndarray/base/ndarraylike2ndarray' );
7886

7987
// Create an ndarray:
8088
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
8189

8290
// Convert to a "base" ndarray:
8391
var out = ndarraylike2ndarray( x );
84-
// returns <ndarray>
92+
// returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
8593

8694
// Print various properties:
87-
console.log( 'dtype: %s', out.dtype );
88-
console.log( 'ndims: %d', out.shape.length );
89-
console.log( 'length: %d', out.length );
90-
console.log( 'shape: [ %s ]', out.shape.join( ', ' ) );
91-
console.log( 'strides: [ %s ]', out.strides.join( ', ' ) );
92-
console.log( 'offset: %d', out.offset );
93-
console.log( 'order: %s', out.order );
95+
console.log( 'dtype: %s', getDType( out ) );
96+
console.log( 'ndims: %d', ndims( out ) );
97+
console.log( 'length: %d', numel( out ) );
98+
console.log( 'shape: [ %s ]', join( getShape( out ), ', ' ) );
99+
console.log( 'strides: [ %s ]', join( getStrides( out ), ', ' ) );
100+
console.log( 'offset: %d', getOffset( out ) );
101+
console.log( 'order: %s', getOrder( out ) );
94102
```
95103

96104
</section>

base/ndarraylike2ndarray/benchmark/benchmark.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var Float64Array = require( '@stdlib/array/float64' );
2525
var ndarrayBase = require( './../../../base/ctor' );
2626
var ndarray = require( './../../../ctor' );
2727
var isCollection = require( '@stdlib/assert/is-collection' );
28+
var getData = require( './../../../data-buffer' );
2829
var format = require( '@stdlib/string/format' );
2930
var pkg = require( './../package.json' ).name;
3031
var ndarraylike2ndarray = require( './../lib' );
@@ -66,7 +67,7 @@ bench( format( '%s::base_ndarray', pkg ), function benchmark( b ) {
6667
}
6768
}
6869
b.toc();
69-
if ( !isCollection( out.data ) ) {
70+
if ( !isCollection( getData( out ) ) ) {
7071
b.fail( 'should return a collection' );
7172
}
7273
b.pass( 'benchmark finished' );
@@ -107,7 +108,7 @@ bench( format( '%s::ndarray', pkg ), function benchmark( b ) {
107108
}
108109
}
109110
b.toc();
110-
if ( !isCollection( out.data ) ) {
111+
if ( !isCollection( getData( out ) ) ) {
111112
b.fail( 'should return a collection' );
112113
}
113114
b.pass( 'benchmark finished' );
@@ -154,7 +155,7 @@ bench( format( '%s::ndarray_like', pkg ), function benchmark( b ) {
154155
}
155156
}
156157
b.toc();
157-
if ( !isCollection( out.data ) ) {
158+
if ( !isCollection( getData( out ) ) ) {
158159
b.fail( 'should return a collection' );
159160
}
160161
b.pass( 'benchmark finished' );

base/ndarraylike2ndarray/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
--------
1717
> var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] );
1818
> var out = {{alias}}( arr )
19-
<ndarray>
19+
<ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
2020

2121
See Also
2222
--------

base/ndarraylike2ndarray/docs/types/test.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,15 @@
1616
* limitations under the License.
1717
*/
1818

19-
/// <reference types="@stdlib/types"/>
20-
21-
import { typedndarray } from '@stdlib/types/ndarray';
19+
import zeros = require( './../../../../zeros' );
2220
import ndarraylike2ndarray = require( './index' );
2321

24-
/**
25-
* Mock function to create an ndarray-like object.
26-
*
27-
* @returns ndarray-like object
28-
*/
29-
function array(): typedndarray<number> {
30-
const obj: typedndarray<number> = {
31-
'byteLength': 80,
32-
'BYTES_PER_ELEMENT': 8,
33-
'data': new Float64Array( 10 ),
34-
'dtype': 'float64',
35-
'flags': {
36-
'ROW_MAJOR_CONTIGUOUS': true,
37-
'COLUMN_MAJOR_CONTIGUOUS': false
38-
},
39-
'length': 10,
40-
'ndims': 1,
41-
'offset': 0,
42-
'order': 'row-major',
43-
'shape': [ 10 ],
44-
'strides': [ 1 ],
45-
'get': (): number => 0,
46-
'set': (): typedndarray<number> => obj
47-
};
48-
return obj;
49-
}
50-
5122

5223
// TESTS //
5324

5425
// The function returns an ndarray...
5526
{
56-
const x = array();
27+
const x = zeros( [ 2, 2 ] );
5728
ndarraylike2ndarray( x ); // $ExpectType typedndarray<number>
5829
}
5930

@@ -71,7 +42,7 @@ function array(): typedndarray<number> {
7142

7243
// The compiler throws an error if the function is provided an unsupported number of arguments...
7344
{
74-
const x = array();
45+
const x = zeros( [ 2, 2 ] );
7546
ndarraylike2ndarray(); // $ExpectError
7647
ndarraylike2ndarray( x, 5 ); // $ExpectError
7748
}

base/ndarraylike2ndarray/examples/index.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,29 @@
1818

1919
'use strict';
2020

21+
var getDType = require( './../../../dtype' );
22+
var getShape = require( './../../../shape' );
23+
var getStrides = require( './../../../strides' );
24+
var getOffset = require( './../../../offset' );
25+
var getOrder = require( './../../../order' );
2126
var array = require( './../../../array' );
27+
var numel = require( './../../../numel' );
28+
var ndims = require( './../../../ndims' );
29+
var join = require( '@stdlib/array/base/join' );
2230
var ndarraylike2ndarray = require( './../lib' );
2331

2432
// Create an ndarray:
2533
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
2634

2735
// Convert to a "base" ndarray:
2836
var out = ndarraylike2ndarray( x );
29-
// returns <ndarray>
37+
// returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
3038

3139
// Print various properties:
32-
console.log( 'dtype: %s', out.dtype );
33-
console.log( 'ndims: %d', out.shape.length );
34-
console.log( 'length: %d', out.length );
35-
console.log( 'shape: [ %s ]', out.shape.join( ', ' ) );
36-
console.log( 'strides: [ %s ]', out.strides.join( ', ' ) );
37-
console.log( 'offset: %d', out.offset );
38-
console.log( 'order: %s', out.order );
40+
console.log( 'dtype: %s', getDType( out ) );
41+
console.log( 'ndims: %d', ndims( out ) );
42+
console.log( 'length: %d', numel( out ) );
43+
console.log( 'shape: [ %s ]', join( getShape( out ), ', ' ) );
44+
console.log( 'strides: [ %s ]', join( getStrides( out ), ', ' ) );
45+
console.log( 'offset: %d', getOffset( out ) );
46+
console.log( 'order: %s', getOrder( out ) );

base/ndarraylike2ndarray/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] );
3131
*
3232
* var out = ndarraylike2ndarray( x );
33-
* // returns <ndarray>
33+
* // returns <ndarray>[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
3434
*/
3535

3636
// MODULES //

base/ndarraylike2ndarray/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var DEFAULT_ORDER = defaults( 'order' );
5555
* var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] );
5656
*
5757
* var out = ndarraylike2ndarray( x );
58-
* // returns <ndarray>
58+
* // returns <ndarray>[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
5959
*/
6060
function ndarraylike2ndarray( x ) {
6161
return new ndarray( getDType( x ), getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) || DEFAULT_ORDER ); // eslint-disable-line max-len

0 commit comments

Comments
 (0)