8000 fix(least_squares): Wrap unsafe cast in trusted by Geod24 · Pull Request #23 · libmir/mir-optim · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(least_squares): Wrap unsafe cast in trusted #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
setup:
name: 'Load job configuration'
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
outputs:
compilers: ${{ steps.load-config.outputs.compilers }}
steps:
Expand All @@ -29,7 +29,7 @@ jobs:
const compilers = {"windows": [], "macos": [], "ubuntu": []};
const {owner, repo} = context.repo;
let commit_sha = context.sha;
if (context.eventName == "pull_request")
if (context.eventName == "pull_request")
{
commit_sha = context.payload.pull_request.head.sha;
}
Expand Down Expand Up @@ -75,11 +75,11 @@ jobs:
matrix:
dc: ${{ fromJSON(needs.setup.outputs.compilers).macos }}
steps:
- name: Checkout repo
- name: Checkout repo
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
fetch-depth: 0
- name: Setup D compiler
- name: Setup D compiler
uses: dlang-community/setup-dlang@763d869b4d67e50c3ccd142108c8bca2da9df166
with:
compiler: ${{ matrix.dc }}
Expand Down Expand Up @@ -112,17 +112,17 @@ jobs:
env:
# Ubuntu no longer has a 32-bit version of LAPACK available, so
# we have to drop support. :(
ARCH: x86_64
ARCH: x86_64
strategy:
fail-fast: false
matrix:
dc: ${{ fromJSON(needs.setup.outputs.compilers).ubuntu }}
steps:
- name: Checkout repo
- name: Checkout repo
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
fetch-depth: 0
- name: Setup D compiler
- name: Setup D compiler
uses: dlang-community/setup-dlang@763d869b4d67e50c3ccd142108c8bca2da9df166
with:
compiler: ${{ matrix.dc }}
Expand All @@ -137,13 +137,13 @@ jobs:
key: ubuntu-latest-build-${{ hashFiles('**/dub.sdl', '**/dub.json') }}
restore-keys: |
ubuntu-latest-build-
- name: Build / test
- name: Build / test
run: |
dub test --arch=$ARCH --build=unittest-cov -c unittest-blas
shell: bash
- name: Upload coverage data
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b

windows:
name: '[windows] x86_64/${{ matrix.dc }}'
runs-on: windows-latest
Expand All @@ -158,11 +158,11 @@ jobs:
matrix:
dc: ${{ fromJSON(needs.setup.outputs.compilers).windows }}
steps:
- name: Checkout repo
- name: Checkout repo
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
fetch-depth: 0
- name: Setup D compiler
- name: Setup D compiler
uses: dlang-community/setup-dlang@763d869b4d67e50c3ccd142108c8bca2da9df166
with:
compiler: ${{ matrix.dc }}
Expand All @@ -189,5 +189,3 @@ jobs:
shell: bash
- name: Upload coverage data
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b


14 changes: 7 additions & 7 deletions source/mir/optim/least_squares.d
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ algorithm, and an estimate of the Jacobian of `f` at x.
The function `f` should take an input vector of length `n`, and fill an output
vector of length `m`.

The function `g` is the Jacobian of `f`, and should fill a row-major `m x n` matrix.
The function `g` is the Jacobian of `f`, and should fill a row-major `m x n` matrix.

Throws: $(LREF LeastSquaresException)
Params:
Expand All @@ -173,10 +173,10 @@ LeastSquaresResult!T optimize(alias f, alias g = null, alias tm = null, T)(
{
auto ret = optimizeLeastSquares!(f, g, tm, T)(settings, m, x, l, u);
if (ret.status == -1)
throw cast()leastSquaresException_maxIterations;
() @trusted { throw cast()leastSquaresException_maxIterations; }();
else
if (ret.status < -1)
throw cast()leastSquaresExceptions[ret.status + 32];
() @trusted { throw cast()leastSquaresExceptions[ret.status + 32]; }();
return ret;
}

Expand Down Expand Up @@ -207,10 +207,10 @@ LeastSquaresResult!T optimize(alias f, TaskPool, T)(

auto ret = optimizeLeastSquares!(f, null, tm, T)(settings, m, x, l, u);
if (ret.status == -1)
throw leastSquaresException_maxIterations;
() @trusted { throw cast()leastSquaresException_maxIterations; }();
else
if (ret.status < -1)
throw leastSquaresExceptions[ret.status + 32];
() @trusted { throw cast()leastSquaresExceptions[ret.status + 32]; }();
return ret;
}

Expand Down Expand Up @@ -442,7 +442,7 @@ algorithm, and an estimate of the Jacobian of `f` at x.
The function `f` should take an input vector of length `n`, and fill an output
vector of length `m`.

The function `g` is the Jacobian of `f`, and should fill a row-major `m x n` matrix.
The function `g` is the Jacobian of `f`, and should fill a row-major `m x n` matrix.

Returns: optimization status.
Params:
Expand Down Expand Up @@ -1201,7 +1201,7 @@ uint normalizeSafety()(uint attrs)
auto trustedAllAttr(T)(scope return T t) @trusted
if (isFunctionPointer!T || isDelegate!T)
{
enum attrs = (functionAttributes!T & ~FunctionAttribute.system)
enum attrs = (functionAttributes!T & ~FunctionAttribute.system)
| FunctionAttribute.pure_
| FunctionAttribute.safe
| FunctionAttribute.nogc
Expand Down
Loading
0