Skip to content

Commit f9df7e8

Browse files
committed
test cov
1 parent efcbca6 commit f9df7e8

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/utils.jl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,19 @@ From https://github.com/rdeits/NNLS.jl/blob/0a9bf56774595b5735bc738723bd3cb94138
2727
end
2828

2929
"""
30-
squashsorted(v)
30+
mintype(v)
3131
32-
Returns the sorted vector `v` converted to the smallest possible
33-
integer type that can fit all values.
32+
Returns the minimum integer type required to fit all elements
33+
in sorted vector `v`.
3434
3535
### Implementation Notes
3636
`v` is assumed to be sorted.
3737
"""
38-
function squashsorted(v::AbstractVector)
39-
validtypes = [UInt8, UInt16, UInt32, UInt64, UInt128]
40-
l = v[end]
41-
for T in validtypes
42-
l < typemax(T) && return convert(Vector{T}, v)
43-
end
44-
return v
45-
end
46-
4738
function mintype(v::AbstractVector)
4839
validtypes = [UInt8, UInt16, UInt32, UInt64, UInt128]
4940
l = v[end]
5041
for T in validtypes
51-
l < typemax(T) && return T
42+
l <= typemax(T) && return T
5243
end
5344
return eltype(v)
5445
end

test/runtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ const testdir = dirname(@__FILE__)
3939
@test testfn(outdegree)
4040
@test testfn(outdegree, 1)
4141

42-
@test @inferred has_edge(hu, 1, 2)
43-
@test @inferred !has_edge(hu, 1, 5)
42+
@test @inferred has_edge(hu, 1, 3)
43+
@test @inferred has_edge(hu, 3, 1)
44+
@test @inferred !has_edge(hu, 2, 3)
45+
@test @inferred !has_edge(hu, 3, 2)
4446
@test @inferred !has_edge(hu, 1, 10)
4547
@test @inferred has_vertex(hu, 1)
4648
@test @inferred !has_vertex(hu, 10)

0 commit comments

Comments
 (0)