Skip to content

Commit 5c2ca2e

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into ndarray-base-binary-reduce-strided1d-dispatch
2 parents 73da28b + dbc0f86 commit 5c2ca2e

File tree

701 files changed

+34069
-1069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

701 files changed

+34069
-1069
lines changed

.github/workflows/pr_commands_comment.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ on:
2929
description: 'Pull request number'
3030
required: true
3131
type: number
32+
debug:
33+
description: 'Enable debug output'
34+
required: false
35+
default: false
36+
type: boolean
3237

3338
# Define the secrets accessible by the workflow:
3439
secrets:
@@ -43,6 +48,14 @@ on:
4348
description: 'Pull request number'
4449
required: true
4550
type: number
51+
debug:
52+
description: 'Enable debug output'
53+
required: false
54+
default: 'false'
55+
type: choice
56+
options:
57+
- 'true'
58+
- 'false'
4659

4760
# Global permissions:
4861
permissions:
@@ -63,11 +76,23 @@ jobs:
6376

6477
# Define the sequence of job steps...
6578
steps:
79+
# Checkout the repository:
80+
- name: 'Checkout repository'
81+
# Pin action to full length commit SHA
82+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
83+
with:
84+
# Ensure we have access to the scripts directory:
85+
sparse-checkout: |
86+
.github/workflows/scripts
87+
sparse-checkout-cone-mode: false
88+
timeout-minutes: 10
6689

6790
# Leave comment with package make command instructions:
6891
- name: 'Leave comment with package make command instructions'
6992
env:
7093
PR_NUMBER: ${{ inputs.pull_request_number }}
94+
GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN || secrets.STDLIB_BOT_PAT_REPO_WRITE }}
95+
DEBUG: ${{ inputs.debug || 'false' }}
7196
run: |
7297
. "$GITHUB_WORKSPACE/.github/workflows/scripts/package_commands_comment" "$PR_NUMBER"
7398
timeout-minutes: 30

.github/workflows/scripts/package_commands_comment

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
# Environment variables:
2828
#
2929
# GITHUB_TOKEN GitHub token for authentication.
30+
# DEBUG Whether to enable verbose debug output. Default: `false`.
3031

3132
# Ensure that the exit status of pipelines is non-zero in the event that at least one of the commands in a pipeline fails:
3233
set -o pipefail
@@ -44,9 +45,22 @@ github_api_url="https://api.github.com"
4445
repo_owner="stdlib-js"
4546
repo_name="stdlib"
4647

48+
# Set debug mode:
49+
debug="${DEBUG:-false}"
50+
4751

4852
# FUNCTIONS #
4953

