Skip to content

Commit 7f9b278

Browse files
authored
Fix the issue with reset! (#242)
1 parent 7baee63 commit 7f9b278

File tree

6 files changed

+59
-17
lines changed

6 files changed

+59
-17
lines changed

.cirrus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
freebsd_instance:
2-
image_family: freebsd-13-3
2+
image_family: freebsd-14-2
33
task:
44
name: FreeBSD
55
env:

.github/workflows/Breakage.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,49 @@ jobs:
159159
fi
160160
done >> summary.md
161161
162+
- name: Display summary in CI logs
163+
run: |
164+
echo "### Breakage Summary" >> $GITHUB_STEP_SUMMARY
165+
cat breakage/summary.md >> $GITHUB_STEP_SUMMARY
166+
162167
- name: PR comment with file
163-
uses: thollander/actions-comment-pull-request@v2
168+
if: github.event.pull_request.head.repo.fork == false
169+
uses: actions/github-script@main
164170
with:
165-
filePath: breakage/summary.md
171+
github-token: ${{ secrets.GITHUB_TOKEN }}
172+
script: |
173+
// Import file content from summary.md
174+
const fs = require('fs')
175+
const filePath = 'breakage/summary.md'
176+
const msg = fs.readFileSync(filePath, 'utf8')
177+
178+
// Get the current PR number from context
179+
const prNumber = context.payload.pull_request.number
180+
181+
// Fetch existing comments on the PR
182+
const { data: comments } = await github.rest.issues.listComments({
183+
owner: context.repo.owner,
184+
repo: context.repo.repo,
185+
issue_number: prNumber
186+
})
187+
188+
// Find a previous comment by the bot to update
189+
const botComment = comments.find(comment => comment.user.id === 41898282)
190+
191+
if (botComment) {
192+
// Update the existing comment
193+
await github.rest.issues.updateComment({
194+
owner: context.repo.owner,
195+
repo: context.repo.repo,
196+
comment_id: botComment.id,
197+
body: msg
198+
})
199+
} else {
200+
// Create a new comment
201+
await github.rest.issues.createComment({
202+
owner: context.repo.owner,
203+
repo: context.repo.repo,
204+
issue_number: prNumber,
205+
body: msg
206+
})
207+
}

.github/workflows/Test.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,22 @@ jobs:
2626
- "1"
2727
os:
2828
- ubuntu-latest
29-
- macOS-latest
30-
29+
- maos-latest
3130
- windows-latest
3231

3332
arch:
3433
- x64
3534
allow_failure: [false]
3635
include:
37-
- version: "nightly"
36+
- version: "pre"
3837
os: ubuntu-latest
3938
arch: x64
4039
allow_failure: true
41-
- version: "nightly"
42-
os: macOS-latest
40+
- version: "pre"
41+
os: macos-latest
4342
arch: x64
4443
allow_failure: true
45-
- version: "nightly"
44+
- version: "pre"
4645
os: windows-latest
4746
arch: x64
4847
allow_failure: true

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
99
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1010

1111
[compat]
12+
LinearAlgebra = "1.10"
1213
LinearOperators = "2.0"
1314
NLPModels = "0.21"
14-
julia = "^1.10"
15+
Printf = "1.10"
16+
julia = "1.10"

src/trust-region/trust-region.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# A trust-region type and basic utility functions.
2-
import NLPModels: reset!
32
export TrustRegionException, acceptable, aredpred!, reset!, update!
43

54
"Exception type raised in case of error."
@@ -170,7 +169,7 @@ end
170169
171170
Reset the trust-region radius to its initial value.
172171
"""
173-
function reset!(tr::AbstractTrustRegion)
172+
function NLPModels.reset!(tr::AbstractTrustRegion)
174173
tr.radius = tr.initial_radius
175174
return tr
176175
end

test/test-trust_region.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ end
9898
tr.ratio = T(10)
9999
update!(tr, Δ₀)
100100
@test tr.radius > Δ₀
101-
reset!(tr)
101+
NLPModels.reset!(tr)
102102
tr.ratio = -T(1)
103103
update!(tr, Δ₀)
104104
@test tr.radius < Δ₀
105-
reset!(tr)
105+
NLPModels.reset!(tr)
106106

107107
if VERSION v"1.7"
108108
trust_region_allocs_test(TrustRegion, S)
@@ -120,15 +120,15 @@ end
120120
tr.ratio = tr.acceptance_threshold - 1
121121
update!(tr, Δ₀)
122122
@test tr.radius < Δ₀
123-
reset!(tr)
123+
NLPModels.reset!(tr)
124124
tr.ratio = (tr.acceptance_threshold + tr.decrease_threshold) / 2
125125
update!(tr, Δ₀)
126126
@test tr.radius < Δ₀
127-
reset!(tr)
127+
NLPModels.reset!(tr)
128128
tr.ratio = (tr.decrease_threshold + tr.increase_threshold) / 2
129129
update!(tr, Δ₀)
130130
@test tr.radius < Δ₀
131-
reset!(tr)
131+
NLPModels.reset!(tr)
132132
tr.ratio = tr.increase_threshold + 1
133133
tr.quad_min = T(2)
134134
update!(tr, Δ₀)

0 commit comments

Comments
 (0)