Skip to content

Commit 4ab2e6c

Browse files
Merge branch 'logcdf' of https://github.com/vivekmaurya001/stdlib into logcdf
2 parents 2d6c6a4 + 58b9eb3 commit 4ab2e6c

File tree

332 files changed

+23492
-670
lines changed

Some content is hidden

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

332 files changed

+23492
-670
lines changed

.github/workflows/scripts/create_sub_issue

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818

1919
# Script to create a sub-issue.
2020
#
21-
# Usage: ./create_sub_issue.sh <issue-title> <body-file> <parent-issue-number>
21+
# Usage: ./create_sub_issue.sh <issue-title> <body-file> <parent-issue-number> [<labels>]
2222
#
2323
# Arguments:
2424
#
2525
# issue-title Title for the new sub-issue.
2626
# body-file Path to the file containing the issue body.
2727
# parent-issue-number Number of the parent issue.
28+
# labels Optional comma-separated list of labels to apply to the new sub-issue.
2829
#
2930
# Environment variables:
3031
#
@@ -42,6 +43,7 @@ set -o pipefail
4243
issue_title="$1"
4344
body_file="$2"
4445
parent_issue_number="$3"
46+
labels="$4"
4547

4648
# Repository information:
4749
owner="stdlib-js"
@@ -61,6 +63,14 @@ if [ ! -f "$body_file" ]; then
6163
fi
6264
issue_body=$(cat "$body_file")
6365

66+
# Process labels into an array if provided:
67+
if [ -n "$labels" ]; then
68+
# Convert comma-separated string to JSON array...
69+
label_array="[$(echo "$labels" | sed 's/[[:space:]]*,[[:space:]]*/","/g' | sed 's/.*/"&"/')]"
70+
else
71+
label_array="[]"
72+
fi
73+
6474
# FUNCTIONS #
6575

6676
# Error handler.
@@ -95,7 +105,7 @@ EOF
95105
echo "$response" | jq -r '.data.repository.id'
96106
}
97107

98-
# Creates a child issue.
108+
# Creates a child issue with labels.
99109
#
100110
# $1 - repository node ID
101111
# $2 - issue body
@@ -108,11 +118,12 @@ create_child_issue() {
108118
-H "Content-Type: application/json" \
109119
--data @- << EOF
110120
{
111-
"query": "mutation CreateIssue(\$repositoryId: ID!, \$title: String!, \$body: String!) { createIssue(input: {repositoryId: \$repositoryId, title: \$title, body: \$body}) { issue { id number } } }",
121+
"query": "mutation CreateIssue(\$repositoryId: ID!, \$title: String!, \$body: String!, \$labelIds: [ID!]) { createIssue(input: {repositoryId: \$repositoryId, title: \$title, body: \$body, labelIds: \$labelIds}) { issue { id number } } }",
112122
"variables": {
113123
"repositoryId": "${repo_id}",
114124
"title": "${issue_title}",
115-
"body": $(echo "$issue_body" | jq -R -s '.')
125+
"body": $(echo "$issue_body" | jq -R -s '.'),
126+
"labelIds": ${label_array}
116127
}
117128
}
118129
EOF
@@ -140,6 +151,37 @@ EOF
140151
echo "$response" | jq -r '.data.repository.issue.id'
141152
}
142153

