Skip to content

Commit

Permalink
Merge pull request #24 from lendle/pull-request/b980dd1f
Browse files Browse the repository at this point in the history
Add runtests.jl and cleanup
  • Loading branch information
kmsquire committed Jul 8, 2014
2 parents ebb5898 + b980dd1 commit 83ec106
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/affprop.jl
Expand Up @@ -44,7 +44,7 @@ function affinity_propagation{T<:FloatingPoint}(S::Matrix{T}, opts::AffinityProp
exemplars[:, mod(n_iter-1, opts.n_stop_check)+1] = IC

if opts.display == :iter
@printf("%7d: %3d exemplars identified\n", n_iter, nnz(IC))
@printf("%7d: %3d exemplars identified\n", n_iter, countnz(IC))
end

if n_iter > opts.n_stop_check
Expand Down Expand Up @@ -91,7 +91,7 @@ function affprop_update_message!{T<:FloatingPoint}(psi::Matrix{T}, phi::Matrix{T
Y = SM[I]
SM[I] = -Inf
Y2 = maximum(SM)
val = S[i,:] - Y;
val = S[i,:] .- Y;
val[I] = S[i,I] - Y2;
phi[i,:] = opts.damp*phi[i,:] + (1-opts.damp)*val
end
Expand All @@ -101,7 +101,7 @@ function affprop_update_message!{T<:FloatingPoint}(psi::Matrix{T}, phi::Matrix{T
RP = phi[:,j]
idx = 1:n .!= j
RP[idx] = max(RP[idx], 0)
val = sum(RP) - RP;
val = sum(RP) .- RP;
val[idx] = min(val[idx], 0)
psi[:,j] = opts.damp*psi[:,j] + (1 - opts.damp)*val
end
Expand Down
9 changes: 6 additions & 3 deletions test/dbscan_test.jl
Expand Up @@ -6,7 +6,8 @@

module dbscan_tester

include("../src/dbscan.jl")
using Clustering
import Clustering: region_query, expand_cluster, DBSCAN

function MakeTestMatrix()
n = 125 # Number of points in the point cloud
Expand Down Expand Up @@ -125,12 +126,14 @@ function testDB()
return passed
end

end # end module

test_matrix = MakeTestMatrix()

println ("region_query test: ", testRegionQuery())
println ("expand_cluster test: ", testExpandCluster())
println ("dbscan test: ", testDB())


end # end module



11 changes: 11 additions & 0 deletions test/runtests.jl
@@ -0,0 +1,11 @@
testfiles = ["affprop.jl",
"dbscan_test.jl",
"kmeans.jl",
"kmedoids.jl",
"sil.jl"]

for fname in testfiles
println("Running $fname...")
include(fname)
end

0 comments on commit 83ec106

Please sign in to comment.