Skip to content

Commit 7ac3f70

Browse files
committed
sync wrt latest odrpack c-api
1 parent a6fc585 commit 7ac3f70

8 files changed

Lines changed: 36 additions & 39 deletions

File tree

src/odrpack/__odrpack.py.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ int odr_wrapper(int n,
132132

133133
// Define the overall user-supplied model function 'fcn'
134134
odrpack_fcn_t fcn = nullptr;
135-
fcn = [](const int *n, const int *m, const int *q, const int *npar, const double beta[],
136-
const double xplusd[], const int ifixb[], const int ifixx[],
137-
const int *ldifx, const int *ideval, double f[], double fjacb[],
138-
double fjacd[], int *istop) {
135+
fcn = [](const int *n, const int *m, const int *q, const int *npar, const int *ldifx,
136+
const double beta[], const double xplusd[], const int ifixb[], const int ifixx[],
137+
const int *ideval, double f[], double fjacb[], double fjacd[], int *istop) {
139138
// Create NumPy arrays that wrap the input C-style arrays, without copying the data
140139
nb::ndarray<const double, nb::numpy> beta_ndarray(beta, {static_cast<size_t>(*npar)});
141140
nb::ndarray<const double, nb::numpy> xplusd_ndarray(
@@ -409,9 +408,9 @@ tuple[int, int]
409408
result["npp"] = iwi.npp;
410409
result["idf"] = iwi.idf;
411410
result["job"] = iwi.job;
412-
result["iprin"] = iwi.iprin;
413-
result["luner"] = iwi.luner;
414-
result["lunrp"] = iwi.lunrp;
411+
result["iprint"] = iwi.iprint;
412+
result["lunerr"] = iwi.lunerr;
413+
result["lunrpt"] = iwi.lunrpt;
415414
result["nrow"] = iwi.nrow;
416415
result["ntol"] = iwi.ntol;
417416
result["neta"] = iwi.neta;
@@ -423,7 +422,7 @@ tuple[int, int]
423422
result["irank"] = iwi.irank;
424423
result["ldtt"] = iwi.ldtt;
425424
result["bound"] = iwi.bound;
426-
result["liwkmn"] = iwi.liwkmn;
425+
result["liwkmin"] = iwi.liwkmin;
427426
return result;
428427
},
429428
R"doc(
@@ -454,27 +453,27 @@ dict[str, int]
454453
std::map<std::string, int> result;
455454
result["delta"] = rwi.delta;
456455
result["eps"] = rwi.eps;
457-
result["xplus"] = rwi.xplus;
456+
result["xplusd"] = rwi.xplusd;
458457
result["fn"] = rwi.fn;
459458
result["sd"] = rwi.sd;
460459
result["vcv"] = rwi.vcv;
461460
result["rvar"] = rwi.rvar;
462461
result["wss"] = rwi.wss;
463-
result["wssde"] = rwi.wssde;
464-
result["wssep"] = rwi.wssep;
462+
result["wssdel"] = rwi.wssdel;
463+
result["wsseps"] = rwi.wsseps;
465464
result["rcond"] = rwi.rcond;
466465
result["eta"] = rwi.eta;
467-
result["olmav"] = rwi.olmav;
466+
result["olmavg"] = rwi.olmavg;
468467
result["tau"] = rwi.tau;
469468
result["alpha"] = rwi.alpha;
470469
result["actrs"] = rwi.actrs;
471470
result["pnorm"] = rwi.pnorm;
472-
result["rnors"] = rwi.rnors;
471+
result["rnorms"] = rwi.rnorms;
473472
result["prers"] = rwi.prers;
474-
result["partl"] = rwi.partl;
473+
result["partol"] = rwi.partol;
475474
result["sstol"] = rwi.sstol;
476-
result["taufc"] = rwi.taufc;
477-
result["epsma"] = rwi.epsma;
475+
result["taufac"] = rwi.taufac;
476+
result["epsmac"] = rwi.epsmac;
478477
result["beta0"] = rwi.beta0;
479478
result["betac"] = rwi.betac;
480479
result["betas"] = rwi.betas;
@@ -488,8 +487,8 @@ dict[str, int]
488487
result["fjacb"] = rwi.fjacb;
489488
result["we1"] = rwi.we1;
490489
result["diff"] = rwi.diff;
491-
result["delts"] = rwi.delts;
492-
result["deltn"] = rwi.deltn;
490+
result["deltas"] = rwi.deltas;
491+
result["deltan"] = rwi.deltan;
493492
result["t"] = rwi.t;
494493
result["tt"] = rwi.tt;
495494
result["omega"] = rwi.omega;
@@ -503,7 +502,7 @@ dict[str, int]
503502
result["wrk7"] = rwi.wrk7;
504503
result["lower"] = rwi.lower;
505504
result["upper"] = rwi.upper;
506-
result["lrwkmn"] = rwi.lrwkmn;
505+
result["lrwkmin"] = rwi.lrwkmin;
507506
return result;
508507
},
509508
R"doc(

src/odrpack/odr_fortran.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
from typing import Callable
33

44
import numpy as np
5-
from numpy.typing import NDArray
65

76
from odrpack.__odrpack import loc_iwork, loc_rwork
87
from odrpack.__odrpack import odr as _odr
98
from odrpack.__odrpack import workspace_dimensions
10-
from odrpack.result import OdrResult, I32Array, F64Array
9+
from odrpack.result import F64Array, I32Array, OdrResult
1110

1211
__all__ = ['odr']
1312

@@ -517,7 +516,7 @@ def fjacd_(x, beta): return fjacd(beta, x)
517516
beta=beta,
518517
delta=delta,
519518
eps=eps,
520-
xplus=x+delta,
519+
xplusd=x+delta,
521520
yest=y+eps,
522521
sd_beta=sd_beta,
523522
cov_beta=cov_beta,
@@ -530,8 +529,8 @@ def fjacd_(x, beta): return fjacd(beta, x)
530529
irank=iwork[iwork_idx['irank']],
531530
inv_condnum=rwork[rwork_idx['rcond']],
532531
sum_square=rwork[rwork_idx['wss']],
533-
sum_square_delta=rwork[rwork_idx['wssde']],
534-
sum_square_eps=rwork[rwork_idx['wssep']],
532+
sum_square_delta=rwork[rwork_idx['wssdel']],
533+
sum_square_eps=rwork[rwork_idx['wsseps']],
535534
iwork=iwork,
536535
rwork=rwork,
537536
)

src/odrpack/odr_scipy.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from typing import Callable, Literal
22

33
import numpy as np
4-
from numpy.typing import NDArray
54

65
from odrpack.__odrpack import loc_iwork, loc_rwork
76
from odrpack.__odrpack import odr as _odr
87
from odrpack.__odrpack import workspace_dimensions
9-
from odrpack.result import OdrResult, F64Array, BoolArray
8+
from odrpack.result import BoolArray, F64Array, OdrResult
109

1110
__all__ = ['odr_fit']
1211

@@ -528,7 +527,7 @@ def fdummy(x, beta): return np.array([np.nan]) # will never be called
528527
beta=beta,
529528
delta=delta,
530529
eps=eps,
531-
xplus=xdata+delta,
530+
xplusd=xdata+delta,
532531
yest=ydata+eps,
533532
sd_beta=sd_beta,
534533
cov_beta=cov_beta,
@@ -541,8 +540,8 @@ def fdummy(x, beta): return np.array([np.nan]) # will never be called
541540
irank=iwork[iwork_idx['irank']],
542541
inv_condnum=rwork[rwork_idx['rcond']],
543542
sum_square=rwork[rwork_idx['wss']],
544-
sum_square_delta=rwork[rwork_idx['wssde']],
545-
sum_square_eps=rwork[rwork_idx['wssep']],
543+
sum_square_delta=rwork[rwork_idx['wssdel']],
544+
sum_square_eps=rwork[rwork_idx['wsseps']],
546545
iwork=iwork,
547546
rwork=rwork,
548547
)