154+
# Fetches label IDs for given label names.
155+
fetch_label_ids() {
156+
if [ -z "$labels" ]; then
157+
echo "[]"
158+
return
159+
fi
160+
161+
local label_names="${labels//,/\",\"}"
162+
local response
163+
response=$(curl -s -X POST 'https://api.github.com/graphql' \
164+
-H "Authorization: bearer ${github_token}" \
165+
-H "Content-Type: application/json" \
166+
--data @- << EOF
167+
{
168+
"query": "query(\$owner: String!, \$repo: String!) { repository(owner: \$owner, name: \$repo) { labels(first: 100) { nodes { id name } } } }",
169+
"variables": {
170+
"owner": "${owner}",
171+
"repo": "${repo}"
172+
}
173+
}
174+
EOF
175+
)
176+
177+
# Extract and filter label IDs that match our requested labels...
178+
echo "$response" | jq --arg names "${label_names}" '
179+
.data.repository.labels.nodes |
180+
map(select(.name as $n | [$names] | contains([$n]))) |
181+
map(.id)
182+
'
183+
}
184+
143185
# Creates a sub-issue relationship.
144186
#
145187
# $1 - parent issue ID
@@ -175,6 +217,14 @@ main() {
175217
exit 1
176218
fi
177219

220+
if [ -n "$labels" ]; then
221+
echo "Fetching label IDs..."
222+
label_array=$(fetch_label_ids)
223+
if [ "$label_array" = "[]" ]; then
224+
echo -e "Warning: No valid labels found for the provided label names."
225+
fi
226+
fi
227+
178228
echo "Creating child issue..."
179229
child_issue_response=$(create_child_issue "$repo_id" "$issue_body")
180230

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ UtkershBasnet <[email protected]>
112112
Vaibhav Patel <[email protected]>
113113
Varad Gupta <[email protected]>
114114
Vinit Pandit <[email protected]>
115+
Vivek maurya <[email protected]>
115116
Xiaochuan Ye <[email protected]>
116117
Yaswanth Kosuru <[email protected]>
117118
Yernar Yergaziyev <[email protected]>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
type: filter-packages
3+
exclude:
4+
- blas/base/daxpy
5+
---
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 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+
# bquaternary3d
22+
23+
> Apply a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assign results to elements in a three-dimensional nested output array.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var bquaternary3d = require( '@stdlib/array/base/broadcasted-quaternary3d' );
37+
```
38+
39+
#### bquaternary3d( arrays, shapes, fcn )
40+
41+
Applies a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assigns results to elements in a three-dimensional nested output array.
42+
43+
```javascript
44+
var add = require( '@stdlib/math/base/ops/add4' );
45+
var zeros3d = require( '@stdlib/array/base/zeros3d' );
46+
47+
var x = [ [ 1.0, 2.0 ] ];
48+
var y = [ [ 3.0 ], [ 4.0 ] ];
49+
var z = [ [ 5.0 ] ];
50+
var w = [ [ 2.0 ] ];
51+
var out = zeros3d( [ 2, 2, 2 ] );
52+
53+
var shapes = [
54+
[ 1, 2 ],
55+
[ 2, 1 ],
56+
[ 1, 1 ],
57+
[ 1, 1 ],
58+
[ 2, 2, 2 ]
59+
];
60+
61+
bquaternary3d( [ x, y, z, w, out ], shapes, add );
62+
// out => [ [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ], [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ] ]
63+
```
64+
65+
The function accepts the following arguments:
66+
67+
- **arrays**: array-like object containing four input nested arrays and one output nested array.
68+
- **shapes**: array shapes.
69+
- **fcn**: quaternary function to apply.
70+
71+
</section>
72+
73+
<!-- /.usage -->
74+
75+
<section class="notes">
76+
77+
## Notes
78+
79+
- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes].
80+
81+
</section>
82+
83+
<!-- /.notes -->
84+
85+
<section class="examples">
86+
87+
## Examples
88+
89+
<!-- eslint no-undef: "error" -->
90+
91+
```javascript
92+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
93+
var filled3dBy = require( '@stdlib/array/base/filled3d-by' );
94+
var zeros3d = require( '@stdlib/array/base/zeros3d' );
95+
var add = require( '@stdlib/math/base/ops/add4' );
96+
var bquaternary3d = require( '@stdlib/array/base/broadcasted-quaternary3d' );
97+
98+
var shapes = [
99+
[ 1, 1, 3 ],
100+
[ 3, 1, 1 ],
101+
[ 1, 3, 1 ],
102+
[ 3, 3, 3 ],
103+
[ 3, 3, 3 ]
104+
];
105+
106+
var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) );
107+
console.log( x );
108+
109+
var y = filled3dBy( shapes[ 1 ], discreteUniform( -100, 100 ) );
110+
console.log( y );
111+
112+
var z = filled3dBy( shapes[ 2 ], discreteUniform( -100, 100 ) );
113+
console.log( z );
114+
115+
var w = filled3dBy( shapes[ 3 ], discreteUniform( -100, 100 ) );
116+
console.log( w );
117+
118+
var out = zeros3d( shapes[ 4 ] );
119+
console.log( z );
120+
121+
bquaternary3d( [ x, y, z, w, out ], shapes, add );
122+
console.log( out );
123+
```
124+
125+
</section>
126+
127+
<!-- /.examples -->
128+
129+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
130+
131+
<section class="related">
132+
133+
</section>
134+
135+
<!-- /.related -->
136+
137+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
138+
139+
<section class="links">
140+
141+
[@stdlib/array/base/broadcast-array]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/broadcast-array
142+
143+
[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/broadcast-shapes
144+
145+
</section>
146+
147+
<!-- /.links -->

0 commit comments

Comments
 (0)