Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
FitRoutines
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Antonino D'Anna
FitRoutines
Commits
083b215c
Commit
083b215c
authored
Apr 24, 2026
by
Antonino D'Anna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created FitRes struct
parent
a3d63b0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
2 deletions
+64
-2
src/FitRoutines.jl
src/FitRoutines.jl
+3
-1
src/fit_functions.jl
src/fit_functions.jl
+1
-1
src/types.jl
src/types.jl
+60
-0
No files found.
src/FitRoutines.jl
View file @
083b215c
...
@@ -6,6 +6,8 @@ using ADerrors, LsqFit, LinearAlgebra, ForwardDiff
...
@@ -6,6 +6,8 @@ using ADerrors, LsqFit, LinearAlgebra, ForwardDiff
include
(
"types.jl"
)
include
(
"types.jl"
)
include
(
"pvalue.jl"
)
include
(
"pvalue.jl"
)
include
(
"fit_functions.jl"
)
include
(
"fit_functions.jl"
)
include
(
"fit_scan.jl"
)
export
pvalue
,
fit_routine
export
pvalue
,
fit_routine
,
FitRes
,
fit_scan
end
# module FitRoutines
end
# module FitRoutines
src/fit_functions.jl
View file @
083b215c
...
@@ -119,7 +119,7 @@ function fit_routine(model::Function,
...
@@ -119,7 +119,7 @@ function fit_routine(model::Function,
println
(
logfile
,
"
\t\t
chiexp: "
,
chiexp
)
println
(
logfile
,
"
\t\t
chiexp: "
,
chiexp
)
println
(
logfile
,
"
\t\t
pvalue: "
,
pval
)
println
(
logfile
,
"
\t\t
pvalue: "
,
pval
)
return
(
par
=
par
,
chi2
=
chi2
,
chiexp
=
chiexp
,
pval
=
pval
)
return
FitRes
(
par
=
par
,
chi2
=
chi2
,
chiexp
=
chiexp
,
pval
=
pval
)
end
end
"""
"""
...
...
src/types.jl
View file @
083b215c
struct
FitRes
{
NT
<:
Union
{
NamedTuple
,
Nothing
}}
par
::
Union
{
Vector
{
uwreal
},
Missing
}
pval
::
Float64
chi2
::
Float64
chiexp
::
Float64
extra
::
NT
function
FitRes
(;
par
=
[],
pval
=
0.0
,
chi2
=
0.0
,
chiexp
=
0.0
,
extra
...
)
isempty
(
extra
)
&&
return
new
{
Nothing
}(
par
,
pval
,
chi2
,
chiexp
,
nothing
)
E
=
(;
extra
...
)
new
{
typeof
(
E
)}(
par
,
pval
,
chi2
,
chiexp
,(;
extra
...
))
end
end
import
Base
.
iterate
function
Base
.
iterate
(
f
::
FitRes
{
NT
},
state
=
1
)
where
NT
<:
NamedTuple
state
==
1
&&
(
return
(
:
par
=>
f
.
par
),
state
+
1
)
state
==
2
&&
(
return
(
:
pval
=>
f
.
pval
),
state
+
1
)
state
==
3
&&
(
return
(
:
chi2
=>
f
.
chi2
),
state
+
1
)
state
==
4
&&
(
return
(
:
chiexp
=>
f
.
chiexp
),
state
+
1
)
idx
=
state
-
4
idx
>
length
(
A
)
&&
return
nothing
return
(
keys
(
fit
.
extra
)[
i
]
=>
fit
.
extra
[
i
]),
state
+
1
end
function
Base
.
iterate
(
f
::
FitRes
{
Nothing
},
state
=
1
)
state
==
1
&&
(
return
(
:
par
=>
f
.
par
),
state
+
1
)
state
==
2
&&
(
return
(
:
pval
=>
f
.
pval
),
state
+
1
)
state
==
3
&&
(
return
(
:
chi2
=>
f
.
chi2
),
state
+
1
)
state
==
4
&&
(
return
(
:
chiexp
=>
f
.
chiexp
),
state
+
1
)
return
nothing
end
import
Base
:
print
function
__print_minimum_fit__
(
io
::
IO
,
f
::
FitRes
{
NT
})
where
NT
<:
Union
{
Nothing
,
NamedTuple
}
if
ismissing
(
f
.
par
)
print
(
io
,
"Failed fit: No parameter is available"
)
return
end
println
(
io
,
"Fit with
$
length(f.par) parameters: "
)
for
(
i
,
p
)
in
enumerate
(
f
.
par
)
println
(
io
,
"
\t
p_"
,
i
-
1
,
"=
\t
"
,
p
)
end
println
(
io
,
"
\t
pval =
\t
"
,
f
.
pval
)
println
(
io
,
"
\t
chi^2=
\t
"
,
f
.
chi2
,
"
\t
chi^2_exp="
,
f
.
chiexp
)
print
(
io
,
"
\t
chi^2/chi_exp = "
,
f
.
chi2
/
f
.
chiexp
)
end
print
(
io
::
IO
,
f
::
FitRes
{
Nothing
})
=
__print_minimum_fit__
(
io
,
f
)
function
print
(
io
::
IO
,
f
::
FitRes
{
NT
})
where
NT
<:
NamedTuple
__print_minimum_fit__
(
io
,
f
)
ismissing
(
f
.
par
)
&&
return
for
k
in
keys
(
f
.
extra
)
println
()
print
(
io
,
"
\t
"
,
k
,
"=
\t
"
,
getfield
(
f
.
extra
,
k
))
end
nothing
end
"""
"""
struct NoPrint
struct NoPrint
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment