Skip to content

Remove use of old typealiases from StatsBase #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Clustering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Clustering
using Random

import Base: show
import StatsBase: IntegerVector, RealVector, RealMatrix, counts
import StatsBase: counts

export
# reexport from StatsBase
Expand Down
12 changes: 6 additions & 6 deletions src/seeding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct RandSeedAlg <: SeedingAlgorithm end
Initialize `iseeds` with the indices of cluster seeds for the `X` data matrix
using the `alg` seeding algorithm.
"""
function initseeds!(iseeds::IntegerVector, alg::RandSeedAlg, X::AbstractMatrix{<:Real};
function initseeds!(iseeds::AbstractVector{<:Integer}, alg::RandSeedAlg, X::AbstractMatrix{<:Real};
rng::AbstractRNG=Random.GLOBAL_RNG)
check_seeding_args(X, iseeds)
sample!(rng, 1:size(X, 2), iseeds; replace=false)
Expand All @@ -137,7 +137,7 @@ Here, `costs[i, j]` is the cost of assigning points ``i`` and ``j``
to the same cluster. One may, for example, use the squared Euclidean distance
between the points as the cost.
"""
function initseeds_by_costs!(iseeds::IntegerVector, alg::RandSeedAlg, X::AbstractMatrix{<:Real}; rng::AbstractRNG=Random.GLOBAL_RNG)
function initseeds_by_costs!(iseeds::AbstractVector{<:Integer}, alg::RandSeedAlg, X::AbstractMatrix{<:Real}; rng::AbstractRNG=Random.GLOBAL_RNG)
check_seeding_args(X, iseeds)
sample!(rng, 1:size(X,2), iseeds; replace=false)
end
Expand All @@ -157,7 +157,7 @@ proportional to the minimum cost of assigning it to the existing seeds.
"""
struct KmppAlg <: SeedingAlgorithm end

function initseeds!(iseeds::IntegerVector, alg::KmppAlg,
function initseeds!(iseeds::AbstractVector{<:Integer}, alg::KmppAlg,
X::AbstractMatrix{<:Real},
metric::PreMetric = SqEuclidean();
rng::AbstractRNG=Random.GLOBAL_RNG)
Expand Down Expand Up @@ -190,7 +190,7 @@ function initseeds!(iseeds::IntegerVector, alg::KmppAlg,
return iseeds
end

function initseeds_by_costs!(iseeds::IntegerVector, alg::KmppAlg,
function initseeds_by_costs!(iseeds::AbstractVector{<:Integer}, alg::KmppAlg,
costs::AbstractMatrix{<:Real};
rng::AbstractRNG=Random.GLOBAL_RNG)
n = size(costs, 1)
Expand Down Expand Up @@ -233,7 +233,7 @@ Choose the ``k`` points with the highest *centrality* as seeds.
"""
struct KmCentralityAlg <: SeedingAlgorithm end

function initseeds_by_costs!(iseeds::IntegerVector, alg::KmCentralityAlg,
function initseeds_by_costs!(iseeds::AbstractVector{<:Integer}, alg::KmCentralityAlg,
costs::AbstractMatrix{<:Real}; kwargs...)

n = size(costs, 1)
Expand All @@ -258,6 +258,6 @@ function initseeds_by_costs!(iseeds::IntegerVector, alg::KmCentralityAlg,
return iseeds
end

initseeds!(iseeds::IntegerVector, alg::KmCentralityAlg, X::AbstractMatrix{<:Real},
initseeds!(iseeds::AbstractVector{<:Integer}, alg::KmCentralityAlg, X::AbstractMatrix{<:Real},
metric::PreMetric = SqEuclidean(); kwargs...) =
initseeds_by_costs!(iseeds, alg, pairwise(metric, X, dims=2); kwargs...)