From 5fb249b3631ca11fae4dbe4bae7ce953d5d83b2b Mon Sep 17 00:00:00 2001 From: LokeshRanjan Date: Wed, 24 Dec 2025 12:39:06 +0530 Subject: [PATCH 1/2] docs: improve doctests for ndarray instances in ndarray/count-Truthy --- 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: 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: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/count-truthy/README.md | 27 ++++--------------- .../ndarray/count-truthy/docs/repl.txt | 12 ++------- .../count-truthy/docs/types/index.d.ts | 20 +++----------- .../ndarray/count-truthy/lib/assign.js | 5 +--- .../@stdlib/ndarray/count-truthy/lib/index.js | 10 ++----- .../@stdlib/ndarray/count-truthy/lib/main.js | 5 +--- 6 files changed, 15 insertions(+), 64 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/count-truthy/README.md b/lib/node_modules/@stdlib/ndarray/count-truthy/README.md index dc2055189810..edf22cc1ef9e 100644 --- a/lib/node_modules/@stdlib/ndarray/count-truthy/README.md +++ b/lib/node_modules/@stdlib/ndarray/count-truthy/README.md @@ -49,10 +49,7 @@ var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] ); // Perform reduction: var out = countTruthy( x ); -// returns - -var v = out.get(); -// returns 5 +// returns [ 5 ] ``` The function accepts the following arguments: @@ -69,7 +66,6 @@ By default, the function performs a reduction over all elements in a provided [` ```javascript var array = require( '@stdlib/ndarray/array' ); -var ndarray2array = require( '@stdlib/ndarray/to-array' ); // Create an input ndarray: var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] ); @@ -79,17 +75,13 @@ var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] ); var out = countTruthy( x, { 'dims': [ 1, 2 ] }); -// returns - -var v = ndarray2array( out ); -// returns [ 2, 2, 1 ] +// returns [ 2, 2, 1 ] ``` By default, the function returns an [`ndarray`][@stdlib/ndarray/ctor] having a shape matching only the non-reduced dimensions of the input [`ndarray`][@stdlib/ndarray/ctor] (i.e., the reduced dimensions are dropped). To include the reduced dimensions as singleton dimensions in the output [`ndarray`][@stdlib/ndarray/ctor], set the `keepdims` option to `true`. ```javascript var array = require( '@stdlib/ndarray/array' ); -var ndarray2array = require( '@stdlib/ndarray/to-array' ); // Create an input ndarray: var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] ); @@ -100,10 +92,7 @@ var out = countTruthy( x, { 'dims': [ 1, 2 ], 'keepdims': true }); -// returns - -var v = ndarray2array( out ); -// returns [ [ [ 2 ] ], [ [ 2 ] ], [ [ 1 ] ] ] +// returns [ [ [ 2 ] ], [ [ 2 ] ], [ [ 1 ] ] ] ``` #### countTruthy.assign( x, out\[, options] ) @@ -125,13 +114,10 @@ var y = empty( [], { // Perform reduction: var out = countTruthy.assign( x, y ); -// returns +// returns [ 5 ] var bool = ( out === y ); // returns true - -var v = y.get(); -// returns 5 ``` The function accepts the following arguments: @@ -149,7 +135,6 @@ By default, the function performs a reduction over all elements in a provided [` ```javascript var array = require( '@stdlib/ndarray/array' ); var empty = require( '@stdlib/ndarray/empty' ); -var ndarray2array = require( '@stdlib/ndarray/to-array' ); // Create an input ndarray: var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] ); @@ -164,12 +149,10 @@ var y = empty( [ 3 ], { var out = countTruthy.assign( x, y, { 'dims': [ 1, 2 ] }); +// returns [ 2, 2, 1 ] var bool = ( out === y ); // returns true - -var v = ndarray2array( y ); -// returns [ 2, 2, 1 ] ``` diff --git a/lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt index 09180e53384c..3a0d93474aed 100644 --- a/lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt @@ -33,11 +33,7 @@ > y.get() 3 > y = {{alias}}( x, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ 3 ] ] - > y.get( 0, 0 ) - 3 + [ [ 3 ] ] {{alias}}.assign( x, y[, options] ) @@ -71,11 +67,7 @@ > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 1.0 ], [ 0.0, 1.0 ] ] ); > var y = {{alias:@stdlib/ndarray/from-scalar}}( 0, { 'dtype': 'int32' } ); > var out = {{alias}}.assign( x, y ) - - > var bool = ( out === y ) - true - > y.get() - 3 + [ 3 ] See Also -------- diff --git a/lib/node_modules/@stdlib/ndarray/count-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/count-truthy/docs/types/index.d.ts index e5312a075cf7..09a2798d1b81 100644 --- a/lib/node_modules/@stdlib/ndarray/count-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/count-truthy/docs/types/index.d.ts @@ -77,10 +77,7 @@ interface CountTruthy { * * // Perform reduction: * var out = countTruthy( x ); - * // returns - * - * var v = out.get(); - * // returns 5 + * // returns [ 5 ] */ ( x: ndarray, options?: Options ): int32ndarray; // FIXME: update once `int64` dtype support; may require adding support for an output `dtype` option @@ -120,10 +117,7 @@ interface CountTruthy { * * // Perform reduction: * var out = countTruthy.assign( x, y ); - * // returns - * - * var v = out.get(); - * // returns 5 + * // returns [ 5 ] */ assign( x: ndarray, y: T, options?: BaseOptions ): T; } @@ -158,10 +152,7 @@ interface CountTruthy { * * // Perform reduction: * var out = countTruthy( x ); -* // returns -* -* var v = out.get(); -* // returns 5 +* // returns [ 5 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -190,10 +181,7 @@ interface CountTruthy { * * // Perform reduction: * var out = countTruthy.assign( x, y ); -* // returns -* -* var v = out.get(); -* // returns 5 +* // returns [ 5 ] */ declare var countTruthy: CountTruthy; diff --git a/lib/node_modules/@stdlib/ndarray/count-truthy/lib/assign.js b/lib/node_modules/@stdlib/ndarray/count-truthy/lib/assign.js index c9cc0e7b10c4..91028bd92c52 100644 --- a/lib/node_modules/@stdlib/ndarray/count-truthy/lib/assign.js +++ b/lib/node_modules/@stdlib/ndarray/count-truthy/lib/assign.js @@ -73,10 +73,7 @@ var validate = require( './validate.js' ); * * // Perform reduction: * var out = assign( x, y ); -* // returns -* -* var v = out.get(); -* // returns 5 +* // returns [ 5 ] */ function assign( x, y, options ) { var opts; diff --git a/lib/node_modules/@stdlib/ndarray/count-truthy/lib/index.js b/lib/node_modules/@stdlib/ndarray/count-truthy/lib/index.js index 69e40244946a..5690828b82a7 100644 --- a/lib/node_modules/@stdlib/ndarray/count-truthy/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/count-truthy/lib/index.js @@ -45,10 +45,7 @@ * * // Perform reduction: * var out = countTruthy( x ); -* // returns -* -* var v = out.get(); -* // returns 5 +* // returns [ 5 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -78,10 +75,7 @@ * * // Perform reduction: * var out = countTruthy.assign( x, y ); -* // returns -* -* var v = out.get(); -* // returns 5 +* // returns [ 5 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/ndarray/count-truthy/lib/main.js b/lib/node_modules/@stdlib/ndarray/count-truthy/lib/main.js index dc3d70cd5aeb..475c3c6722b6 100644 --- a/lib/node_modules/@stdlib/ndarray/count-truthy/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/count-truthy/lib/main.js @@ -79,10 +79,7 @@ var DEFAULT_DTYPE = defaults.get( 'dtypes.integer_index' ); * * // Perform reduction: * var out = countTruthy( x ); -* // returns -* -* var v = out.get(); -* // returns 5 +* // returns [ 5 ] */ function countTruthy( x, options ) { var opts; From 8f0611a07b2a841447278653c63960288bff3b27 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 24 Dec 2025 14:24:00 -0800 Subject: [PATCH 2/2] docs: update example Signed-off-by: Athan --- lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt index 3a0d93474aed..e97aa171785a 100644 --- a/lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt @@ -68,6 +68,8 @@ > var y = {{alias:@stdlib/ndarray/from-scalar}}( 0, { 'dtype': 'int32' } ); > var out = {{alias}}.assign( x, y ) [ 3 ] + > var bool = ( out === y ) + true See Also --------