Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 11cbe4b0 authored by Thierry Martinez's avatar Thierry Martinez
Browse files

Tables

parent c25dc2eb
......@@ -298,6 +298,8 @@ generate_body(Doc, Type) :-
\+ (
toc(Item),
\+ (
print(Item),
nl,
generate_body_item(Item, Doc, Type)
)
).
......
......@@ -684,7 +684,7 @@ delete_item(Id) :-
retractall(annotation(Id, _KindAnnotation, _Annotation)),
retractall(listed_item(_Index, Id)),
retractall(dependency(Id, _Master)),
retract_all(at_delete_goal(Id, _Goal)),
retractall(at_delete_goal(Id, _Goal)),
\+ (
item(SubId, Id, _SubKind, _SubItem),
\+ (
......
......@@ -30,7 +30,7 @@ numerical_simulation(Time) :-
doc('performs a numerical simulation up to a given time.'),
compute_ode,
make_ode_system,
solve(Time).
solve(Time)..
make_ode_system :-
......@@ -39,6 +39,8 @@ make_ode_system :-
solve(Time) :-
print(hello),
nl,
gather_headers(Headers),
gather_equations(Equations),
gather_initial_values(InitialValues),
......@@ -56,7 +58,11 @@ solve(Time) :-
time_final: Time
],
solve(Options, Table),
add_table('numerical_simulation', Table).
print(here),
nl,
add_table('numerical_simulation', Table),
print(there),
nl.
gather_headers(Headers) :-
......
......@@ -14,6 +14,7 @@ plot :-
biocham_command,
doc('plots the current trace.'),
get_plot_driver(Driver),
print(here), nl,
Driver.
......
......@@ -7,10 +7,12 @@
rename_table/1,
list_tables/0,
delete_table/1,
list_rows/0,
list_columns/0,
column/1,
delete_column/1,
rename_column/2,
delete_row/1,
add_table/2,
get_table_data/1,
get_current_table/1,
......@@ -112,6 +114,13 @@ delete_table(TableSet) :-
).
list_rows :-
biocham_command,
doc('lists the rows of the current table.'),
get_current_table(Id),
list_items([parent: Id, kind: row]).
list_columns :-
biocham_command,
doc('lists the column names of the current table.'),
......@@ -131,7 +140,7 @@ column(Name) :-
delete_column(Columns) :-
biocham_command(*),
type(Column, '*'(column)),
type(Columns, '*'(column)),
doc('deletes the given columns from the current table.'),
get_current_table(Id),
\+ (
......@@ -160,13 +169,27 @@ rename_column(Column, Name) :-
->
ColumnIndex = Column
;
find_item([parent: Id, kind: column, item: Column]),
get_annotation(Column, index, ColumnIndex)
find_item([parent: Id, kind: column, item: Column, id: ColumnId]),
get_annotation(ColumnId, index, ColumnIndex)
),
delete_items([parent: Id, kind: column, key: ColumnIndex]),
declare_column(Id, ColumnIndex, Name).
delete_row(Rows) :-
biocham_command(*),
type(Rows, '*'(number)),
doc('deletes the given rows from the current table.'),
get_current_table(Id),
\+ (
member(Row, Rows),
\+ (
find_item([parent: Id, kind: column, key: Row, id: RowId]),
delete_item(RowId)
)
).
:- devdoc('\\section{Public API}').
......@@ -180,7 +203,7 @@ add_table(Name, Table) :-
->
declare_column(Id, 0, FirstColumnName),
\+ (
nth1(ColumnIndex, OtherColumns, ColumnName),
nth0(ColumnIndex, OtherColumns, ColumnName),
\+ (
declare_column(Id, ColumnIndex, ColumnName)
)
......@@ -198,13 +221,35 @@ add_table(Name, Table) :-
),
Data = Table
),
set_annotation(Id, data, Data),
\+ (
nth0(RowIndex, Data, Row),
\+ (
add_item([parent: Id, kind: row, key: RowIndex, item: Row])
)
),
set_current_table(Id).
get_table_data(Data) :-
get_current_table(Id),
get_annotation(Id, data, Data).
set_counter(row, 0),
findall(
Row,
(
repeat,
(
count(row, RowIndex),
item([parent:Id, kind: row, key: RowIndex, item: Row])
->
true
;
!,
fail
)
),
Data
),
print(get(Data)), nl.
get_column_name(Index, Name) :-
......@@ -233,22 +278,14 @@ declare_column(Id, ColumnIndex, Name) :-
perform_column_delete(Id, ColumnIndex) :-
(
get_annotation(Id, data, Data)
->
findall(
NewRow,
(
member(Row, Data),
Row =.. [row, RowItems],
nth1(ColumnIndex, RowItems, _Deleted, NewRowItems),
NewRow =.. [row, NewRowItems]
),
NewData
),
set_annotation(Id, data, NewData)
;
true
\+ (
item([parent:Id, kind: row, key: RowIndex, item: Row, id: RowId]),
\+ (
Row =.. [row | RowItems],
nth0(ColumnIndex, RowItems, _Deleted, NewRowItems),
NewRow =.. [row | NewRowItems],
replace_item(RowId, row, RowIndex, NewRow)
)
).
......
......@@ -7,15 +7,28 @@ test(
[true(Tables == [table])]
) :-
clear_model,
add_table(table, [row(50, 50)]),
add_table(table, [row(1, 2)]),
all_items([kind: table], Tables).
test(
'get_table_data',
[true(Data == [row(50, 50)])]
[true(Data == [row(1, 2)])]
) :-
clear_model,
add_table(table, [row(50, 50)]),
add_table(table, [row(1, 2)]),
get_table_data(Data).
test(
'delete_column',
[true(Data == [row(1, 3), row(4, 6)])]
) :-
clear_model,
add_table(table, [row(1, 2, 3), row(4, 5, 6)]),
print(here),y
nl,leash(-all),trace,
command(delete_column(1)),
print(there),
nl,
get_table_data(Data).
:- end_tests(tables).
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment