Mercurial > repos > public > sbplib_julia
annotate test/test_utils.jl @ 703:988e9cfcd58d feature/laplace_opset
Add function for == comparison of the fields for a struct, and apply to Laplace tests
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 15 Feb 2021 17:20:03 +0100 |
parents | |
children |
rev | line source |
---|---|
703
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
1 """ |
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
2 cmp_fields(s1,s2) |
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
3 |
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
4 Compares the fields of two structs s1, s2, using the == operator. |
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
5 """ |
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
6 function cmp_fields(s1::T,s2::T) where T |
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
7 f = fieldnames(T) |
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
8 return getfield.(Ref(s1),f) == getfield.(Ref(s2),f) |
988e9cfcd58d
Add function for == comparison of the fields for a struct, and apply to Laplace tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
9 end |