Skip to content

Commit b311738

Browse files
committed
Auto-generated commit
1 parent 92f575b commit b311738

25 files changed

+2630
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Features
1212

13+
- [`e00d73a`](https://github.com/stdlib-js/stdlib/commit/e00d73a3cb8c5355a46771ed5630d178e25ec0f4) - add `onesLike` to namespace
14+
- [`d200536`](https://github.com/stdlib-js/stdlib/commit/d200536a79672d3a31022f894a63acdf08b79159) - add `ndarray/base/ones-like`
1315
- [`baef022`](https://github.com/stdlib-js/stdlib/commit/baef0223f86db141fa6a1dabc15ec6c5fa2f0f59) - update `ndarray/base` TypeScript declarations [(#11131)](https://github.com/stdlib-js/stdlib/pull/11131)
1416
- [`91e532c`](https://github.com/stdlib-js/stdlib/commit/91e532cf02003c24e6ee03c0d60d24b32169df4e) - add `ones` to namespace
1517
- [`78bcb59`](https://github.com/stdlib-js/stdlib/commit/78bcb5902c6120dfcf9e8472a6ce8c3d4f61968f) - add `ndarray/base/ones`
@@ -805,6 +807,9 @@ A total of 44 issues were closed in this release:
805807

806808
<details>
807809

810+
- [`e00d73a`](https://github.com/stdlib-js/stdlib/commit/e00d73a3cb8c5355a46771ed5630d178e25ec0f4) - **feat:** add `onesLike` to namespace _(by Athan Reines)_
811+
- [`d200536`](https://github.com/stdlib-js/stdlib/commit/d200536a79672d3a31022f894a63acdf08b79159) - **feat:** add `ndarray/base/ones-like` _(by Athan Reines)_
812+
- [`60e78d4`](https://github.com/stdlib-js/stdlib/commit/60e78d484b31ca96b47f36c260db2620bd40f555) - **docs:** update `ndarray` TypeScript declarations [(#11132)](https://github.com/stdlib-js/stdlib/pull/11132) _(by stdlib-bot)_
808813
- [`baef022`](https://github.com/stdlib-js/stdlib/commit/baef0223f86db141fa6a1dabc15ec6c5fa2f0f59) - **feat:** update `ndarray/base` TypeScript declarations [(#11131)](https://github.com/stdlib-js/stdlib/pull/11131) _(by stdlib-bot)_
809814
- [`ae72f8e`](https://github.com/stdlib-js/stdlib/commit/ae72f8e7910cbfd1a0204bedd7f46bff23c74aa0) - **test:** use corrected expected type for `complex64` tests _(by Athan Reines)_
810815
- [`2a1517f`](https://github.com/stdlib-js/stdlib/commit/2a1517fe8ee92381e9db01cab5f99241c542a6fc) - **test:** use correct expected type in complex64 tests for `ndarray/base/ones` _(by Philipp Burckhardt)_

base/lib/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,15 @@ setReadOnly( ns, 'offset', require( './../../base/offset' ) );
967967
*/
968968
setReadOnly( ns, 'ones', require( './../../base/ones' ) );
969969

970+
/**
971+
* @name onesLike
972+
* @memberof ns
973+
* @readonly
974+
* @type {Function}
975+
* @see {@link module:@stdlib/ndarray/base/ones-like}
976+
*/
977+
setReadOnly( ns, 'onesLike', require( './../../base/ones-like' ) );
978+
970979
/**
971980
* @name order
972981
* @memberof ns

base/ones-like/README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2026 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# onesLike
22+
23+
> Create a ones-filled ndarray having the same shape and [data type][@stdlib/ndarray/dtypes] as a provided ndarray.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var onesLike = require( '@stdlib/ndarray/base/ones-like' );
41+
```
42+
43+
#### onesLike( x )
44+
45+
Creates a ones-filled ndarray having the same shape and [data type][@stdlib/ndarray/dtypes] as a provided ndarray.
46+
47+
```javascript
48+
var getShape = require( '@stdlib/ndarray/shape' );
49+
var ones = require( '@stdlib/ndarray/base/ones' );
50+
51+
var x = ones( 'float64', [ 2, 2 ], 'row-major' );
52+
// returns <ndarray>[ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ]
53+
54+
var y = onesLike( x );
55+
// returns <ndarray>[ [ 1.0, 1.0 ], [ 1.0, 1.0 ] ]
56+
57+
var sh = getShape( y );
58+
// returns [ 2, 2 ]
59+
```
60+
61+
</section>
62+
63+
<!-- /.usage -->
64+
65+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
66+
67+
<section class="notes">
68+
69+
## Notes
70+
71+
- 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].
72+
73+
</section>
74+
75+
<!-- /.notes -->
76+
77+
<!-- Package usage examples. -->
78+
79+
<section class="examples">
80+
81+
## Examples
82+
83+
<!-- eslint no-undef: "error" -->
84+
85+
```javascript
86+
var dtypes = require( '@stdlib/ndarray/dtypes' );
87+
var ones = require( '@stdlib/ndarray/base/ones' );
88+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
89+
var onesLike = require( '@stdlib/ndarray/base/ones-like' );
90+
91+
// Get a list of data types:
92+
var dt = dtypes( 'integer_and_generic' );
93+
94+
// Generate ones-filled arrays...
95+
var x;
96+
var i;
97+
for ( i = 0; i < dt.length; i++ ) {
98+
x = onesLike( ones( dt[ i ], [ 2, 2 ], 'row-major' ) );
99+
console.log( ndarray2array( x ) );
100+
}
101+
```
102+
103+
</section>
104+
105+
<!-- /.examples -->
106+
107+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
108+
109+
<section class="references">
110+
111+
</section>
112+
113+
<!-- /.references -->
114+
115+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
116+
117+
<section class="related">
118+
119+
</section>
120+
121+
<!-- /.related -->
122+
123+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
124+
125+
<section class="links">
126+
127+
[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray/tree/main/base/ctor
128+
129+
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray/tree/main/ctor
130+
131+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
132+
133+
</section>
134+
135+
<!-- /.links -->

0 commit comments

Comments
 (0)