Skip to content

Commit

Permalink
More tests and fix eltype and in
Browse files Browse the repository at this point in the history
  • Loading branch information
Liozou committed Apr 26, 2022
1 parent ea5c853 commit bb69570
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 52 deletions.
7 changes: 3 additions & 4 deletions src/algorithms/rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ConstMiniBitSet(l::AbstractVector{<:Integer}) = ConstMiniBitSet{UInt64}(l)
push(x::ConstMiniBitSet{T}, i::Integer) where {T} = _constminibitset(x.x | (one(T) << (i % UInt8)))
Base.union(x::ConstMiniBitSet, y::ConstMiniBitSet) = _constminibitset(x.x | y.x)
Base.intersect(x::ConstMiniBitSet, y::ConstMiniBitSet) = _constminibitset(x.x & y.x)
Base.in(x::ConstMiniBitSet{T}, i::Integer) where {T} = ((x.x >> (i % UInt8)) & one(T)) % Bool
Base.in(i::Integer, x::ConstMiniBitSet{T}) where {T} = ((x.x >> (i % UInt8)) & one(T)) % Bool
Base.setdiff(x::ConstMiniBitSet, y::ConstMiniBitSet) = _constminibitset(x.x & ~y.x)
Base.symdiff(x::ConstMiniBitSet, y::ConstMiniBitSet) = _constminibitset(x.x y.x)
Base.length(x::ConstMiniBitSet) = count_ones(x.x)
Expand Down Expand Up @@ -67,7 +67,6 @@ struct JunctionNode
end
JunctionNode() = JunctionNode(Int[], -one(SmallIntType), ConstMiniBitSet{UInt32}())
JunctionNode(head::Integer, num, roots::ConstMiniBitSet) = JunctionNode(Int[head], num, roots)
JunctionNode(num::Integer, ::Nothing) = JunctionNode(Int[], num, ConstMiniBitSet{UInt32}())
JunctionNode(root::Integer) = JunctionNode(1, zero(SmallIntType), ConstMiniBitSet{UInt32}(root))

function Base.show(io::IO, x::JunctionNode)
Expand Down Expand Up @@ -1039,7 +1038,7 @@ Base.length(ras::RingAttributions) = length(ras.attrs)
Base.eltype(::Type{RingAttributions{D}}) where {D} = RingIncluding{D}

function Base.show(io::IO, ras::RingAttributions)
println(io, typeof(ras), "(rings per node:", length.(ras.attrs), ')')
println(io, typeof(ras), "(rings per node: ", length.(ras.attrs), ')')
end

struct RingIncluding{D}
Expand All @@ -1053,7 +1052,7 @@ function Base.getindex(ri::RingIncluding{D}, j::Integer) where {D}
return PeriodicNeighborList{D}(.-ofs, newring)
end
Base.length(ri::RingIncluding) = length(ri.ras.attrs[ri.i])
Base.eltype(::Type{RingIncluding{D}}) where {D} = PeriodicNeighborList
Base.eltype(::Type{RingIncluding{D}}) where {D} = PeriodicNeighborList{D}

function Base.iterate(r::Union{RingAttributions,RingIncluding}, state=1)
(state % UInt) - 1 < length(r) ? ((@inbounds r[state]), state+1) : nothing
Expand Down
3 changes: 1 addition & 2 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function _precompile_()
@enforce Base.precompile(Tuple{typeof(intersect), CMBitSet{T}, CMBitSet{T}})
@enforce Base.precompile(Tuple{typeof(setdiff), CMBitSet{T}, CMBitSet{T}})
@enforce Base.precompile(Tuple{typeof(symdiff), CMBitSet{T}, CMBitSet{T}})
@enforce Base.precompile(Tuple{typeof(in), CMBitSet{T}, Int})
@enforce Base.precompile(Tuple{typeof(in), Int, CMBitSet{T}})
@enforce Base.precompile(Tuple{typeof(eltype), Type{CMBitSet{T}}})
@enforce Base.precompile(Tuple{typeof(length), CMBitSet{T}})
@enforce Base.precompile(Tuple{typeof(isempty), CMBitSet{T}})
Expand All @@ -48,7 +48,6 @@ function _precompile_()
@enforce Base.precompile(Tuple{Type{PeriodicGraphs.JunctionNode},Int,SmallIntT,CMBitSet{T}})
end
@enforce Base.precompile(Tuple{Type{PeriodicGraphs.JunctionNode}})
@enforce Base.precompile(Tuple{Type{PeriodicGraphs.JunctionNode},Int,Nothing})
@enforce Base.precompile(Tuple{Type{PeriodicGraphs.JunctionNode},Int})
@enforce Base.precompile(Tuple{typeof(PeriodicGraphs.unsafe_incr!),Ptr{SmallIntT}})
@enforce Base.precompile(Tuple{typeof(PeriodicGraphs.symdiff_cycles), Vector{Int}, Vector{Int}})
Expand Down
Loading

0 comments on commit bb69570

Please sign in to comment.