Skip to content

Commit 093d1fb

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into dsnannsumors-refactor
2 parents a1c2c33 + 7b01e66 commit 093d1fb

Some content is hidden

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

59 files changed

+1485
-433
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2024 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+
# Workflow name:
20+
name: cleanup_coverage
21+
22+
# Workflow triggers:
23+
on:
24+
25+
# Trigger the workflow when a pull request is closed (e.g., merged or closed without merging):
26+
pull_request_target:
27+
types:
28+
- closed
29+
30+
# Workflow jobs:
31+
jobs:
32+
33+
# Define a job to perform coverage cleanup...
34+
cleanup:
35+
36+
# Define a display name:
37+
name: 'Cleanup coverage'
38+
39+
# Define the type of virtual host machine:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
# Delete the 'pr-<number>' branch from the 'stdlib-js/www-test-code-coverage' repository:
44+
- name: 'Delete coverage branch for PR'
45+
env:
46+
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
47+
PR_NUMBER: ${{ github.event.pull_request.number }}
48+
run: |
49+
curl -X DELETE -H "Authorization: token $REPO_GITHUB_TOKEN" \
50+
"https://api.github.com/repos/stdlib-js/www-test-code-coverage/git/refs/heads/pr-${PR_NUMBER}" \
51+
|| echo "Branch pr-${PR_NUMBER} does not exist or could not be deleted."
52+
53+
# Find and update the '## Coverage Report' comment in the PR
54+
- name: 'Update coverage comment in PR'
55+
# Pin action to full length commit SHA
56+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
57+
with:
58+
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
59+
script: |
60+
const prNumber = context.payload.pull_request.number;
61+
const { data: comments } = await github.rest.issues.listComments({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
issue_number: prNumber,
65+
});
66+
const coverageComment = comments.find( comment => comment.body && comment.body.includes( '## Coverage Report' ) );
67+
if ( coverageComment ) {
68+
// Replace URLs with plain text in the coverage report comment body:
69+
const updatedBody = coverageComment.body.replace( /<a href="[^"]+">([^<]+)<\/a>/g, '$1' );
70+
await github.rest.issues.updateComment({
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
comment_id: coverageComment.id,
74+
body: updatedBody,
75+
});
76+
} else {
77+
console.log( 'No Coverage Report comment found.' );
78+
}

.github/workflows/pr_merge_develop.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,18 @@ jobs:
108108
BRANCH_NAME: ${{ steps.pr-details.outputs.branch }}
109109
REPO_NAME: ${{ steps.pr-details.outputs.repository }}
110110
run: |
111+
# Configure Git user:
111112
git config --local user.email "[email protected]"
112113
git config --local user.name "stdlib-bot"
113-
git fetch origin develop:develop
114-
git merge develop --no-edit
114+
115+
# Add upstream remote pointing to the original repository:
116+
git remote add upstream https://github.com/stdlib-js/stdlib.git
117+
118+
# Fetch the develop branch from upstream:
119+
git fetch upstream develop
120+
121+
# Merge upstream develop into the current branch:
122+
git merge upstream/develop --no-edit
123+
124+
# Push the updated branch back to the forked repository:
115125
git push "https://$USER_NAME:[email protected]/$REPO_NAME.git" $BRANCH_NAME

.github/workflows/pr_rebase_develop.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,18 @@ jobs:
108108
BRANCH_NAME: ${{ steps.pr-details.outputs.branch }}
109109
REPO_NAME: ${{ steps.pr-details.outputs.repository }}
110110
run: |
111+
# Configure Git user:
111112
git config --local user.email "[email protected]"
112113
git config --local user.name "stdlib-bot"
113-
git fetch origin develop:develop
114-
git rebase develop
114+
115+
# Add upstream remote pointing to the original repository:
116+
git remote add upstream https://github.com/stdlib-js/stdlib.git
117+
118+
# Fetch the develop branch from upstream:
119+
git fetch upstream develop
120+
121+
# Rebase current branch onto upstream develop:
122+
git rebase upstream/develop
123+
124+
# Force push the updated branch back to the forked repository:
115125
git push --force-with-lease "https://$USER_NAME:[email protected]/$REPO_NAME.git" $BRANCH_NAME

