diff --git a/docs/src/changelog.md b/docs/src/changelog.md index a7a76ff..df6dae5 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -6,6 +6,7 @@ ### Fixed - error when constructing [`MCMCData`](@ref) with input distance matrix that has non-zero diagonal entries. +- edge case for [`fitprior2'](@ref) when `Kmin = Kmax = 1` or `Kmin = Kmax = N` generates a warning and fallback to default repulsion/cohesion parameters. ## [1.2.0] ### Added diff --git a/src/prior.jl b/src/prior.jl index 87f141d..e1bec9c 100644 --- a/src/prior.jl +++ b/src/prior.jl @@ -232,8 +232,7 @@ function fitprior2( u, v = Distributions.params(fitp) # Generate prior on K - Kprior = Float64.(counts(sampleK(η, σ, u, v, maximum([10000, 100 * N]), N))) - Kprior ./= sum(Kprior) + Kprior = pmf(sampleK(η, σ, u, v, maximum([10000, 100 * N]), N)) append!(Kprior, zeros(N - length(Kprior))) # Compute likelihood parameters @@ -243,15 +242,29 @@ function fitprior2( append!(wtsB, fill(Kprior[k], szB[k])) end A = reduce(append!, A[Kmin:Kmax]) + if isempty(A) # A is empty + @warn "The ensemble of clusterings has only one clustering, consisting of all singletons. This might be because you have set Kmin = Kmax = number of points. Falling back to defaults for cohesion parameters." + δ1 = 1 + α = 1 + β = 1 + else + fitA = fit_mle(Gamma, A, wtsA) + δ1 = shape(fitA) + α = sum(szA[Kmin:Kmax] .* Kprior[Kmin:Kmax]) * δ1 + β = sum(A .* wtsA) + end B = reduce(append!, B[Kmin:Kmax]) - fitA = fit_mle(Gamma, A, wtsA) - δ1 = shape(fitA) - α = sum(szA[Kmin:Kmax] .* Kprior[Kmin:Kmax]) * δ1 - β = sum(A .* wtsA) - fitB = fit_mle(Gamma, B, wtsB) - δ2 = shape(fitB) - ζ = sum(szB[Kmin:Kmax] .* Kprior[Kmin:Kmax]) * δ2 - γ = sum(B .* wtsB) + if isempty(B) + @warn "The ensemble of clusterings has only one clustering, consisting of a single cluster. This might be because you have set Kmin = Kmax = 1. Falling back to defaults for repulsion parameters." + δ2 = 1 + ζ = 1 + γ = 1 + else + fitB = fit_mle(Gamma, B, wtsB) + δ2 = shape(fitB) + ζ = sum(szB[Kmin:Kmax] .* Kprior[Kmin:Kmax]) * δ2 + γ = sum(B .* wtsB) + end params = PriorHyperparamsList( δ1 = δ1, @@ -351,4 +364,11 @@ function detectknee( # Max distance point maxind = argmax(distances) x[maxind], y[maxind] +end + +function pmf(X::AbstractVector{<:Integer}) + xmin = minimum(X) + p = counts(X)./length(X) + p = [zeros(xmin-1); p] + return p end \ No newline at end of file diff --git a/test/Manifest.toml b/test/Manifest.toml index eee5891..8ca48b9 100644 --- a/test/Manifest.toml +++ b/test/Manifest.toml @@ -1,8 +1,48 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.8.1" +julia_version = "1.8.2" manifest_format = "2.0" -project_hash = "8f6fbf937c2d3bb3ac923885056e2beace909bc7" +project_hash = "50875ce1632b9cf62c778e866540fb7c81fd550e" + +[[deps.Adapt]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "0310e08cb19f5da31d08341c6120c047598f5b9c" +uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +version = "3.5.0" + +[[deps.ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "1.1.1" + +[[deps.ArrayInterface]] +deps = ["ArrayInterfaceCore", "Compat", "IfElse", "LinearAlgebra", "SnoopPrecompile", "Static"] +git-tree-sha1 = "dedc16cbdd1d32bead4617d27572f582216ccf23" +uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" +version = "6.0.25" + +[[deps.ArrayInterfaceCore]] +deps = ["LinearAlgebra", "SnoopPrecompile", "SparseArrays", "SuiteSparse"] +git-tree-sha1 = "e5f08b5689b1aad068e01751889f2f615c7db36d" +uuid = "30b0a656-2188-435a-8636-2ec0e6a096e2" +version = "0.1.29" + +[[deps.ArrayInterfaceOffsetArrays]] +deps = ["ArrayInterface", "OffsetArrays", "Static"] +git-tree-sha1 = "3d1a9a01976971063b3930d1aed1d9c4af0817f8" +uuid = "015c0d05-e682-4f19-8f0a-679ce4c54826" +version = "0.1.7" + +[[deps.ArrayInterfaceStaticArrays]] +deps = ["Adapt", "ArrayInterface", "ArrayInterfaceCore", "ArrayInterfaceStaticArraysCore", "LinearAlgebra", "Static", "StaticArrays"] +git-tree-sha1 = "f12dc65aef03d0a49650b20b2fdaf184928fd886" +uuid = "b0d46f97-bff5-4637-a19a-dd75974142cd" +version = "0.1.5" + +[[deps.ArrayInterfaceStaticArraysCore]] +deps = ["Adapt", "ArrayInterfaceCore", "LinearAlgebra", "StaticArraysCore"] +git-tree-sha1 = "93c8ba53d8d26e124a5a8d4ec914c3a16e6a0970" +uuid = "dd5226c6-a4d4-4bc7-8575-46859f9c95b9" +version = "0.1.3" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -10,6 +50,24 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +[[deps.BitTwiddlingConvenienceFunctions]] +deps = ["Static"] +git-tree-sha1 = "0c5f81f47bbbcf4aea7b2959135713459170798b" +uuid = "62783981-4cbd-42fc-bca8-16325de8dc4b" +version = "0.1.5" + +[[deps.CPUSummary]] +deps = ["CpuId", "IfElse", "Static"] +git-tree-sha1 = "5b735f654bdfd7b6c18c49f1d3ebff34b4b8af43" +uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" +version = "0.2.1" + +[[deps.Calculus]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad" +uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" +version = "0.5.1" + [[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra", "SparseArrays"] git-tree-sha1 = "e7ff6cadf743c098e08fca25c91103ee4303c9bb" @@ -22,12 +80,24 @@ git-tree-sha1 = "38f7a08f19d8810338d4f5085211c7dfa5d5bdd8" uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" version = "0.1.4" +[[deps.CloseOpenIntervals]] +deps = ["ArrayInterface", "Static"] +git-tree-sha1 = "d61300b9895f129f4bd684b2aff97cf319b6c493" +uuid = "fb6a15b2-703c-40df-9091-08a04967cfa9" +version = "0.1.11" + [[deps.Clustering]] deps = ["Distances", "LinearAlgebra", "NearestNeighbors", "Printf", "Random", "SparseArrays", "Statistics", "StatsBase"] git-tree-sha1 = "64df3da1d2a26f4de23871cd1b6482bb68092bd5" uuid = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" version = "0.14.3" +[[deps.CommonSubexpressions]] +deps = ["MacroTools", "Test"] +git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7" +uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" +version = "0.3.0" + [[deps.Compat]] deps = ["Dates", "LinearAlgebra", "UUIDs"] git-tree-sha1 = "3ca828fe1b75fa84b021a7860bd039eaea84d2f2" @@ -39,6 +109,12 @@ deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" version = "0.5.2+0" +[[deps.CpuId]] +deps = ["Markdown"] +git-tree-sha1 = "fcbb72b032692610bfbdb15018ac16a36cf2e406" +uuid = "adafc99b-e345-5852-983c-f28acb93d879" +version = "0.3.1" + [[deps.DataAPI]] git-tree-sha1 = "46d2680e618f8abd007bce0c3026cb0c4a8f2032" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" @@ -54,18 +130,97 @@ version = "0.18.13" deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" +[[deps.DensityInterface]] +deps = ["InverseFunctions", "Test"] +git-tree-sha1 = "80c3e8639e3353e5d2912fb3a1916b8455e2494b" +uuid = "b429d917-457f-4dbc-8f4c-0cc954292b1d" +version = "0.4.0" + +[[deps.DiffResults]] +deps = ["StaticArraysCore"] +git-tree-sha1 = "782dd5f4561f5d267313f23853baaaa4c52ea621" +uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" +version = "1.1.0" + +[[deps.DiffRules]] +deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"] +git-tree-sha1 = "c5b6685d53f933c11404a3ae9822afe30d522494" +uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" +version = "1.12.2" + [[deps.Distances]] deps = ["LinearAlgebra", "SparseArrays", "Statistics", "StatsAPI"] git-tree-sha1 = "3258d0659f812acde79e8a74b11f17ac06d0ca04" uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" version = "0.10.7" +[[deps.Distributions]] +deps = ["ChainRulesCore", "DensityInterface", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns", "Test"] +git-tree-sha1 = "74911ad88921455c6afcad1eefa12bd7b1724631" +uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" +version = "0.25.80" + [[deps.DocStringExtensions]] deps = ["LibGit2"] git-tree-sha1 = "5158c2b41018c5f7eb1470d558127ac274eca0c9" uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" version = "0.9.1" +[[deps.Downloads]] +deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +version = "1.6.0" + +[[deps.DualNumbers]] +deps = ["Calculus", "NaNMath", "SpecialFunctions"] +git-tree-sha1 = "5837a837389fccf076445fce071c8ddaea35a566" +uuid = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74" +version = "0.6.8" + +[[deps.FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" + +[[deps.FillArrays]] +deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"] +git-tree-sha1 = "d3ba08ab64bdfd27234d3f61956c966266757fe6" +uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" +version = "0.13.7" + +[[deps.ForwardDiff]] +deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"] +git-tree-sha1 = "a69dd6db8a809f78846ff259298678f0d6212180" +uuid = "f6369f11-7733-5829-9624-2563aa707210" +version = "0.10.34" + +[[deps.HDF5]] +deps = ["Compat", "HDF5_jll", "Libdl", "Mmap", "Random", "Requires", "UUIDs"] +git-tree-sha1 = "b5df7c3cab3a00c33c2e09c6bd23982a75e2fbb2" +uuid = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" +version = "0.16.13" + +[[deps.HDF5_jll]] +deps = ["Artifacts", "JLLWrappers", "LibCURL_jll", "Libdl", "OpenSSL_jll", "Pkg", "Zlib_jll"] +git-tree-sha1 = "4cc2bb72df6ff40b055295fdef6d92955f9dede8" +uuid = "0234f1f7-429e-5d53-9886-15a909be8d59" +version = "1.12.2+2" + +[[deps.HostCPUFeatures]] +deps = ["BitTwiddlingConvenienceFunctions", "IfElse", "Libdl", "Static"] +git-tree-sha1 = "f64b890b2efa4de81520d2b0fbdc9aadb65bdf53" +uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0" +version = "0.1.13" + +[[deps.HypergeometricFunctions]] +deps = ["DualNumbers", "LinearAlgebra", "OpenLibm_jll", "SpecialFunctions", "Test"] +git-tree-sha1 = "709d864e3ed6e3545230601f94e11ebc65994641" +uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a" +version = "0.3.11" + +[[deps.IfElse]] +git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1" +uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" +version = "0.1.1" + [[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" @@ -81,10 +236,37 @@ git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151" uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" version = "0.1.1" +[[deps.JLLWrappers]] +deps = ["Preferences"] +git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" +uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" +version = "1.4.1" + +[[deps.LayoutPointers]] +deps = ["ArrayInterface", "ArrayInterfaceOffsetArrays", "ArrayInterfaceStaticArrays", "LinearAlgebra", "ManualMemory", "SIMDTypes", "Static"] +git-tree-sha1 = "7e34177793212f6d64d045ee47d2883f09fffacc" +uuid = "10f19ff3-798f-405d-979b-55457f8fc047" +version = "0.1.12" + +[[deps.LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" +version = "0.6.3" + +[[deps.LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" +version = "7.84.0+0" + [[deps.LibGit2]] deps = ["Base64", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +[[deps.LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.10.2+0" + [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -101,16 +283,51 @@ version = "0.3.18" [[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +[[deps.LoopVectorization]] +deps = ["ArrayInterface", "ArrayInterfaceCore", "ArrayInterfaceOffsetArrays", "ArrayInterfaceStaticArrays", "CPUSummary", "ChainRulesCore", "CloseOpenIntervals", "DocStringExtensions", "ForwardDiff", "HostCPUFeatures", "IfElse", "LayoutPointers", "LinearAlgebra", "OffsetArrays", "PolyesterWeave", "SIMDDualNumbers", "SIMDTypes", "SLEEFPirates", "SnoopPrecompile", "SpecialFunctions", "Static", "ThreadingUtilities", "UnPack", "VectorizationBase"] +git-tree-sha1 = "c3a7202222318121bf1db4547a27a1afd0cf9b88" +uuid = "bdcacae8-1622-11e9-2a5c-532679323890" +version = "0.12.148" + +[[deps.MacroTools]] +deps = ["Markdown", "Random"] +git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2" +uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" +version = "0.5.10" + +[[deps.ManualMemory]] +git-tree-sha1 = "bcaef4fc7a0cfe2cba636d84cda54b5e4e4ca3cd" +uuid = "d125e4d3-2237-4719-b19c-fa641b8a4667" +version = "0.1.8" + [[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +[[deps.MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.0+0" + [[deps.Missings]] deps = ["DataAPI"] git-tree-sha1 = "bf210ce90b6c9eed32d25dbcae1ebc565df2687f" uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" version = "1.0.2" +[[deps.Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[deps.MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" +version = "2022.2.1" + +[[deps.NaNMath]] +deps = ["OpenLibm_jll"] +git-tree-sha1 = "a7c3d1da1189a1c2fe843a3bfa04d18d20eb3211" +uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" +version = "1.0.1" + [[deps.NearestNeighbors]] deps = ["Distances", "StaticArrays"] git-tree-sha1 = "440165bf08bc500b8fe4a7be2dc83271a00c0716" @@ -121,31 +338,148 @@ version = "0.4.12" uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" version = "1.2.0" +[[deps.OffsetArrays]] +deps = ["Adapt"] +git-tree-sha1 = "f71d8950b724e9ff6110fc948dff5a329f901d64" +uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +version = "1.12.8" + [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" version = "0.3.20+0" +[[deps.OpenLibm_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "05823500-19ac-5b8b-9628-191a04bc5112" +version = "0.8.1+0" + +[[deps.OpenSSL_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "f6e9dba33f9f2c44e08a020b0caf6903be540004" +uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" +version = "1.1.19+0" + +[[deps.OpenSpecFun_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" +uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" +version = "0.5.5+0" + [[deps.OrderedCollections]] git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" version = "1.4.1" +[[deps.PDMats]] +deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"] +git-tree-sha1 = "cf494dca75a69712a72b80bc48f59dcf3dea63ec" +uuid = "90014a1f-27ba-587c-ab20-58faa44d9150" +version = "0.11.16" + +[[deps.Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +version = "1.8.0" + +[[deps.PolyesterWeave]] +deps = ["BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "Static", "ThreadingUtilities"] +git-tree-sha1 = "5d0a598c95f67ee0787723e38745cb954d143684" +uuid = "1d0040c9-8b98-4ee7-8388-3f51789ca0ad" +version = "0.2.0" + +[[deps.Preferences]] +deps = ["TOML"] +git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" +uuid = "21216c6a-2e73-6563-6e65-726566657250" +version = "1.3.0" + [[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +[[deps.ProgressBars]] +deps = ["Printf"] +git-tree-sha1 = "806ebc92e1b4b4f72192369a28dfcaf688566b2b" +uuid = "49802e3a-d2f1-5c88-81d8-b72133a6f568" +version = "1.4.1" + +[[deps.QuadGK]] +deps = ["DataStructures", "LinearAlgebra"] +git-tree-sha1 = "de191bc385072cc6c7ed3ffdc1caeed3f22c74d4" +uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +version = "2.7.0" + +[[deps.REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + [[deps.Random]] deps = ["SHA", "Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +[[deps.RedClust]] +deps = ["Clustering", "Dates", "Distances", "Distributions", "HDF5", "LinearAlgebra", "LoopVectorization", "Printf", "ProgressBars", "Random", "SpecialFunctions", "StaticArrays", "StatsBase"] +path = "c:\\Users\\Abhinav\\OneDrive\\Projects\\Julia Packages\\RedClust\\test\\.." +uuid = "bf1adee6-87fe-4679-8d23-51fe99940a25" +version = "1.2.1" + +[[deps.Reexport]] +git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" +uuid = "189a3867-3050-52da-a836-e630ba90ab69" +version = "1.2.2" + +[[deps.Requires]] +deps = ["UUIDs"] +git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7" +uuid = "ae029012-a4dd-5104-9daa-d747884805df" +version = "1.3.0" + +[[deps.Rmath]] +deps = ["Random", "Rmath_jll"] +git-tree-sha1 = "bf3188feca147ce108c76ad82c2792c57abe7b1f" +uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa" +version = "0.7.0" + +[[deps.Rmath_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "68db32dff12bb6127bac73c209881191bf0efbb7" +uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f" +version = "0.3.0+0" + [[deps.SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" version = "0.7.0" +[[deps.SIMDDualNumbers]] +deps = ["ForwardDiff", "IfElse", "SLEEFPirates", "VectorizationBase"] +git-tree-sha1 = "dd4195d308df24f33fb10dde7c22103ba88887fa" +uuid = "3cdde19b-5bb0-4aaf-8931-af3e248e098b" +version = "0.1.1" + +[[deps.SIMDTypes]] +git-tree-sha1 = "330289636fb8107c5f32088d2741e9fd7a061a5c" +uuid = "94e857df-77ce-4151-89e5-788b33177be4" +version = "0.1.0" + +[[deps.SLEEFPirates]] +deps = ["IfElse", "Static", "VectorizationBase"] +git-tree-sha1 = "cda0aece8080e992f6370491b08ef3909d1c04e7" +uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa" +version = "0.6.38" + [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" +[[deps.SnoopPrecompile]] +deps = ["Preferences"] +git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c" +uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" +version = "1.0.3" + +[[deps.Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + [[deps.SortingAlgorithms]] deps = ["DataStructures"] git-tree-sha1 = "b3363d7460f7d098ca0912c69b082f75625d7508" @@ -156,6 +490,18 @@ version = "1.0.1" deps = ["LinearAlgebra", "Random"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +[[deps.SpecialFunctions]] +deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] +git-tree-sha1 = "d75bda01f8c31ebb72df80a46c88b25d1c79c56d" +uuid = "276daf66-3868-5448-9aa4-cd146d93841b" +version = "2.1.7" + +[[deps.Static]] +deps = ["IfElse"] +git-tree-sha1 = "c35b107b61e7f34fa3f124026f2a9be97dea9e1c" +uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" +version = "0.8.3" + [[deps.StaticArrays]] deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"] git-tree-sha1 = "f86b3a049e5d05227b10e15dbb315c5b90f14988" @@ -183,18 +529,70 @@ git-tree-sha1 = "d1bf48bfcc554a3761a133fe3a9bb01488e06916" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" version = "0.33.21" +[[deps.StatsFuns]] +deps = ["ChainRulesCore", "HypergeometricFunctions", "InverseFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] +git-tree-sha1 = "ab6083f09b3e617e34a956b43e9d51b824206932" +uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c" +version = "1.1.1" + +[[deps.SuiteSparse]] +deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] +uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" + +[[deps.TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +version = "1.0.0" + +[[deps.Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +version = "1.10.1" + [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +[[deps.ThreadingUtilities]] +deps = ["ManualMemory"] +git-tree-sha1 = "f8629df51cab659d70d2e5618a430b4d3f37f2c3" +uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5" +version = "0.5.0" + [[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +[[deps.UnPack]] +git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b" +uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" +version = "1.0.2" + [[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +[[deps.VectorizationBase]] +deps = ["ArrayInterface", "CPUSummary", "HostCPUFeatures", "IfElse", "LayoutPointers", "Libdl", "LinearAlgebra", "SIMDTypes", "Static"] +git-tree-sha1 = "4c59c2df8d2676c4691a39fa70495a6db0c5d290" +uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f" +version = "0.21.58" + +[[deps.Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.12+3" + [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" version = "5.1.1+0" + +[[deps.nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" +version = "1.48.0+0" + +[[deps.p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +version = "17.4.0+0" diff --git a/test/Project.toml b/test/Project.toml index bf6a859..4ff765e 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,5 +1,6 @@ [deps] Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +RedClust = "bf1adee6-87fe-4679-8d23-51fe99940a25" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 529398a..28dcb03 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,14 @@ +local_build = "CI" ∉ keys(ENV) +if local_build # if we are local + using Pkg + Pkg.activate(@__DIR__) + Pkg.develop(Pkg.PackageSpec(path = joinpath(@__DIR__, ".."))) + Pkg.instantiate() +end using RedClust, Test, Clustering using StatsBase: sample + macro throws(expr) quote try diff --git a/test/test_fitprior.jl b/test/test_fitprior.jl index b1de514..00202ab 100644 --- a/test/test_fitprior.jl +++ b/test/test_fitprior.jl @@ -3,7 +3,7 @@ @test_nothrow fitprior(distM, "k-medoids", true; verbose = false) # kmedoids with distances, Julia @test_logs (:warn,) global params = fitprior(pnts, "k-means", false; verbose = false, Kmin = 1, Kmax = 1) # check edge case Kmax = 2 @test params.K_initial == 1 -@test_logs (:warn,) global params = fitprior(pnts, "k-means", false; verbose = false, Kmin = N, Kmax = N) # check edge case Kmin = N-1 +@test_logs (:warn,) global params = fitprior(pnts, "k-means", false; verbose = false, Kmin = N, Kmax = N) # check edge case Kmin = N @test params.K_initial == N @test_throws ArgumentError fitprior(distM, "hierarchical", true; verbose = false) # check that only 2 methods allowed @test_throws ArgumentError fitprior(pnts, "k-means", true; verbose = false) # check that dist is disregarded when pnts is supplied @@ -19,5 +19,5 @@ @test_nothrow fitprior2(distM, "k-medoids", true; verbose = false) # kmedoids with distances, Julia @test_logs (:warn,) global params = fitprior2(pnts, "k-means", false; verbose = false, Kmin = 1, Kmax = 1) # check edge case Kmax = 2 @test params.K_initial == 1 -@test_logs (:warn,) global params = fitprior2(pnts, "k-means", false; verbose = false, Kmin = N, Kmax = N) # check edge case Kmin = N-1 +@test_logs (:warn,) global params = fitprior2(pnts, "k-means", false; verbose = false, Kmin = N, Kmax = N) # check edge case Kmin = N @test params.K_initial == N \ No newline at end of file