Skip to content

Commit 647e0b1

Browse files
committed
refactor: use scalar assign utility
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - 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: na - task: lint_license_headers status: passed ---
1 parent af91b63 commit 647e0b1

File tree

1 file changed

+5
-6
lines changed
  • lib/node_modules/@stdlib/ndarray/base/fill/lib

1 file changed

+5
-6
lines changed

lib/node_modules/@stdlib/ndarray/base/fill/lib/main.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
// MODULES //
2222

2323
var isScalarMostlySafeCompatible = require( '@stdlib/ndarray/base/assert/is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length
24-
var broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' );
24+
var scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' );
2525
var getDType = require( '@stdlib/ndarray/base/dtype' );
26-
var getShape = require( '@stdlib/ndarray/base/shape' );
2726
var getOrder = require( '@stdlib/ndarray/base/order' );
28-
var assign = require( '@stdlib/ndarray/base/assign' );
27+
var assign = require( '@stdlib/ndarray/base/assign-scalar' );
2928
var format = require( '@stdlib/string/format' );
3029

3130

@@ -61,11 +60,11 @@ function fill( x, value ) {
6160
if ( !isScalarMostlySafeCompatible( value, dt ) ) {
6261
throw new TypeError( format( 'invalid argument. The second argument cannot be safely cast to the input array data type. Data type: %s. Value: `%s`.', dt, value ) );
6362
}
64-
// Broadcast the fill value to an ndarray of same shape and data type as the input ndarray:
65-
v = broadcastScalar( value, dt, getShape( x ), getOrder( x ) );
63+
// Convert the fill value to an ndarray having the same data type as the input ndarray:
64+
v = scalar2ndarray( value, dt, getOrder( x ) );
6665

6766
// Assign the fill value to each element of the input ndarray:
68-
assign( [ v, x ] ); // TODO: consider replacing with ndarray/base/assign-scalar in order to avoid zero-dimensional ndarray creation and subsequent broadcasting
67+
assign( [ v, x ] );
6968

7069
return x;
7170
}

0 commit comments

Comments
 (0)