.github/workflows/run_tests_coverage.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,22 @@ jobs:
131131
if: github.event_name != 'workflow_dispatch'
132132
id: changed-directories
133133
continue-on-error: true
134+
env:
135+
STDLIB_BOT_GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
134136
run: |
135137
if [ -n "${{ github.event.pull_request.number }}" ]; then
136138
# Get the list of changed files in pull request:
137-
ancestor_commit=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
138-
files=$(git diff --diff-filter=AM --name-only $ancestor_commit ${{ github.event.pull_request.head.sha }})
139+
page=1
140+
files=""
141+
while true; do
142+
changed_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer $STDLIB_BOT_GITHUB_TOKEN" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.pull_request.number }}/files?page=$page&per_page=100" | jq -r '.[] | .filename')
143+
if [ -z "$changed_files" ]; then
144+
break
145+
fi
146+
files="$files $changed_files"
147+
page=$((page+1))
148+
done
149+
files=$(echo "$files" | tr '\n' ' ' | sed 's/ $//')
139150
else
140151
# Get changed files by comparing the current commit to the commit before the push event or with its parent:
141152
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
@@ -167,6 +178,15 @@ jobs:
167178
else
168179
directories="${{ steps.changed-directories.outputs.directories }}"
169180
fi
181+
182+
# Append suffix to coverage base URL for PRs:
183+
if [ -n "${{ github.event.pull_request.number }}" ]; then
184+
PR_NUMBER=${{ github.event.pull_request.number }}
185+
export COVERAGE_BASE_URL="https://coverage.stdlib.io/pr-${PR_NUMBER}"
186+
else
187+
export COVERAGE_BASE_URL="https://coverage.stdlib.io"
188+
fi
189+
170190
. "$GITHUB_WORKSPACE/.github/workflows/scripts/run_tests_coverage" "$directories"
171191
timeout-minutes: 30
172192

.github/workflows/scripts/run_tests_coverage

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ set -o pipefail
4242

4343
# VARIABLES #
4444

45+
# Define the base URL for coverage reports, defaulting to 'https://coverage.stdlib.io':
46+
coverage_base_url="${COVERAGE_BASE_URL:-https://coverage.stdlib.io}"
47+
4548
# Get the list of changed files:
4649
changed="$*"
4750