src/odrpack/result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OdrResult():
2323
Differences between the observed and fitted `x` values.
2424
eps : F64Array
2525
Differences between the observed and fitted `y` values.
26-
xplus : F64Array
26+
xplusd : F64Array
2727
Adjusted `x` values after fitting, `x + delta`.
2828
yest : F64Array
2929
Estimated `y` values corresponding to the fitted model, `y + eps`.
@@ -63,7 +63,7 @@ class OdrResult():
6363
beta: F64Array
6464
delta: F64Array
6565
eps: F64Array
66-
xplus: F64Array
66+
xplusd: F64Array
6767
yest: F64Array
6868
sd_beta: F64Array
6969
cov_beta: F64Array

subprojects/odrpack95.wrap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[wrap-git]
22
url = https://github.com/HugoMVale/odrpack95.git
3-
# revision = v1.0.1
4-
revision = HEAD
3+
revision = v2.0.1
4+
# revision = HEAD
55
depth = 1
66

77
[provide]

tests/test_bindings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def test_dimension_consistency():
3535
dims = workspace_dimensions(n, m, q, npar, isodr)
3636
iwork_idx = loc_iwork(m, q, npar)
3737
rwork_idx = loc_rwork(n, m, q, npar, ldwe=1, ld2we=1, isodr=isodr)
38-
assert dims[0] >= rwork_idx['lrwkmn']
39-
assert dims[1] >= iwork_idx['liwkmn']
38+
assert dims[0] >= rwork_idx['lrwkmin']
39+
assert dims[1] >= iwork_idx['liwkmin']
4040

4141

4242
def test_odr():

tests/test_odr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,13 @@ def test_parameters(case1):
391391
partol = 0.456
392392
sol = odr(**case1, partol=partol)
393393
assert sol.info == 2
394-
assert np.isclose(sol.rwork[rwork_idx['partl']], partol)
394+
assert np.isclose(sol.rwork[rwork_idx['partol']], partol)
395395

396396
# taufac
397397
taufac = 0.6969
398398
sol = odr(**case1, taufac=taufac)
399399
assert sol.info == 1
400-
assert np.isclose(sol.rwork[rwork_idx['taufc']], taufac)
400+
assert np.isclose(sol.rwork[rwork_idx['taufac']], taufac)
401401

402402

403403
def test_restart(case1):

tests/test_odr_fit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,13 @@ def test_parameters(case1):
408408
partol = 0.456
409409
sol = odr_fit(**case1, partol=partol)
410410
assert sol.info == 2
411-
assert np.isclose(sol.rwork[rwork_idx['partl']], partol)
411+
assert np.isclose(sol.rwork[rwork_idx['partol']], partol)
412412

413413
# taufac
414414
taufac = 0.6969
415415
sol = odr_fit(**case1, taufac=taufac)
416416
assert sol.info == 1
417-
assert np.isclose(sol.rwork[rwork_idx['taufc']], taufac)
417+
assert np.isclose(sol.rwork[rwork_idx['taufac']], taufac)
418418

419419

420420
def test_rptfile_and_errfile(case1):

0 commit comments

Comments
 (0)