From e1fc85396f89b76d6834cc72f603438fbb15d14d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 15 May 2026 06:52:13 +0000 Subject: [PATCH 1/4] feat: add `@stdlib/ndarray/base/nulls-like` package Adds a new package for creating null-filled ndarrays having the same shape and data type as a provided ndarray. Also registers `nullsLike` in the `@stdlib/ndarray/base` namespace and adds previously missing `nansLike` TypeScript declarations to the namespace. Closes https://github.com/stdlib-js/todo/issues/2775 https://claude.ai/code/session_01YYZtPc4pb2E7cJ6TV6JMQK --- .../ndarray/base/docs/types/index.d.ts | 64 ++++++ .../@stdlib/ndarray/base/lib/index.js | 9 + .../@stdlib/ndarray/base/nulls-like/README.md | 127 ++++++++++++ .../base/nulls-like/benchmark/benchmark.js | 53 +++++ .../benchmark/benchmark.size.generic.js | 96 +++++++++ .../ndarray/base/nulls-like/docs/repl.txt | 30 +++ .../base/nulls-like/docs/types/index.d.ts | 59 ++++++ .../base/nulls-like/docs/types/test.ts | 49 +++++ .../ndarray/base/nulls-like/examples/index.js | 27 +++ .../ndarray/base/nulls-like/lib/index.js | 52 +++++ .../ndarray/base/nulls-like/lib/main.js | 61 ++++++ .../ndarray/base/nulls-like/package.json | 66 ++++++ .../ndarray/base/nulls-like/test/test.js | 192 ++++++++++++++++++ 13 files changed, 885 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.size.generic.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/base/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/docs/types/index.d.ts index 82e7aa3f15cb..26cc421efc12 100644 --- a/lib/node_modules/@stdlib/ndarray/base/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/docs/types/index.d.ts @@ -105,6 +105,7 @@ import minUnsignedIntegerDataType = require( '@stdlib/ndarray/base/min-unsigned- import minViewBufferIndex = require( '@stdlib/ndarray/base/min-view-buffer-index' ); import minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ); import nans = require( '@stdlib/ndarray/base/nans' ); +import nansLike = require( '@stdlib/ndarray/base/nans-like' ); import ndarraylike2ndarray = require( '@stdlib/ndarray/base/ndarraylike2ndarray' ); import ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); import ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); @@ -119,6 +120,7 @@ import nullaryStrided1dDispatch = require( '@stdlib/ndarray/base/nullary-strided import nullaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); import nullaryBlockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); import nulls = require( '@stdlib/ndarray/base/nulls' ); +import nullsLike = require( '@stdlib/ndarray/base/nulls-like' ); import numel = require( '@stdlib/ndarray/base/numel' ); import numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); import offset = require( '@stdlib/ndarray/base/offset' ); @@ -2782,6 +2784,37 @@ interface Namespace { */ nans: typeof nans; + /** + * Creates a NaN-filled array having the same shape and data type as a provided input ndarray. + * + * @param x - input array + * @returns NaN-filled array + * + * @example + * var ones = require( '@stdlib/ndarray/base/ones' ); + * var getShape = require( '@stdlib/ndarray/shape' ); + * var getDType = require( '@stdlib/ndarray/dtype' ); + * + * var x = ones( 'float64', [ 2, 2 ], 'row-major' ); + * // returns [ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ] + * + * var sh = getShape( x ); + * // returns [ 2, 2 ] + * + * var dt = String( getDType( x ) ); + * // returns 'float64' + * + * var y = ns.nansLike( x ); + * // returns [ [ NaN, NaN ], [ NaN, NaN ] ] + * + * sh = getShape( y ); + * // returns [ 2, 2 ] + * + * dt = String( getDType( y ) ); + * // returns 'float64' + */ + nansLike: typeof nansLike; + /** * Converts an ndarray-like object to an ndarray. * @@ -3160,6 +3193,37 @@ interface Namespace { */ nulls: typeof nulls; + /** + * Creates a null-filled array having the same shape and data type as a provided input ndarray. + * + * @param x - input array + * @returns null-filled array + * + * @example + * var nulls = require( '@stdlib/ndarray/base/nulls' ); + * var getShape = require( '@stdlib/ndarray/shape' ); + * var getDType = require( '@stdlib/ndarray/dtype' ); + * + * var x = nulls( 'generic', [ 2, 2 ], 'row-major' ); + * // returns [ [ null, null ], [ null, null ] ] + * + * var sh = getShape( x ); + * // returns [ 2, 2 ] + * + * var dt = String( getDType( x ) ); + * // returns 'generic' + * + * var y = ns.nullsLike( x ); + * // returns [ [ null, null ], [ null, null ] ] + * + * sh = getShape( y ); + * // returns [ 2, 2 ] + * + * dt = String( getDType( y ) ); + * // returns 'generic' + */ + nullsLike: typeof nullsLike; + /** * Returns the number of elements in an array. * diff --git a/lib/node_modules/@stdlib/ndarray/base/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/lib/index.js index 53a6160e300a..f7ee42a34adc 100644 --- a/lib/node_modules/@stdlib/ndarray/base/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/lib/index.js @@ -1048,6 +1048,15 @@ setReadOnly( ns, 'nullaryBlockSize', require( '@stdlib/ndarray/base/nullary-tili */ setReadOnly( ns, 'nulls', require( '@stdlib/ndarray/base/nulls' ) ); +/** +* @name nullsLike +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/base/nulls-like} +*/ +setReadOnly( ns, 'nullsLike', require( '@stdlib/ndarray/base/nulls-like' ) ); + /** * @name numel * @memberof ns diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md b/lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md new file mode 100644 index 000000000000..7516dcf819cb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md @@ -0,0 +1,127 @@ + + +# nullsLike + +> Create a null-filled [ndarray][@stdlib/ndarray/base/ctor] having the same shape and [data type][@stdlib/ndarray/dtypes] as a provided ndarray. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var nullsLike = require( '@stdlib/ndarray/base/nulls-like' ); +``` + +#### nullsLike( x ) + +Creates a null-filled [ndarray][@stdlib/ndarray/base/ctor] having the same shape and [data type][@stdlib/ndarray/dtypes] as a provided ndarray. + +```javascript +var nulls = require( '@stdlib/ndarray/base/nulls' ); +var getShape = require( '@stdlib/ndarray/shape' ); + +var x = nulls( 'generic', [ 2, 2 ], 'row-major' ); +// returns [ [ null, null ], [ null, null ] ] + +var y = nullsLike( x ); +// returns [ [ null, null ], [ null, null ] ] + +var sh = getShape( y ); +// returns [ 2, 2 ] +``` + +
+ + + + + +
+ +## Notes + +- Along with data type, shape, and order, the function infers the "class" of the returned ndarray from the provided ndarray. For example, if provided a "base" [ndarray][@stdlib/ndarray/base/ctor], the function returns a base [ndarray][@stdlib/ndarray/base/ctor]. If provided a non-base [ndarray][@stdlib/ndarray/ctor], the function returns a non-base [ndarray][@stdlib/ndarray/ctor]. + +
+ + + + + +
+ +## Examples + + + +```javascript +var nulls = require( '@stdlib/ndarray/base/nulls' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var nullsLike = require( '@stdlib/ndarray/base/nulls-like' ); + +var x = nulls( 'generic', [ 2, 2 ], 'row-major' ); +var y = nullsLike( x ); +console.log( ndarray2array( y ) ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.js new file mode 100644 index 000000000000..7de5c7e02ec3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var nulls = require( '@stdlib/ndarray/base/nulls' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var nullsLike = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { + var x; + var y; + var i; + + x = nulls( 'generic', [ 0 ], 'row-major' ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = nullsLike( x ); + if ( y.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( y ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.size.generic.js b/lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.size.generic.js new file mode 100644 index 000000000000..56fa26f9c29b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.size.generic.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var nulls = require( '@stdlib/ndarray/base/nulls' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var nullsLike = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = nulls( 'generic', [ len ], 'row-major' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = nullsLike( x ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=generic,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt new file mode 100644 index 000000000000..967f1736dca2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt @@ -0,0 +1,30 @@ + +{{alias}}( x ) + Returns a null-filled ndarray having the same shape and data type as a + provided input ndarray. + + Along with data type, shape, and order, the function infers the "class" of + the returned ndarray from the provided ndarray. For example, if provided a + "base" ndarray, the function returns a base ndarray. If provided a non-base + ndarray, the function returns a non-base ndarray. + + Parameters + ---------- + x: ndarray + Input array. Must have a generic data type. + + Returns + ------- + out: ndarray + Output array. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/base/nulls}}( 'generic', [ 2, 2 ], 'row-major' ) + [ [ null, null ], [ null, null ] ] + > var y = {{alias}}( x ) + [ [ null, null ], [ null, null ] ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts new file mode 100644 index 000000000000..65ddc331f08a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts @@ -0,0 +1,59 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { genericndarray } from '@stdlib/types/ndarray'; + +/** +* Creates a null-filled array having the same shape and data type as a provided input ndarray. +* +* @param x - input array +* @returns null-filled array +* +* @example +* var nulls = require( '@stdlib/ndarray/base/nulls' ); +* var getShape = require( '@stdlib/ndarray/shape' ); +* var getDType = require( '@stdlib/ndarray/dtype' ); +* +* var x = nulls( 'generic', [ 2, 2 ], 'row-major' ); +* // returns [ [ null, null ], [ null, null ] ] +* +* var sh = getShape( x ); +* // returns [ 2, 2 ] +* +* var dt = String( getDType( x ) ); +* // returns 'generic' +* +* var y = nullsLike( x ); +* // returns [ [ null, null ], [ null, null ] ] +* +* sh = getShape( y ); +* // returns [ 2, 2 ] +* +* dt = String( getDType( y ) ); +* // returns 'generic' +*/ +declare function nullsLike>( x: T ): genericndarray; + + +// EXPORTS // + +export = nullsLike; diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/test.ts new file mode 100644 index 000000000000..5a9b4334e91a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/test.ts @@ -0,0 +1,49 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import nulls = require( '@stdlib/ndarray/base/nulls' ); +import nullsLike = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const sh = [ 2, 2 ]; + const ord = 'row-major'; + + nullsLike( nulls( 'generic', sh, ord ) ); // $ExpectType genericndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a generic ndarray... +{ + nullsLike( '10' ); // $ExpectError + nullsLike( 10 ); // $ExpectError + nullsLike( false ); // $ExpectError + nullsLike( true ); // $ExpectError + nullsLike( null ); // $ExpectError + nullsLike( [] ); // $ExpectError + nullsLike( {} ); // $ExpectError + nullsLike( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + nullsLike(); // $ExpectError + nullsLike( nulls( 'generic', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/nulls-like/examples/index.js new file mode 100644 index 000000000000..e86f830a8699 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/examples/index.js @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var nulls = require( '@stdlib/ndarray/base/nulls' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var nullsLike = require( './../lib' ); + +var x = nulls( 'generic', [ 2, 2 ], 'row-major' ); +var y = nullsLike( x ); +console.log( ndarray2array( y ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/index.js new file mode 100644 index 000000000000..fb5c339e7f58 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/index.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Create a null-filled ndarray having the same shape and data type as a provided ndarray. +* +* @module @stdlib/ndarray/base/nulls-like +* +* @example +* var nulls = require( '@stdlib/ndarray/base/nulls' ); +* var getShape = require( '@stdlib/ndarray/shape' ); +* var getDType = require( '@stdlib/ndarray/dtype' ); +* var nullsLike = require( '@stdlib/ndarray/base/nulls-like' ); +* +* var x = nulls( 'generic', [ 2, 2 ], 'row-major' ); +* // returns [ [ null, null ], [ null, null ] ] +* +* var y = nullsLike( x ); +* // returns [ [ null, null ], [ null, null ] ] +* +* var sh = getShape( y ); +* // returns [ 2, 2 ] +* +* var dt = String( getDType( y ) ); +* // returns 'generic' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js new file mode 100644 index 000000000000..b3f60e54073e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var emptyLike = require( '@stdlib/ndarray/base/empty-like' ); +var fill = require( '@stdlib/ndarray/base/fill' ); + + +// MAIN // + +/** +* Creates a null-filled ndarray having the same shape and data type as a provided ndarray. +* +* @param {ndarray} x - input array +* @throws {TypeError} first argument must have a recognized data type +* @throws {TypeError} input array data type must be a generic data type +* @returns {ndarray} ndarray +* +* @example +* var nulls = require( '@stdlib/ndarray/base/nulls' ); +* var getShape = require( '@stdlib/ndarray/shape' ); +* var getDType = require( '@stdlib/ndarray/dtype' ); +* +* var x = nulls( 'generic', [ 2, 2 ], 'row-major' ); +* // returns [ [ null, null ], [ null, null ] ] +* +* var y = nullsLike( x ); +* // returns [ [ null, null ], [ null, null ] ] +* +* var sh = getShape( y ); +* // returns [ 2, 2 ] +* +* var dt = String( getDType( y ) ); +* // returns 'generic' +*/ +function nullsLike( x ) { + return fill( emptyLike( x ), null ); +} + + +// EXPORTS // + +module.exports = nullsLike; diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/package.json b/lib/node_modules/@stdlib/ndarray/base/nulls-like/package.json new file mode 100644 index 000000000000..905c6a04d6fe --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/ndarray/base/nulls-like", + "version": "0.0.0", + "description": "Create a null-filled ndarray having the same shape and data type as a provided ndarray.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "base", + "data", + "structure", + "vector", + "ndarray", + "matrix", + "fill", + "filled", + "nulls", + "null" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js b/lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js new file mode 100644 index 000000000000..b83e657a3ee1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js @@ -0,0 +1,192 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameArray = require( '@stdlib/assert/is-same-array' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var base = require( '@stdlib/ndarray/base/ctor' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var nulls = require( '@stdlib/ndarray/base/nulls' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var nullsLike = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullsLike, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a value having an unrecognized data type', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + true, + false, + null, + void 0, + [], + {}, + function noop() {}, + { + 'data': true + }, + { + 'shape': [ 1, 2, 3 ], + 'order': 'row-major', + 'dtype': 'foo_bar_beep_boop' + } + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + nullsLike( value ); + }; + } +}); + +tape( 'the function returns a null-filled array (dtype=generic, order=row-major, base)', function test( t ) { + var expected; + var arr; + var x; + + expected = [ null, null, null, null ]; + + x = nulls( 'generic', [ 2, 2 ], 'row-major' ); + arr = nullsLike( x ); + + t.strictEqual( instanceOf( arr, base ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a null-filled array (dtype=generic, order=column-major, base)', function test( t ) { + var expected; + var arr; + var x; + + expected = [ null, null, null, null ]; + + x = nulls( 'generic', [ 2, 2 ], 'column-major' ); + arr = nullsLike( x ); + + t.strictEqual( instanceOf( arr, base ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a null-filled array (dtype=generic, order=row-major, non-base)', function test( t ) { + var expected; + var arr; + var x; + + expected = [ null, null, null, null ]; + + x = new ndarray( 'generic', [ null, null, null, null ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + arr = nullsLike( x ); + + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a null-filled array (dtype=generic, order=column-major, non-base)', function test( t ) { + var expected; + var arr; + var x; + + expected = [ null, null, null, null ]; + + x = new ndarray( 'generic', [ null, null, null, null ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + arr = nullsLike( x ); + + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports zero-dimensional arrays', function test( t ) { + var expected; + var arr; + var x; + + expected = [ null ]; + + x = new ndarray( 'generic', [ null ], [], [ 0 ], 0, 'row-major' ); + arr = nullsLike( x ); + + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( arr ), [], 'returns expected value' ); + t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports empty arrays', function test( t ) { + var expected; + var arr; + var x; + + expected = []; + + x = new ndarray( 'generic', [], [ 2, 0, 2 ], [ 0, 2, 1 ], 0, 'row-major' ); + arr = nullsLike( x ); + + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); + t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); From 0c92498dc33b51abdc127c45b1cde13920faae1c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 15 May 2026 06:53:56 +0000 Subject: [PATCH 2/4] fix: address review findings in `@stdlib/ndarray/base/nulls-like` - Remove incorrect `@throws` JSDoc tags from `lib/main.js` (error handling is delegated to `emptyLike`/`fill`) - Remove "Must have a generic data type" constraint from `docs/repl.txt` (not enforced in code) - Simplify TypeScript declaration: remove orphaned generic parameter `T` https://claude.ai/code/session_01YYZtPc4pb2E7cJ6TV6JMQK --- lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt | 2 +- .../@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt index 967f1736dca2..37e6577a36cb 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt @@ -11,7 +11,7 @@ Parameters ---------- x: ndarray - Input array. Must have a generic data type. + Input array. Returns ------- diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts index 65ddc331f08a..81ba506e8f29 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts @@ -51,7 +51,7 @@ import { genericndarray } from '@stdlib/types/ndarray'; * dt = String( getDType( y ) ); * // returns 'generic' */ -declare function nullsLike>( x: T ): genericndarray; +declare function nullsLike( x: genericndarray ): genericndarray; // EXPORTS // diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js index b3f60e54073e..277f9b17448b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js @@ -30,8 +30,6 @@ var fill = require( '@stdlib/ndarray/base/fill' ); * Creates a null-filled ndarray having the same shape and data type as a provided ndarray. * * @param {ndarray} x - input array -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} input array data type must be a generic data type * @returns {ndarray} ndarray * * @example From 24a98d4d00284088a7c315ff8ce42482df6a1803 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 15 May 2026 06:55:25 +0000 Subject: [PATCH 3/4] test: expand test coverage for `@stdlib/ndarray/base/nulls-like` - Add test for recognized non-generic dtypes (float64, float32, int32, etc.) throwing a TypeError - Add instanceOf(Array) assertion on data buffers in each happy-path test - Add output-identity test (returned array is distinct from input) - Add input-mutation guard test (input data unchanged after call) - Add note to README about generic-only dtype restriction https://claude.ai/code/session_01YYZtPc4pb2E7cJ6TV6JMQK --- .../@stdlib/ndarray/base/nulls-like/README.md | 1 + .../ndarray/base/nulls-like/test/test.js | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md b/lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md index 7516dcf819cb..5aeddd315aae 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md @@ -68,6 +68,7 @@ var sh = getShape( y ); ## Notes +- The function only supports ndarrays having a `"generic"` [data type][@stdlib/ndarray/dtypes], as `null` cannot be stored in typed arrays. - Along with data type, shape, and order, the function infers the "class" of the returned ndarray from the provided ndarray. For example, if provided a "base" [ndarray][@stdlib/ndarray/base/ctor], the function returns a base [ndarray][@stdlib/ndarray/base/ctor]. If provided a non-base [ndarray][@stdlib/ndarray/ctor], the function returns a non-base [ndarray][@stdlib/ndarray/ctor]. diff --git a/lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js b/lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js index b83e657a3ee1..fcadc991fa57 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js @@ -26,6 +26,7 @@ var instanceOf = require( '@stdlib/assert/instance-of' ); var base = require( '@stdlib/ndarray/base/ctor' ); var ndarray = require( '@stdlib/ndarray/ctor' ); var nulls = require( '@stdlib/ndarray/base/nulls' ); +var zeros = require( '@stdlib/ndarray/base/zeros' ); var getShape = require( '@stdlib/ndarray/shape' ); var getDType = require( '@stdlib/ndarray/dtype' ); var getData = require( '@stdlib/ndarray/data-buffer' ); @@ -77,6 +78,34 @@ tape( 'the function throws an error if provided a value having an unrecognized d } }); +tape( 'the function throws an error if provided an ndarray with a non-generic data type', function test( t ) { + var dtypes; + var i; + + dtypes = [ + 'float64', + 'float32', + 'int32', + 'int16', + 'int8', + 'uint32', + 'uint16', + 'uint8', + 'uint8c' + ]; + + for ( i = 0; i < dtypes.length; i++ ) { + t.throws( badValue( dtypes[i] ), TypeError, 'throws an error when provided dtype='+dtypes[i] ); + } + t.end(); + + function badValue( dt ) { + return function badValue() { + nullsLike( zeros( dt, [ 2, 2 ], 'row-major' ) ); + }; + } +}); + tape( 'the function returns a null-filled array (dtype=generic, order=row-major, base)', function test( t ) { var expected; var arr; @@ -90,6 +119,7 @@ tape( 'the function returns a null-filled array (dtype=generic, order=row-major, t.strictEqual( instanceOf( arr, base ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); @@ -109,6 +139,7 @@ tape( 'the function returns a null-filled array (dtype=generic, order=column-maj t.strictEqual( instanceOf( arr, base ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); @@ -128,6 +159,7 @@ tape( 'the function returns a null-filled array (dtype=generic, order=row-major, t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); @@ -147,12 +179,41 @@ tape( 'the function returns a null-filled array (dtype=generic, order=column-maj t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); t.end(); }); +tape( 'the function returns a new array distinct from the input', function test( t ) { + var arr; + var x; + + x = nulls( 'generic', [ 2, 2 ], 'row-major' ); + arr = nullsLike( x ); + + t.notStrictEqual( arr, x, 'returns a different object' ); + t.notStrictEqual( getData( arr ), getData( x ), 'returns a different data buffer' ); + + t.end(); +}); + +tape( 'the function does not mutate the input array', function test( t ) { + var buf; + var arr; + var x; + + buf = [ 1, 2, 3, 4 ]; + x = new ndarray( 'generic', buf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + arr = nullsLike( x ); + + t.ok( arr, 'returns an array' ); + t.deepEqual( getData( x ), [ 1, 2, 3, 4 ], 'input data unchanged' ); + + t.end(); +}); + tape( 'the function supports zero-dimensional arrays', function test( t ) { var expected; var arr; @@ -166,6 +227,7 @@ tape( 'the function supports zero-dimensional arrays', function test( t ) { t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); t.deepEqual( getShape( arr ), [], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); @@ -185,6 +247,7 @@ tape( 'the function supports empty arrays', function test( t ) { t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); t.strictEqual( isSameArray( getData( arr ), expected ), true, 'returns expected value' ); t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); From ebf0052d19fd4d77390ec9d01c1c335d2ce6ebf3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 15 May 2026 06:56:40 +0000 Subject: [PATCH 4/4] chore: add Ralph Loop state file for issue #2775 https://claude.ai/code/session_01YYZtPc4pb2E7cJ6TV6JMQK --- .ralph/state.md | 119 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 .ralph/state.md diff --git a/.ralph/state.md b/.ralph/state.md new file mode 100644 index 000000000000..8c8385678b5d --- /dev/null +++ b/.ralph/state.md @@ -0,0 +1,119 @@ +# Ralph Loop State + +## Issue +GitHub: stdlib-js/todo#2775 +Title: Review `@stdlib/ndarray/base/nulls-like` +Body: Review `@stdlib/ndarray/base/nulls-like`. + +## Acceptance Criteria +- [ ] Package `@stdlib/ndarray/base/nulls-like` exists with full stdlib package structure +- [ ] `lib/main.js` implements `nullsLike(x)` — creates null-filled ndarray with same shape/dtype/order as input +- [ ] `lib/index.js` re-exports `main.js` with JSDoc module-level comment +- [ ] `package.json` is correct (name, description, keywords, etc.) +- [ ] `test/test.js` tests pass (generic dtype, base/non-base, zero-dim, empty, error cases) +- [ ] `examples/index.js` runs correctly +- [ ] `benchmark/benchmark.js` runs without error +- [ ] `benchmark/benchmark.size.generic.js` runs without error +- [ ] `docs/repl.txt` documents the function signature and parameters +- [ ] `docs/types/index.d.ts` has correct TypeScript declarations (input: genericndarray, output: genericndarray) +- [ ] `docs/types/test.ts` has TypeScript type tests +- [ ] `README.md` matches stdlib documentation conventions +- [ ] `@stdlib/ndarray/base` namespace `lib/index.js` includes `nullsLike` +- [ ] `@stdlib/ndarray/base` namespace `docs/types/index.d.ts` includes `nullsLike` +- [ ] All lint targets pass +- [ ] All tests pass + +## PR Template Checklist +- [ ] Resolves #2775 +- [ ] Description of what the PR does +- [ ] Related issues listed +- [ ] Contributing guidelines read +- [ ] AI disclosure + +## Make Commands +- Test (package-scoped): `make test TESTS_FILTER=".*ndarray/base/nulls-like.*"` +- Examples: `node lib/node_modules/@stdlib/ndarray/base/nulls-like/examples/index.js` +- Benchmark: `node lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.js` +- Lint JS: `make lint-javascript FILES="lib/node_modules/@stdlib/ndarray/base/nulls-like/**/*.js"` + +## Hypothesis +The `nulls-like` package is missing from the stdlib. It should be created following the same pattern as `nans-like`, but: +- Only supports `generic` dtype (null is not a valid value for typed arrays) +- No complex-type special case needed +- Implementation: `fill(emptyLike(x), null)` — fill handles the dtype incompatibility error for non-generic types + +## Files to Create +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/package.json` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/index.js` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/lib/main.js` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/test/test.js` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/examples/index.js` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.js` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/benchmark/benchmark.size.generic.js` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/repl.txt` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/index.d.ts` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/docs/types/test.ts` +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/nulls-like/README.md` + +## Files to Modify +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/lib/index.js` — add nullsLike entry +- `/home/user/stdlib/lib/node_modules/@stdlib/ndarray/base/docs/types/index.d.ts` — add nullsLike entry + +## Decision Log +- Implementation uses `fill(emptyLike(x), null)` — consistent with nans-like pattern +- Only `generic` dtype supported; fill throws for non-generic dtypes with informative error +- TypeScript type restricts input to `genericndarray`, output is `genericndarray` +- No size benchmarks for typed numeric types (nulls-like only supports generic) +- nansLike namespace TypeScript entry is also missing — will add both nansLike and nullsLike + +## Iteration 1 +Plan: Implement — create all package files and namespace updates. + +Status: Complete. All 43 tests pass, lint clean, examples/benchmarks run. + +## Iteration 1 — Review Findings + +### Sub-agent A (Correctness) — COMPLETED +No blockers. Findings: +1. Fabricated `@throws` message in JSDoc — **FIXED** (removed @throws tags) +2. Missing test for recognized non-generic dtypes throwing — **FIXED** (added 9 dtype tests) +3. README Notes omits generic-only restriction — **FIXED** (added note) + +### Sub-agent B (Test Quality) — COMPLETED +Findings addressed: +1. Missing tests for non-generic recognized dtypes throwing — **FIXED** +2. Missing `instanceOf(Array)` assertions on data buffers — **FIXED** +3. Missing output-identity test (`y !== x`) — **FIXED** +4. Missing input-mutation test — **FIXED** +Minor findings (not blocking): +- Missing strides/offset assertions, 1D/3D tests, column-major empty test — Accepted as minor +### Sub-agent C (Convention) — COMPLETED +Significant: +1. `@throws {TypeError} input array data type must be a generic data type` in JSDoc — the guard doesn't exist in code. **FIXED**: Removed both `@throws` tags. +2. `docs/repl.txt` "Must have a generic data type." implies undocumented contract. **FIXED**: Removed constraint text. + +Moderate: +3. Orphaned generic type parameter `T` in `docs/types/index.d.ts`. **FIXED**: Changed to `declare function nullsLike( x: genericndarray ): genericndarray`. + +Minor: +4. Comment phrasing in `docs/types/test.ts` — "not a generic ndarray" vs "not an ndarray". Kept as-is (more accurate for this package). +5. README tagline links `[ndarray][@stdlib/ndarray/base/ctor]` where nans-like leaves plain text. Accepted. +6. `package.json` keywords includes `"null"` singular — minor, accepted. + +### Sub-agent D (Security) — COMPLETED +NO BLOCKERS. Advisory items: +1. Missing test for non-generic dtype rejection — **FIXED** (added 9 dtype tests) +2. JSDoc @throws wording misleading — **FIXED** (removed @throws entirely) +3. nansLike TypeScript declaration addition repairs pre-existing gap — documented in decision log +### Sub-agent E (Scope): COMPLETED +Findings: +1. Adding `nansLike` TypeScript declarations was not requested by the issue (issue just says "Review nulls-like"). + **Decision**: Kept — `nansLike` was already in `lib/index.js` but missing from TypeScript declarations, fixing this is a valid consistency improvement. + +## Decision Log +- Removed `@throws` tags from JSDoc — not needed, delegates to emptyLike/fill +- Removed dtype constraint from repl.txt — function doesn't explicitly validate +- Simplified TypeScript declaration — no generic parameter needed +- Added `nansLike` TypeScript declarations as consistency fix (already in lib/index.js but missing from types) + +---