Skip to content

Commit 7b69002

Browse files
committed
feat: ensure support for non-string dtypes and update tests to use functional accessors
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 4794f9e commit 7b69002

8 files changed

Lines changed: 217 additions & 141 deletions

File tree

lib/node_modules/@stdlib/ndarray/base/from-scalar/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,19 @@ var scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' );
4242

4343
#### scalar2ndarray( value, dtype, order )
4444

45-
Returns a zero-dimensional [`ndarray`][@stdlib/ndarray/base/ctor] containing a provided scalar `value` and having a specified [data type][@stdlib/ndarray/dtypes].
45+
Returns a zero-dimensional [ndarray][@stdlib/ndarray/base/ctor] containing a provided scalar `value` and having a specified [data type][@stdlib/ndarray/dtypes].
4646

4747
```javascript
48+
var getShape = require( '@stdlib/ndarray/shape' );
49+
var getDType = require( '@stdlib/ndarray/dtype' );
50+
4851
var x = scalar2ndarray( 1.0, 'float64', 'row-major' );
4952
// returns <ndarray>
5053

51-
var sh = x.shape;
54+
var sh = getShape( x );
5255
// returns []
5356

54-
var dt = x.dtype;
57+
var dt = String( getDType( x ) );
5558
// returns 'float64'
5659

5760
var v = x.get();
@@ -68,7 +71,7 @@ var v = x.get();
6871

6972
## Notes
7073

71-
- If `value` is a number and [`dtype`][@stdlib/ndarray/dtypes] is a complex [data type][@stdlib/ndarray/dtypes], the function returns a zero-dimensional [`ndarray`][@stdlib/ndarray/base/ctor] containing a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero.
74+
- If `value` is a number and [`dtype`][@stdlib/ndarray/dtypes] is a complex [data type][@stdlib/ndarray/dtypes], the function returns a zero-dimensional [ndarray][@stdlib/ndarray/base/ctor] containing a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero.
7275

7376
</section>
7477

@@ -87,7 +90,7 @@ var dtypes = require( '@stdlib/ndarray/dtypes' );
8790
var scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' );
8891

8992
// Get a list of data types:
90-
var dt = dtypes();
93+
var dt = dtypes( 'integer_and_generic' );
9194

9295
// Generate zero-dimensional arrays...
9396
var x;

lib/node_modules/@stdlib/ndarray/base/from-scalar/docs/repl.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
value: any
1313
Scalar value.
1414

15-
dtype: string
15+
dtype: string|DataType
1616
Data type.
1717

1818
order: string
@@ -27,10 +27,8 @@
2727
--------
2828
> var x = {{alias}}( 1.0, 'float64', 'row-major' )
2929
<ndarray>
30-
> var sh = x.shape
30+
> var sh = {{alias:@stdlib/ndarray/shape}}( x )
3131
[]
32-
> var dt = x.dtype
33-
'float64'
3432
> var v = x.get()
3533
1.0
3634

0 commit comments

Comments
 (0)