-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #554 from PEtab-dev/release/2.0.0
Add PEtab 2.0 draft
- Loading branch information
Showing
22 changed files
with
1,464 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
|
||
name: PEtab Extension | ||
about: Suggest a new extension for PEtab core | ||
title: '' | ||
labels: file format | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Name of the Extension** | ||
Please make sure that the extension name matches the regular expression `^[a-zA-Z_][A-Za-z0-9_-]*$`. | ||
|
||
**Which problem would you like to address?** | ||
A clear and concise description of which use case you want to address and, if applicable, why the current specifications do not fulfill your requirements. | ||
|
||
**Describe the solution you would like** | ||
A clear and concise description of the changes you want to propose. Please describe any additional fields / files you would want to add, including allowed inputs and implications. | ||
|
||
**Describe why this should not be implemented by changes to PEtab core** | ||
A clear and concise description in what way the proposed changes introduce features that are orthogonal to the PEtab core specification. | ||
|
||
**List the extension library that implements validation checks** | ||
A link to the website or GitHub repository that accompanies the proposed extension. | ||
|
||
**List the toolboxes that support the proposed standard** | ||
A link to the website or GitHub repository that contains the software that implements support for the standard. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Function Comment Argument types Evaluates to | ||
``pow(a, b)`` power function `b`-th power of `a` float, float float | ||
``exp(x)`` exponential function pow(e, x);(`e` itself not a supported symbol,;but ``exp(1)`` can be used instead) float float | ||
``sqrt(x)`` square root of ``x``;``pow(x, 0.5)`` float float | ||
``log(a, b)``;``log(x)``;``ln(x)``;``log2(x)``;``log10(x)`` logarithm of ``a`` with base ``b``;``log(x, e)``;``log(x, e)``;``log(x, 2)``;``log(x, 10)``;(``log(0)`` is defined as ``-inf``);(NOTE: ``log`` without explicit;base is ``ln``, not ``log10``) float[, float] float | ||
``sin``;``cos``;``tan``;``cot``;``sec``;``csc`` trigonometric functions float float | ||
``arcsin``;``arccos``;``arctan``;``arccot``;``arcsec``;``arccsc`` inverse trigonometric functions float float | ||
``sinh``;``cosh``;``tanh``;``coth``;``sech``;``csch`` hyperbolic functions float float | ||
``arcsinh``;``arccosh``;``arctanh``;``arccoth``;``arcsech``;``arccsch`` inverse hyperbolic functions float float | ||
``piecewise(``; ``true_value_1,``; ``condition_1,``; ``[true_value_2,``; ``condition_2,]``; ``[...]``; ``[true_value_n,``; ``condition_n,]``; ``otherwise``;``)`` The function value is;the ``true_value*`` for the;first ``true`` ``condition*``;or ``otherwise`` if all;conditions are ``false``. ``*value*``: all float or all bool;``condition*``: all bool float | ||
``abs(x)`` absolute value;``piecewise(x, x>=0, -x)`` float float | ||
``sign(x)`` sign of ``x``;``piecewise(1, x>=0, -1)`` float float | ||
``min(a, b)``;``max(a, b)`` minimum / maximum of {``a``, ``b``};``piecewise(a, a<=b, b)``;``piecewise(a, a>=b, b)`` float, float float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pandas as pd | ||
from pathlib import Path | ||
|
||
doc_dir = Path(__file__).parent.parent | ||
table_dir = Path(__file__).parent | ||
|
||
MULTILINE_DELIMITER = ";" | ||
tables = { | ||
"Supported functions": { | ||
"target": doc_dir / "documentation_data_format.rst", | ||
"options": { | ||
"header-rows": "1", | ||
# "widths": "20 10 10 5", | ||
}, | ||
}, | ||
} | ||
|
||
|
||
def df_to_list_table(df, options, name): | ||
columns = df.columns | ||
table = f".. list-table:: {name}\n" | ||
for option_id, option_value in options.items(): | ||
table += f" :{option_id}: {option_value}\n" | ||
table += "\n" | ||
|
||
first = True | ||
for column in columns: | ||
if first: | ||
table += " * " | ||
first = False | ||
else: | ||
table += " " | ||
table += f"- | {column}\n" | ||
|
||
for _, row in df.iterrows(): | ||
first = True | ||
for column in columns: | ||
cell = row[column] | ||
if first: | ||
table += " * " | ||
first = False | ||
else: | ||
table += " " | ||
table += "- " | ||
if MULTILINE_DELIMITER in cell: | ||
first_line = True | ||
for line in cell.split(MULTILINE_DELIMITER): | ||
if first_line: | ||
table += "| " | ||
first_line = False | ||
else: | ||
table += " | " | ||
table += line | ||
table += "\n" | ||
else: | ||
table += cell | ||
table += "\n" | ||
|
||
return table | ||
|
||
|
||
def replace_text(filename, text, start, end): | ||
with open(filename, "r") as f: | ||
full_text0 = f.read() | ||
before_start = full_text0.split(start)[0] | ||
after_end = full_text0.split(end)[1] | ||
full_text = ( | ||
before_start | ||
+ start | ||
+ text | ||
+ end | ||
+ after_end | ||
) | ||
with open(filename, "w") as f: | ||
f.write(full_text) | ||
|
||
|
||
DISCLAIMER = "(GENERATED, DO NOT EDIT, INSTEAD EDIT IN PEtab/doc/src)" | ||
|
||
|
||
for table_id, table_data in tables.items(): | ||
target_file = table_data["target"] | ||
options = table_data["options"] | ||
df = pd.read_csv(table_dir/ f"{table_id}.tsv", sep="\t") | ||
table = df_to_list_table(df, options=options, name=table_id) | ||
replace_text( | ||
filename=target_file, | ||
text=table, | ||
start=f"\n..\n START TABLE {table_id} {DISCLAIMER}\n", | ||
end=f"\n..\n END TABLE {table_id}\n", | ||
) |
Oops, something went wrong.