Skip to content

Commit 35b7d75

Browse files
Merge pull request #536 from ChrisRackauckas-Claude/static-improvements-20260101-030315
Fix JET static analysis issues
2 parents 33fd838 + 55240a1 commit 35b7d75

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/simple_regular_solve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function DiffEqBase.solve(jump_prob::JumpProblem, alg::SimpleTauLeaping;
2020
error("SimpleTauLeaping can only be used with PureLeaping JumpProblems with only RegularJumps.")
2121

2222
(; prob, rng) = jump_prob
23-
(seed !== nothing) && seed!(rng, seed)
23+
(seed !== nothing) && Random.seed!(rng, seed)
2424

2525
rj = jump_prob.regular_jump
2626
rate = rj.rate # rate function rate(out,u,p,t)

src/spatial/flatten.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,26 @@ function flatten(ma_jump, prob::DiscreteProblem, spatial_system, hopping_constan
1414
end
1515
netstoch = ma_jump.net_stoch
1616
reactstoch = ma_jump.reactant_stoch
17-
if isa(ma_jump, MassActionJump)
18-
rx_rates = ma_jump.scaled_rates
17+
rx_rates = if isa(ma_jump, MassActionJump)
18+
ma_jump.scaled_rates
1919
elseif isa(ma_jump, SpatialMassActionJump)
2020
num_nodes = num_sites(spatial_system)
2121
if isnothing(ma_jump.uniform_rates) && isnothing(ma_jump.spatial_rates)
22-
rx_rates = zeros(0, num_nodes)
22+
zeros(0, num_nodes)
2323
elseif isnothing(ma_jump.uniform_rates)
24-
rx_rates = ma_jump.spatial_rates
24+
ma_jump.spatial_rates
2525
elseif isnothing(ma_jump.spatial_rates)
26-
rx_rates = reshape(repeat(ma_jump.uniform_rates, num_nodes),
26+
reshape(repeat(ma_jump.uniform_rates, num_nodes),
2727
length(ma_jump.uniform_rates), num_nodes)
2828
else
2929
@assert size(ma_jump.spatial_rates, 2) == num_nodes
30-
rx_rates = cat(dims = 1,
30+
cat(dims = 1,
3131
reshape(repeat(ma_jump.uniform_rates, num_nodes),
3232
length(ma_jump.uniform_rates), num_nodes),
3333
ma_jump.spatial_rates)
3434
end
35+
else
36+
error("flatten: unsupported jump type $(typeof(ma_jump))")
3537
end
3638
flatten(netstoch, reactstoch, rx_rates, spatial_system, u0, tspan, hopping_constants;
3739
scale_rates = false, kwargs...)

src/spatial/topology.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,16 @@ end
8585
"""
8686
given a vector of hopping constants of length num_neighbors(grid, site), form the vector of size 2*(dimension of grid) with zeros at indices where the neighbor is out of bounds. Store it in to_pad
8787
"""
88-
function pad_hop_vec!(to_pad::AbstractVector{F}, grid, site,
89-
hop_vec::Vector{F}) where {F <: Number}
88+
function pad_hop_vec!(to_pad::AbstractVector, grid, site, hop_vec::AbstractVector)
9089
CI = grid.CI
9190
I = CI[site]
9291
nbr_counter = 1
93-
for (i, off) in enumerate(grid.offsets)
92+
@inbounds for (i, off) in enumerate(grid.offsets)
9493
if I + off in CI
9594
to_pad[i] = hop_vec[nbr_counter]
9695
nbr_counter += 1
9796
else
98-
to_pad[i] = zero(F)
97+
to_pad[i] = zero(eltype(to_pad))
9998
end
10099
end
101100
to_pad

0 commit comments

Comments
 (0)