Skip to content

Commit

Permalink
Merge pull request #1184 from SciML/add_danishnorweigan_emptyset
Browse files Browse the repository at this point in the history
Consider the Danish/Norwegian letter ∅ as the empty set symbol (Ø)
  • Loading branch information
TorkelE authored Feb 15, 2025
2 parents fa4d209 + c7cf77f commit 4d0e7c2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
end
plot_network(brusselator)
```
- The letter Ø (used in Danish/Norwegian alphabet) is now conisdred the same as ∅ (empty set). It can no longer be used as a species/parameter.

## Catalyst 14.4.1
- Support for user-defined functions on the RHS when providing coupled equations
Expand Down
2 changes: 1 addition & 1 deletion src/Catalyst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const ExprValues = Union{Expr, Symbol, Float64, Int, Bool}
const CONSERVED_CONSTANT_SYMBOL =

# Declares symbols which may neither be used as parameters nor unknowns.
const forbidden_symbols_skip = Set([:ℯ, :pi, , :t, :∅])
const forbidden_symbols_skip = Set([:ℯ, :pi, , :t, :∅, ])
const forbidden_symbols_error = union(Set([:im, :nothing, CONSERVED_CONSTANT_SYMBOL]),
forbidden_symbols_skip)

Expand Down
2 changes: 1 addition & 1 deletion src/dsl.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Constants Declarations ###

# Declare various arrow types symbols used for the empty set (also 0).
const empty_set = Set{Symbol}([:∅])
const empty_set = Set{Symbol}([:∅, ])
const fwd_arrows = Set{Symbol}([:>, :(=>), :, :, :, :, :, :, :, :, :, :, :, :])
const bwd_arrows = Set{Symbol}([:<, :(<=), :, :, :, :, :, :, :, :, :, :, :, :,
Symbol("<--")])
Expand Down
2 changes: 1 addition & 1 deletion src/spatial_reaction_systems/spatial_reactions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ end
# Loops through a rate and extracts all parameters.
function find_parameters_in_rate!(parameters, rateex::ExprValues)
if rateex isa Symbol
if rateex in [:t, :∅, :im, :nothing, CONSERVED_CONSTANT_SYMBOL]
if rateex in [:t, :∅, :Ø, :im, :nothing, CONSERVED_CONSTANT_SYMBOL]
error("Forbidden term $(rateex) used in transport reaction rate.")
elseif !(rateex in [:ℯ, :pi, ])
push!(parameters, rateex)
Expand Down
39 changes: 34 additions & 5 deletions test/dsl/dsl_basic_model_construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,35 @@ let
@test any(isequal(I), unknowns(rn))
end

# Test that Ø (Danish/Norwegian letter), ∅ (empty set), and 0 (zero) are equivalent.
let
rn1 = @reaction_network rn begin
p, Ø --> X
d, X --> Ø
end
rn2 = @reaction_network rn begin
p, ∅ --> X
d, X -->
end
rn3 = @reaction_network rn begin
p, 0 --> X
d, X --> 0
end
rn4 = @reaction_network rn begin
p, Ø --> X
d, X -->
end
rn5 = @reaction_network rn begin
p, Ø --> X
d, X --> 0
end
rn6 = @reaction_network rn begin
p, ∅ --> X
d, X --> 0
end
@test rn1 == rn2 == rn3 == rn4 == rn5 == rn6
end

# Tests backwards and bi-directional arrows.
let
rn1 = @reaction_network arrowtest begin
Expand Down Expand Up @@ -472,7 +501,7 @@ let
end

# Test that symbols with special meanings are handled properly.
let
let
test_network = @reaction_network begin t * k, X -->end
@test length(species(test_network)) == 1
@test length(parameters(test_network)) == 1
Expand Down Expand Up @@ -532,7 +561,7 @@ let
@test_throws Exception @eval @reaction nothing, 0 --> X
@test_throws Exception @eval @reaction Γ, 0 --> X
@test_throws Exception @eval @reaction ∅, 0 --> X

# @reaction macro, symbols that cannot be a reactant.
@test_throws Exception @eval @reaction 1, 0 --> im
@test_throws Exception @eval @reaction 1, 0 --> nothing
Expand All @@ -541,13 +570,13 @@ let
@test_throws Exception @eval @reaction 1, 0 --> pi
@test_throws Exception @eval @reaction 1, 0 --> π
@test_throws Exception @eval @reaction 1, 0 --> t

# @reaction_network macro, symbols that cannot be in the rate.
@test_throws Exception @eval @reaction_network begin im, 0 --> X end
@test_throws Exception @eval @reaction_network begin nothing, 0 --> X end
@test_throws Exception @eval @reaction_network begin Γ, 0 --> X end
@test_throws Exception @eval @reaction_network begin ∅, 0 --> X end

# @reaction_network macro, symbols that cannot be a reactant.
@test_throws Exception @eval @reaction_network begin 1, 0 --> im end
@test_throws Exception @eval @reaction_network begin 1, 0 --> nothing end
Expand All @@ -561,4 +590,4 @@ let
@test_throws Exception @eval @reaction_network begin
d, X 0
end
end
end

0 comments on commit 4d0e7c2

Please sign in to comment.