54+
# Prints debug messages if DEBUG environment variable is set to "true".
55+
#
56+
# $1 - debug message
57+
debug_log() {
58+
# Only print debug messages if DEBUG environment variable is set to "true":
59+
if [ "$debug" = true ]; then
60+
echo "[DEBUG] $1" >&2
61+
fi
62+
}
63+
5064
# Error handler.
5165
#
5266
# $1 - error status
@@ -70,6 +84,8 @@ github_api() {
7084
local endpoint="$2"
7185
local data="$3"
7286

87+
debug_log "Making API request: ${method} ${endpoint}"
88+
7389
# Initialize an array to hold curl headers:
7490
local headers=()
7591

@@ -117,12 +133,20 @@ main() {
117133
on_error 1
118134
fi
119135

136+
debug_log "Processing PR #${pr_number}"
137+
120138
# Fetch changed files in pull request:
121139
response=$(github_api "GET" "/repos/${repo_owner}/${repo_name}/pulls/${pr_number}/files?per_page=100")
122140
files=$(echo "${response}" | jq -r '.[] | .filename')
141+
debug_log "Found $(echo "${files}" | wc -l) changed files"
123142

124143
# Extract files associated with native add-ons:
125-
c_files=$(echo "${files}" | grep -e '/benchmark/c' -e '/examples/c' -e '/binding.gyp' -e '/include.gypi' -e '/src/')
144+
c_files=$(echo "${files}" | grep -e '/benchmark/c' -e '/examples/c' -e '/binding.gyp' -e '/include.gypi' -e '/src/' || true)
145+
if [[ -z "${c_files}" ]]; then
146+
debug_log "No native add-on files found"
147+
else
148+
debug_log "Found native add-on files: $(echo "${c_files}" | wc -l) files"
149+
fi
126150

127151
# Find unique package directories:
128152
directories=$(echo "${files}" | tr ' ' '\n' | \
@@ -133,6 +157,7 @@ main() {
133157

134158
# Extract package names from changed package directories (e.g., @stdlib/math/base/special/sin) by removing the leading 'lib/node_modules/':
135159
packages=$(echo "${directories}" | sed -E 's/^lib\/node_modules\///')
160+
debug_log "Found packages: $(echo "${packages}" | tr '\n' ' ')"
136161

137162
# Documentation links:
138163
docs_links="
@@ -148,9 +173,11 @@ main() {
148173

149174
# Count the number of packages:
150175
package_count=$(echo "${packages}" | wc -l)
176+
debug_log "Package count: ${package_count}"
151177

152178
if [[ $package_count -gt 1 ]]; then
153179
# Multiple packages case:
180+
debug_log "Multiple packages detected, generating multi-package comment"
154181
comment="Hello! 👋
155182
156183
Pro-tip: This PR changes multiple packages. You can use various \`make\` rules with \`*_FILTER\` environment variables to run tests, benchmarks, and examples for specific packages.
@@ -174,7 +201,9 @@ ${docs_links}"
174201

175202
else
176203
# Single package case:
177-
if [[ "${#c_files[@]}" -eq 0 ]]; then
204+
debug_log "Single package detected: ${packages}"
205+
if [[ -z "${c_files}" ]]; then
206+
debug_log "No C files found, generating JS-only comment"
178207
comment="Hello! 👋
179208
180209
Pro-tip: Use the \`make\` commands below during local development to ensure that all tests, examples, and benchmark files in your PR run successfully.
@@ -200,6 +229,7 @@ make examples EXAMPLES_FILTER=\".*/${packages}/.*\"
200229
\`\`\`
201230
${docs_links}"
202231
else
232+
debug_log "C files found, generating native addon comment"
203233
comment="Hello! 👋
204234
205235
Pro-tip: Use the \`make\` below commands during local development to ensure that all tests, examples, and benchmark files in your PR run successfully.
@@ -241,10 +271,12 @@ ${docs_links}"
241271
fi
242272
fi
243273

274+
debug_log "Posting comment on PR #${pr_number}"
244275
if ! github_api "POST" "/repos/${repo_owner}/${repo_name}/issues/${pr_number}/comments" "{\"body\":$(echo "${comment}" | jq -R -s -c .)}"; then
245276
echo "Failed to post comment on PR."
246277
on_error 1
247278
fi
279+
debug_log "Successfully posted comment on PR #${pr_number}"
248280

249281
print_success
250282
exit 0

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ Sivam Das <[email protected]>
189189
Snehil Shah <[email protected]>
190190
Soumajit Chatterjee <[email protected]>
191191
Spandan Barve <[email protected]>
192+
Srinivas Batthula <[email protected]>
192193
Stephannie Jiménez Gacha <[email protected]>
193194
Suhaib Ilahi <[email protected]>
194195
Suraj Kumar <[email protected]>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
type: amend-message
3+
---
4+
feat: add constants to `float64` namespace
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
type: amend-message
3+
---
4+
feat: add `planck` distribution namespace

lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var join = require( 'path' ).join;
2626
var format = require( 'util' ).format;
2727
var dirname = require( 'path' ).dirname;
2828
var logger = require( 'debug' );
29+
var rootDir = require( '@stdlib/_tools/utils/root-dir' );
2930
var Buffer = require( '@stdlib/buffer/ctor' );
3031
var isNull = require( '@stdlib/assert/is-null' );
3132
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
@@ -43,6 +44,7 @@ var windowShim = require( './window.js' );
4344
// VARIABLES //
4445

4546
var debug = logger( 'doctest' );
47+
var ROOT_DIR = rootDir();
4648
var RE_JSDOC = /\/\*\*[\s\S]+?\*\//g;
4749
var RE_ESLINT_INLINE = / ?\/\/ eslint-disable-(?:next-)?line[^\n]*\n/g;
4850
var RE_NEWLINE = /\r?\n/g;
@@ -137,9 +139,16 @@ function main( context ) {
137139
* @returns {*} required module
138140
*/
139141
function customRequire( path ) {
142+
var stdlibPath;
143+
140144
if ( startsWith( path, './' ) ) {
141145
return require( join( dir, path ) ); // eslint-disable-line stdlib/no-dynamic-require
142146
}
147+
// Force `@stdlib` packages to be loaded from `lib/node_modules/@stdlib`:
148+
if ( startsWith( path, '@stdlib/' ) ) {
149+
stdlibPath = join( ROOT_DIR, 'lib', 'node_modules', path );
150+
return require( stdlibPath ); // eslint-disable-line stdlib/no-dynamic-require
151+
}
143152
return require( path ); // eslint-disable-line stdlib/no-dynamic-require
144153
}
145154
scope = {

lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-doctest/lib/main.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var format = require( 'util' ).format;
2727
var dirname = require( 'path' ).dirname;
2828
var logger = require( 'debug' );
2929
var parseJSDoc = require( 'doctrine' ).parse;
30+
var rootDir = require( '@stdlib/_tools/utils/root-dir' );
3031
var Buffer = require( '@stdlib/buffer/ctor' );
3132
var isNull = require( '@stdlib/assert/is-null' );
3233
var isNumber = require( '@stdlib/assert/is-number' );
@@ -46,6 +47,7 @@ var windowShim = require( './window.js' );
4647
// VARIABLES //
4748

4849
var debug = logger( 'jsdoc-doctest' );
50+
var ROOT_DIR = rootDir();
4951
var RE_ANNOTATION = /(?:\n|^)(?:var|let|const)? ?([a-zA-Z0-9._]+) ?=?[^;]*;\n\/\/ ?(returns|([A-Za-z][A-Za-z_0-9]*)? ?=>|throws) {0,1}([\s\S]*?)(\n|$)/g;
5052
var RE_CONSOLE = /console\.(?:dir|error|log)/;
5153
var RE_MODULE_TAG = /\* @module[^\n]*\n/g;
@@ -147,9 +149,16 @@ function main( context ) {
147149
* @returns {*} required module
148150
*/
149151
function customRequire( path ) {
152+
var stdlibPath;
153+
150154
if ( startsWith( path, './' ) ) {
151155
return require( join( dir, path ) ); // eslint-disable-line stdlib/no-dynamic-require
152156
}
157+
// Force `@stdlib` packages to be loaded from `lib/node_modules/@stdlib`:
158+
if ( startsWith( path, '@stdlib/' ) ) {
159+
stdlibPath = join( ROOT_DIR, 'lib', 'node_modules', path );
160+
return require( stdlibPath ); // eslint-disable-line stdlib/no-dynamic-require
161+
}
153162
return require( path ); // eslint-disable-line stdlib/no-dynamic-require
154163
}
155164
scope = {

lib/node_modules/@stdlib/_tools/eslint/rules/namespace-export-all/lib/main.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@
2323
var basename = require( 'path' ).basename;
2424
var dirname = require( 'path' ).dirname;
2525
var join = require( 'path' ).join;
26-
var relative = require( 'path' ).relative;
2726
var statSync = require( 'fs' ).statSync; // eslint-disable-line node/no-sync
27+
var exists = require( '@stdlib/fs/exists' ).sync;
2828
var endsWith = require( '@stdlib/string/ends-with' );
29-
var replace = require( '@stdlib/string/replace' );
3029
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
3130
var trim = require( '@stdlib/string/trim' );
3231
var camelcase = require( '@stdlib/string/base/camelcase' );
3332
var readDir = require( '@stdlib/fs/read-dir' ).sync;
3433
var contains = require( '@stdlib/assert/contains' );
35-
var rootDir = require( '@stdlib/_tools/utils/root-dir' );
34+
var resolvePackage = require( './resolve_package.js' );
3635

3736

3837
// VARIABLES //
@@ -41,7 +40,6 @@ var rule;
4140
var ORDER_COMMENT = 'When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.';
4241
var RE_CUSTOM_EXCLUDES = /The following modules are intentionally not exported: ?([^\n]+)\n/;
4342
var RE_NS_VAR = /@namespace ([a-zA-Z0-9_]+)/;
44-
var LIB_DIR = join( rootDir(), 'lib', 'node_modules' );
4543
var EXCLUDE_LIST = [
4644
'node_modules',
4745
'benchmark',
@@ -184,15 +182,15 @@ function main( context ) {
184182
* @returns {Object} fix
185183
*/
186184
function fix( fixer ) {
187-
var nsPath;
185+
var packagePath;
188186
var entry;
189187
var match;
190188
var pos;
191189
var ns;
192190
var re;
193191
var i;
194192

195-
nsPath = replace( relative( LIB_DIR, dir ), '\\', '/' );
193+
packagePath = resolvePackage( dir, pkg );
196194
match = RE_NS_VAR.exec( source.text );
197195
if ( !match ) {
198196
return null;
@@ -208,7 +206,7 @@ function main( context ) {
208206
'*/',
209207
'setReadOnly( <<ns>>, \'<<alias>>\', require( \'<<pkg>>\' ) );'
210208
].join( '\n' );
211-
entry = entry.replace( /<<pkg>>/g, nsPath + '/' + pkg );
209+
entry = entry.replace( /<<pkg>>/g, packagePath );
212210
entry = entry.replace( /<<alias>>/g, camelcase( pkg ) );
213211
entry = entry.replace( /<<ns>>/g, ns );
214212

@@ -218,7 +216,7 @@ function main( context ) {
218216
if ( pkg.localeCompare( packages[ i ], 'en', OPTS_COMPARE ) < 0 ) {
219217
break;
220218
}
221-
re = new RegExp( 'require\\( \'' + nsPath + '\\/' + packages[ i ] + '\' \\) \\);' );
219+
re = new RegExp( 'require\\( \'' + resolvePackage( dir, packages[ i ] ) + '\' \\) \\);' );
222220
if ( re.test( source.text ) ) {
223221
pos = source.text.search( re );
224222
}
@@ -252,16 +250,21 @@ function main( context ) {
252250
* @returns {Array} namespace package directories
253251
*/
254252
function packageDirectories( contents ) {
253+
var pkgJSONPath;
254+
var contentPath;
255255
var content;
256256
var out;
257257
var i;
258258

259259
out = [];
260260
for ( i = 0; i < contents.length; i++ ) {
261261
content = contents[ i ];
262+
contentPath = join( dir, content );
263+
pkgJSONPath = join( contentPath, 'package.json' );
262264
if (
263-
isDirectory( join( dir, content ) ) &&
264-
!contains( excludes, content )
265+
isDirectory( contentPath ) &&
266+
!contains( excludes, content ) &&
267+
exists( pkgJSONPath )
265268
) {
266269
out.push( content );
267270
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var join = require( 'path' ).join;
24+
var relative = require( 'path' ).relative;
25+
var replace = require( '@stdlib/string/replace' );
26+
var rootDir = require( '@stdlib/_tools/utils/root-dir' );
27+
28+
29+
// VARIABLES //
30+
31+
var LIB_DIR = join( rootDir(), 'lib', 'node_modules' );
32+
33+
34+
// MAIN //
35+
36+
/**
37+
* Resolves a stdlib package identifier from directory path and package name.
38+
*
39+
* @private
40+
* @param {string} dir - directory path containing the package
41+
* @param {string} pkg - package name
42+
* @returns {string} stdlib package identifier relative to the lib directory
43+
*
44+
* @example
45+
* var join = require( 'path' ).join;
46+
* var rootDir = require( '@stdlib/_tools/utils/root-dir' );
47+
*
48+
* var LIB_DIR = join( rootDir(), 'lib', 'node_modules' );
49+
* var dir = join( LIB_DIR, '@stdlib', 'math', 'base' );
50+
*
51+
* var pkgId = resolvePackage( dir, 'abs' );
52+
* // returns '@stdlib/math/base/abs'
53+
*/
54+
function resolvePackage( dir, pkg ) {
55+
var nsPath = replace( relative( LIB_DIR, dir ), '\\', '/' );
56+
return nsPath + '/' + pkg;
57+
}
58+
59+
60+
// EXPORTS //
61+
62+
module.exports = resolvePackage;

0 commit comments

Comments
 (0)