@@ -159,11 +162,11 @@ main() {
159162
for package in ${directories}; do
160163
# For each package, extract coverage values from the respective coverage report:
161164
pkg=`echo $package | sed -E 's/^.*stdlib\///'`
162-
165+
163166
if [ -f "lib/node_modules/@stdlib/${pkg}/binding.gyp" ]; then
164167
NODE_ADDONS_PATTERN="${pkg}" make install-node-addons
165168
fi
166-
169+
167170
make test-javascript-cov TESTS_FILTER=".*/${pkg}/test/.*"
168171

169172
if [ ! -f reports/coverage/lcov-report/${pkg}/lib/index.html ]; then
@@ -187,7 +190,7 @@ main() {
187190
pkg_functions_cov_fraction=${pkg_cov_fractions[2]}
188191
pkg_lines_cov_fraction=${pkg_cov_fractions[3]}
189192

190-
old_cov_report=$(curl -s --fail "https://coverage.stdlib.io/${pkg}/lib/index.html" 2>/dev/null || true)
193+
old_cov_report=$(curl -s --fail "${coverage_base_url}/${pkg}/lib/index.html" 2>/dev/null || true)
191194
if [ -z "$old_cov_report" ]; then
192195
old_statements_cov=0
193196
old_branches_cov=0
@@ -208,7 +211,7 @@ main() {
208211

209212
pkg_cov="| $pkg_statements_cov_fraction <br> $cov_change_statements | $pkg_branches_cov_fraction <br> $cov_change_branches | $pkg_functions_cov_fraction <br> $cov_change_functions | $pkg_lines_cov_fraction <br> $cov_change_lines |"
210213

211-
pkg_url="https://coverage.stdlib.io/${pkg}/index.html"
214+
pkg_url="${coverage_base_url}/${pkg}/index.html"
212215
pkg_link="<a href="$pkg_url">$pkg</a>"
213216
coverage="$coverage\n| $pkg_link $pkg_cov"
214217

lib/node_modules/@stdlib/blas/base/cswap/README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,21 +291,46 @@ Interchanges two complex single-precision floating-point vectors.
291291
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f }; // interleaved real and imaginary components
292292
float y[] = { 5.0f, 6.0f, 7.0f, 8.0f };
293293

294-
c_cswap( 2, (void *)x, 1, (void *)Y, 1 );
294+
c_cswap( 2, (void *)x, 1, (void *)y, 1 );
295295
```
296296
297297
The function accepts the following arguments:
298298
299299
- **N**: `[in] CBLAS_INT` number of indexed elements.
300300
- **X**: `[inout] void*` first input array.
301301
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
302-
- **Y**: `[inout] void*` first input array.
302+
- **Y**: `[inout] void*` second input array.
303303
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
304304
305305
```c
306306
void c_cswap( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY );
307307
```
308308

309+
#### c_cswap_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY )
310+
311+
Interchanges two complex single-precision floating-point vectors using alternative indexing semantics.
312+
313+
```c
314+
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f }; // interleaved real and imaginary components
315+
float y[] = { 5.0f, 6.0f, 7.0f, 8.0f };
316+
317+
c_cswap_ndarray( 2, (void *)x, 1, 0, (void *)y, 1, 0 );
318+
```
319+
320+
The function accepts the following arguments:
321+
322+
- **N**: `[in] CBLAS_INT` number of indexed elements.
323+
- **X**: `[inout] void*` first input array.
324+
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
325+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
326+
- **Y**: `[inout] void*` second input array.
327+
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
328+
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
329+
330+
```c
331+
void c_cswap_ndarray( const CBLAS_INT N, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
332+
```
333+
309334
</section>
310335

311336
<!-- /.usage -->

lib/node_modules/@stdlib/blas/base/cswap/benchmark/c/benchmark.length.c

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static float rand_float( void ) {
9494
* @param len array length
9595
* @return elapsed time in seconds
9696
*/
97-
static double benchmark( int iterations, int len ) {
97+
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
9999
float x[ len*2 ];
100100
float y[ len*2 ];
@@ -122,6 +122,41 @@ static double benchmark( int iterations, int len ) {
122122
return elapsed;
123123
}
124124

125+
/**
126+
* Runs a benchmark.
127+
*
128+
* @param iterations number of iterations
129+
* @param len array length
130+
* @return elapsed time in seconds
131+
*/
132+
static double benchmark2( int iterations, int len ) {
133+
double elapsed;
134+
float x[ len*2 ];
135+
float y[ len*2 ];
136+
double t;
137+
int i;
138+
139+
for ( i = 0; i < len; i++ ) {
140+
x[ i ] = ( rand_float()*10000.0f ) - 5000.0f;
141+
x[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f;
142+
y[ i ] = 0.0f;
143+
y[ i+1 ] = 0.0f;
144+
}
145+
t = tic();
146+
for ( i = 0; i < iterations; i++ ) {
147+
c_cswap_ndarray( len, (void *)x, 1, 0, (void *)y, 1, 0 );
148+
if ( y[ 0 ] != y[ 0 ] ) {
149+
printf( "should not return NaN\n" );
150+
break;
151+
}
152+
}
153+
elapsed = tic() - t;
154+
if ( y[ 0 ] != y[ 0 ] ) {
155+
printf( "should not return NaN\n" );
156+
}
157+
return elapsed;
158+
}
159+
125160
/**
126161
* Main execution sequence.
127162
*/
@@ -144,7 +179,14 @@ int main( void ) {
144179
for ( j = 0; j < REPEATS; j++ ) {
145180
count += 1;
146181
printf( "# c::%s:len=%d\n", NAME, len );
147-
elapsed = benchmark( iter, len );
182+
elapsed = benchmark1( iter, len );
183+
print_results( iter, elapsed );
184+
printf( "ok %d benchmark finished\n", count );
185+
}
186+
for ( j = 0; j < REPEATS; j++ ) {
187+
count += 1;
188+
printf( "# c::%s:ndarray:len=%d\n", NAME, len );
189+
elapsed = benchmark2( iter, len );
148190
print_results( iter, elapsed );
149191
printf( "ok %d benchmark finished\n", count );
150192
}

lib/node_modules/@stdlib/blas/base/cswap/examples/c/example.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ int main( void ) {
3131
const int strideX = 1;
3232
const int strideY = -1;
3333

34-
// Copy elements:
34+
// Swap elements:
3535
c_cswap( N, (void *)x, strideX, (void *)y, strideY );
3636

3737
// Print the result:
3838
for ( int i = 0; i < N; i++ ) {
3939
printf( "x[ %i ] = %f + %fj\n", i, x[ i*2 ], x[ (i*2)+1 ] );
4040
printf( "y[ %i ] = %f + %fj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
4141
}
42+
43+
// Swap elements using alternative indexing semantics:
44+
c_cswap_ndarray( N, (void *)x, -strideX, N-1, (void *)y, strideY, N-1 );
45+
46+
// Print the result:
47+
for ( int i = 0; i < N; i++ ) {
48+
printf( "x[ %i ] = %f + %fj\n", i, x[ i*2 ], x[ (i*2)+1 ] );
49+
printf( "y[ %i ] = %f + %fj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
50+
}
4251
}

lib/node_modules/@stdlib/blas/base/cswap/include/stdlib/blas/base/cswap.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ extern "C" {
3636
*/
3737
void API_SUFFIX(c_cswap)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY );
3838

39+
/**
40+
* Interchanges two complex single-precision floating-point vectors.
41+
*/
42+
void API_SUFFIX(c_cswap_ndarray)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
43+
3944
#ifdef __cplusplus
4045
}
4146
#endif

0 commit comments

Comments
 (0)