Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LCSB-BioCore
SBML.jl
Commits
70778a8c
Unverified
Commit
70778a8c
authored
Jul 10, 2021
by
Miroslav Kratochvil
🚴
Committed by
GitHub
Jul 10, 2021
Browse files
Merge pull request #114 from LCSB-BioCore/mk-fix-piecewise
fix argument order and count for piecewise function
parents
4e68f3f3
951e776d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Project.toml
View file @
70778a8c
...
...
@@ -4,14 +4,15 @@ authors = ["Mirek Kratochvil <miroslav.kratochvil@uni.lu>", "LCSB R3 team <lcsb-
version
=
"0.5.5"
[deps]
IfElse
=
"615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
Libdl
=
"8f399da3-3557-5675-b5ff-fb832c97cbdb"
SBML_jll
=
"bb12108a-f4ef-5f88-8ef3-0b33ff7017f1"
SparseArrays
=
"2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Symbolics
=
"0c5d862f-8b57-4792-8d23-62f2024744c7"
[compat]
julia
=
"1.5"
Symbolics
=
"0.1.21, 1"
julia
=
"1.5"
[extras]
Downloads
=
"f43a241f-c20a-4ad4-852c-f6b1247861c6"
...
...
src/SBML.jl
View file @
70778a8c
...
...
@@ -3,6 +3,7 @@ module SBML
using
SBML_jll
,
Libdl
using
SparseArrays
using
Symbolics
using
IfElse
include
(
"types.jl"
)
include
(
"structs.jl"
)
...
...
src/symbolics.jl
View file @
70778a8c
...
...
@@ -45,7 +45,7 @@ const default_symbolics_mapping = Dict{String,Any}(
"ln"
=>
:
log
,
"log"
=>
:
sbmlLog
,
"lt"
=>
:<
,
"piecewise"
=>
:
(
Core
.
ifel
se
),
"piecewise"
=>
:
(
sbmlPiecewi
se
),
"power"
=>
:^
,
"root"
=>
:
sbmlRoot
,
"sech"
=>
:
sech
,
...
...
@@ -56,6 +56,17 @@ const default_symbolics_mapping = Dict{String,Any}(
"tan"
=>
:
tan
,
)
function
sbmlPiecewise
(
args
...
)
if
length
(
args
)
==
1
args
[
1
]
elseif
length
(
args
)
>=
3
IfElse
.
ifelse
(
args
[
2
],
args
[
1
],
sbmlPiecewise
(
args
[
3
:
end
]
...
))
else
throw
(
AssertionError
(
"malformed piecewise SBML function"
))
end
end
sbmlLog
(
x
)
=
log
(
x
,
10
)
sbmlLog
(
base
,
x
)
=
log
(
base
,
x
)
...
...
@@ -103,7 +114,7 @@ function Base.convert(
convert_time
=
(
x
::
SBML
.
MathTime
)
->
Num
(
Variable
(
Symbol
(
x
.
id
)))
.
val
,
convert_const
=
(
x
::
SBML
.
MathConst
)
->
Num
(
default_symbolics_constants
[
x
.
id
]),
)
conv
(
x
::
SBML
.
MathApply
)
=
eval
(
allowed_sym
(
x
.
fn
,
mapping
))(
conv
.
(
x
.
args
)
...
)
conv
(
x
::
SBML
.
MathApply
)
=
Num
(
eval
(
allowed_sym
(
x
.
fn
,
mapping
))(
conv
.
(
x
.
args
)
...
)
)
conv
(
x
::
SBML
.
MathTime
)
=
convert_time
(
x
)
conv
(
x
::
SBML
.
MathConst
)
=
convert_const
(
x
)
conv
(
x
::
SBML
.
MathIdent
)
=
Num
(
Variable
(
Symbol
(
x
.
id
)))
.
val
...
...
test/symbolics.jl
View file @
70778a8c
...
...
@@ -30,8 +30,8 @@
test
=
SBML
.
MathApply
(
"piecewise"
,
SBML
.
Math
[
SBML
.
MathApply
(
"lt"
,
SBML
.
Math
[
SBML
.
MathVal
(
1
),
SBML
.
MathVal
(
0
)]),
SBML
.
MathVal
(
123
),
SBML
.
MathApply
(
"lt"
,
SBML
.
Math
[
SBML
.
MathVal
(
1
),
SBML
.
MathVal
(
0
)]),
SBML
.
MathVal
(
456
),
],
)
...
...
cylon-x
🤖
@cylon-x
mentioned in commit
4dcde799
·
Jul 10, 2021
mentioned in commit
4dcde799
mentioned in commit 4dcde799bb60cc5fc2f45b008124cfc18d59ac9a
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment