Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Lifeware
biocham
Commits
4194f625
Commit
4194f625
authored
Oct 17, 2015
by
SOLIMAN Sylvain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
introduce a warning counter, use it through print_message/3
parent
c117f67e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
21 deletions
+41
-21
conservation_laws.pl
conservation_laws.pl
+20
-8
conservation_laws.plt
conservation_laws.plt
+15
-13
toplevel.pl
toplevel.pl
+1
-0
util.pl
util.pl
+5
-0
No files found.
conservation_laws.pl
View file @
4194f625
...
...
@@ -106,15 +106,18 @@ check_conservation(C) :-
(
check_conserv_reactions
(
C
)
->
message
(
'~w
checked
from
reactions
'
,
[
C
]
)
print_
message
(
informational
,
conservation_
checked
(
C
,
reactions
,
true
)
)
;
message
(
'~w not checked from reactions'
,
[
C
]),
print_message
(
informational
,
conservation_checked
(
C
,
reactions
,
false
)
),
check_conserv_num
(
C
)
->
message
(
'~w
checked
from
kinetics
'
,
[
C
]
)
print_
message
(
informational
,
conservation_
checked
(
C
,
kinetics
,
true
)
)
;
message
(
'~w not
checked
from
kinetics
either, but trusted anyway'
,
[
C
]
),
throw
(
error
(
unchecked_
conservation_
law
(
C
))
)
print_
message
(
informational
,
conservation_
checked
(
C
,
kinetics
,
false
)
),
print_message
(
warning
,
conservation_
trusted
(
C
))
).
...
...
@@ -160,8 +163,17 @@ scalar_conservation([K*M | L], C, Total) :-
Total
is
I
*
K
+
T1
.
message
(
M
,
O
)
:-
format
(
M
,
O
),
nl
.
prolog
:
message
(
conservation_trusted
(
C
))
-->
[
'Conservation ~w trusted without proof'
-
[
C
]].
prolog
:
message
(
conservation_checked
(
C
,
From
,
Truth
))
-->
{
Truth
==
true
->
Not
=
''
;
Not
=
'not '
},
[
'Conservation ~w ~wchecked from ~w'
-
[
C
,
Not
,
From
]].
% vi: set ts=2 sts=2 sw=2
conservation_laws.plt
View file @
4194f625
...
...
@@ -58,8 +58,8 @@ test(
test(
'check_conservations is ok with trivial P-invariants',
[
setup(models:clear_model),
cleanup(models:clear_model)
setup(
(
models:clear_model
, set_prolog_flag(verbose, silent))
),
cleanup(
(
models:clear_model
, set_prolog_flag(verbose, normal))
)
]
) :-
command(add_reaction(a => b)),
...
...
@@ -71,8 +71,8 @@ test(
test(
'check_conservations is ok with kinetically conserved moieties',
[
setup(models:clear_model),
cleanup(models:clear_model)
setup(
(
models:clear_model
, set_prolog_flag(verbose, silent))
),
cleanup(
(
models:clear_model
, set_prolog_flag(verbose, normal))
)
]
) :-
command(add_reaction(k*[a] for a => b)),
...
...
@@ -84,16 +84,20 @@ test(
test(
'check_conservations is unhappy with non-conserved moieties',
[
setup(models:clear_model),
cleanup(models:clear_model),
t
hrows(error(unchecked_conservation_law([1*'a', 2*'b']))
)
setup(
(
models:clear_model
, set_prolog_flag(verbose, silent))
),
cleanup(
(
models:clear_model
, set_prolog_flag(verbose, normal))
),
t
rue(Warnings == 1
)
]
) :-
% not written 'a => b' to allow flycheck by separate compilation…
command(add_reaction(
'=>'(2*a,
b))
)
,
command(add_reaction(
'=>'(a,
b))
)
,
set_counter(warnings, 0),
command(add_reaction(
2*a =>
b)),
command(add_reaction(
a =>
b)),
command(add_conservation(a + 2*b)),
with_output_to(atom(_), command(check_conservations)).
with_output_to(atom(_), command(check_conservations)),
count(warnings, Warnings).
:- end_tests(conservation_laws).
set_some_conservations :-
...
...
@@ -103,6 +107,4 @@ set_some_conservations :-
command(add_conservation(c-c + 2*c)).
:- end_tests(conservation_laws).
% vi: set ts=2 sts=2 sw=2
toplevel.pl
View file @
4194f625
...
...
@@ -19,6 +19,7 @@ loop :-
read_execute_print
:-
set_counter
(
warnings
,
0
),
read_command
(
Command
),
(
Command
=
end_of_file
...
...
util.pl
View file @
4194f625
...
...
@@ -106,3 +106,8 @@ nth0_eqq(N, [_Head | Tail], Result) :-
executable_filename
(
Filename
)
:-
current_prolog_flag
(
os_argv
,
[
_Swipl
,
_X
,
Filename
|
_
]).
user
:
message_hook
(
Msg
,
warning
,
Lines
)
:-
count
(
warnings
,
_
),
fail
.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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