Skip to content

Commit 8ca611a

Browse files
todonnellclaude
andcommitted
Port to Julia 1.11: Graphs.jl, modern CSV, AbstractString types
- Replace LightGraphs (archived) with Graphs.jl (drop-in replacement) - Remove CSV 0.8.5 pin, allow CSV 0.10+ - Change String -> AbstractString in distribution signatures to handle CSV.jl's String3/String31 types (from PR probcomp#26 by limarta) - Rename proposal_dummy_value -> PROPOSAL_DUMMY_VALUE (constant convention) - Remove unused deps: BenchmarkTools, DelimitedFiles, Interpolations, Memoize, Plots, Polynomials, PyPlot, Revise, StatsBase - Add [compat] bounds for all dependencies - Tested: loads and precompiles on Julia 1.11.9 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6779154 commit 8ca611a

8 files changed

Lines changed: 20 additions & 23 deletions

File tree

Project.toml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ authors = ["alex-lew <alexl.mail@gmail.com>"]
44
version = "0.1.0"
55

66
[deps]
7-
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
87
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
98
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
109
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
11-
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
1210
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
13-
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
11+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1412
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
15-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
1613
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
17-
Memoize = "c03570c3-d221-55d1-a50c-7939bbd78826"
18-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
19-
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
20-
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
21-
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
22-
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
2314
StringDistances = "88034a9c-02f8-509d-84a9-84ec65e18404"
2415

2516
[compat]
26-
CSV = "0.8.5"
17+
julia = "1.10"
18+
CSV = "0.10"
19+
DataFrames = "1"
20+
Distributions = "0.25"
21+
Graphs = "1"
22+
MacroTools = "0.5"
23+
StringDistances = "0.11"

src/PClean.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module PClean
22

33
using Distributions
4-
using LightGraphs
4+
using Graphs
55
using CSV
66
using DataFrames: DataFrame
77

src/distributions/add_typos.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ end
3333

3434
const IMPOSSIBLE = -1e5
3535

36-
random(::AddTypos, word::String, max_typos=nothing) = begin
36+
random(::AddTypos, word::AbstractString, max_typos=nothing) = begin
3737
num_typos = rand(NegativeBinomial(ceil(length(word) / 5.0), 0.9))
3838
num_typos = isnothing(max_typos) ? num_typos : min(max_typos, num_typos)
3939
for i=1:num_typos
@@ -47,7 +47,7 @@ end
4747
const add_typos_density_dict = Dict{Tuple{String, String}, Float64}()
4848
const LETTERS_PER_TYPO = 5.0
4949

50-
logdensity(::AddTypos, observed::Union{String,Missing}, word::String, max_typos=nothing) = begin
50+
logdensity(::AddTypos, observed::Union{<:AbstractString,Missing}, word::AbstractString, max_typos=nothing) = begin
5151
if ismissing(observed)
5252
return 0.0
5353
end

src/distributions/distributions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function random end
55
function logdensity end
66

77
struct ProposalDummyValue end
8-
const proposal_dummy_value = ProposalDummyValue()
8+
const PROPOSAL_DUMMY_VALUE = ProposalDummyValue()
99

1010
# Can this distribution enumerate values on which
1111
# its posterior support is concentrated? If the distribution's

src/distributions/string_prior.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ const alphabet_lookup = Dict([l => i for (i, l) in enumerate(alphabet)])
1313
has_discrete_proposal(::StringPrior) = true
1414

1515
# Assume proposal_atoms are unique.
16-
function discrete_proposal(::StringPrior, min_length::Int, max_length::Int, proposal_atoms::Vector{String})::Tuple{Vector{Union{String, ProposalDummyValue}}, Vector{Float64}}
17-
options = Union{String, ProposalDummyValue}[proposal_atoms..., proposal_dummy_value]
16+
function discrete_proposal(::StringPrior, min_length::Int, max_length::Int, proposal_atoms::Vector{T})::Tuple{Vector{Union{T, ProposalDummyValue}}, Vector{Float64}} where T<:AbstractString
17+
options = Union{T, ProposalDummyValue}[proposal_atoms..., PROPOSAL_DUMMY_VALUE]
1818
probs = map(s -> logdensity(StringPrior(), s, min_length, max_length, proposal_atoms), proposal_atoms)
1919
total = logsumexp(probs)
2020
probs = Float64[probs..., log1p(-exp(total))]
2121
return (options, probs)
2222
end
2323

24-
discrete_proposal_dummy_value(::StringPrior, min_length::Int, max_length::Int, proposal_atoms::Vector{String}) = begin
24+
discrete_proposal_dummy_value(::StringPrior, min_length::Int, max_length::Int, proposal_atoms::Vector{<:AbstractString}) = begin
2525
join(fill("*", Int(floor((min_length + max_length) / 2))))
2626
end
2727

28-
random(::StringPrior, min_length::Int, max_length::Int, proposal_atoms::Vector{String}) = begin
28+
random(::StringPrior, min_length::Int, max_length::Int, proposal_atoms::Vector{<:AbstractString}) = begin
2929
len = rand(DiscreteUniform(min_length, max_length))
3030
letters = []
3131
for i=1:len
@@ -40,7 +40,7 @@ end
4040

4141
const UNUSUAL_LETTER_PENALTY = 1000
4242
const string_prior_density_dict = Dict{Tuple{String, Int, Int}, Float64}()
43-
function logdensity(::StringPrior, observed::String, min_length::Int, max_length::Int, proposal_atoms::Vector{String})
43+
function logdensity(::StringPrior, observed::AbstractString, min_length::Int, max_length::Int, proposal_atoms::Vector{<:AbstractString})
4444
get!(string_prior_density_dict, (observed, min_length, max_length)) do
4545
if length(observed) < min_length || length(observed) > max_length
4646
return -Inf

src/distributions/time_prior.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ has_discrete_proposal(::TimePrior) = true
66

77
# Assume proposal_atoms are unique.
88
function discrete_proposal(::TimePrior, proposal_atoms::Vector{String})
9-
options = [proposal_atoms..., proposal_dummy_value]
9+
options = [proposal_atoms..., PROPOSAL_DUMMY_VALUE]
1010
probs = map(x -> isnothing(match(r"^\d?\d:\d\d [ap]\.m\.$", x)) ? -Inf : -log(1440), proposal_atoms)
1111
total = logsumexp(probs)
1212
probs = [probs..., log1p(-exp(total))]

src/dsl/builder.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using LightGraphs
1+
using Graphs
22

33

44
############

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ end
3030
3131
Like `normalize`, but in log-space and more numerically stable.
3232
"""
33-
logprobs(proportions::Vector{Float64}) = begin
33+
logprobs(proportions::AbstractVector{<:Real}) = begin
3434
l = log.(proportions)
3535
#l .- logsumexp(l)
3636
end

0 commit comments

Comments
 (0)