push
travis-ci-com
3 of 4 new or added lines in 1 file covered. (75.0%)
41 existing lines in 5 files now uncovered.282 of 341 relevant lines covered (82.7%)
92978252.18 hits per line
1 |
""" |
|
2 |
auc_trapezoidal(x::RealVector, y::RealVector) |
|
3 |
|
|
4 |
Computes the area under curve `(x,y)` using trapezoidal rule. |
|
5 |
""" |
|
6 |
function auc_trapezoidal(x::RealVector, y::RealVector) |
17,190✔ |
7 |
|
|
8 |
n = length(x) |
103,140✔ |
9 |
n == length(y) || throw(DimensionMismatch("Inconsistent lengths of `x` and `y`.")) |
68,760✔ |
10 |
|
|
11 |
if issorted(x)
|
137,520✔ |
12 |
prm = 1:n
|
4,248✔ |
13 |
elseif issorted(x; rev = true)
|
64,512✔ |
14 |
prm = n:-1:1 |
64,512✔ |
15 |
else
|
|
UNCOV
16
|
throw(ArgumentError("`x` must be sorted.")) |
× |
17 |
end |
|
18 |
|
|
19 |
val = zero(promote_type(eltype(x), eltype(y))) |
68,760✔ |
20 |
for i in 2:n |
137,520✔ |
21 |
Δx = x[prm[i]] - x[prm[i-1]] |
465,876,648✔ |
22 |
Δy = (y[prm[i]] + y[prm[i-1]])/2 |
465,876,648✔ |
23 |
if !(isnan(Δx) || isnan(Δy) || Δx == 0) |
931,753,296✔ |
24 |
val += Δx*Δy |
695,061,912✔ |
25 |
end |
|
26 |
end |
|
27 |
return val
|
68,760✔ |
28 |
end |
|
29 |
|
|
30 |
auc_trapezoidal(tpls::AbstractArray{<:Tuple}) = auc_trapezoidal.(tpls) |
11,520✔ |
31 |
auc_trapezoidal((x,y)::Tuple{RealVector, RealVector}) = auc_trapezoidal(x, y) |
81,984✔ |