Skip to content

Commit

Permalink
Merge pull request #78 from lbl-srg/issue76_improveDoc
Browse files Browse the repository at this point in the history
Specified two-column csv file
  • Loading branch information
JayHuLBL authored Apr 16, 2024
2 parents 8903c15 + d067463 commit 0e6812f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,23 @@ The module `pyfunnel.py` can also be run with the following command line interfa
```
usage: pyfunnel.py [-h] --reference REFERENCE --test TEST [--output OUTPUT] [--atolx ATOLX] [--atoly ATOLY] [--ltolx LTOLX] [--ltoly LTOLY] [--rtolx RTOLX] [--rtoly RTOLY]
Run funnel binary from terminal.
Run funnel binary from terminal on two two-column CSV files.
Output `errors.csv`, `lowerBound.csv`, `upperBound.csv`, `reference.csv`, `test.csv` into the output directory (`./results` by default).
optional arguments:
-h, --help show this help message and exit
--output OUTPUT Path of directory to store output data
--atolx ATOLX Absolute tolerance along x axis
--atoly ATOLY Absolute tolerance along y axis
--ltolx LTOLX Relative tolerance along x axis (relatively to the local value)
--ltoly LTOLY Relative tolerance along y axis (relatively to the local value)
--rtolx RTOLX Relative tolerance along x axis (relatively to the range)
--rtoly RTOLY Relative tolerance along y axis (relatively to the range)
-h, --help show this help message and exit
--output OUTPUT Path of directory to store output data
--atolx ATOLX Absolute tolerance along x axis
--atoly ATOLY Absolute tolerance along y axis
--ltolx LTOLX Relative tolerance along x axis (relatively to the local value)
--ltoly LTOLY Relative tolerance along y axis (relatively to the local value)
--rtolx RTOLX Relative tolerance along x axis (relatively to the range)
--rtoly RTOLY Relative tolerance along y axis (relatively to the range)
required named arguments:
--reference REFERENCE
Path of CSV file with reference data
--test TEST Path of CSV file with test data
--reference REFERENCE Path of two-column CSV file with reference data
--test TEST Path of two-column CSV file with test data
Full documentation at https://github.com/lbl-srg/funnel
```
Expand Down
14 changes: 10 additions & 4 deletions pyfunnel/pyfunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description=(
'Run funnel binary from terminal.\n\n'
'Run funnel binary from terminal on two two-column CSV files.\n\n'
'Output `errors.csv`, `lowerBound.csv`, `upperBound.csv`, `reference.csv`, `test.csv` '
'into the output directory (`./results` by default).'),
epilog='Full documentation at https://github.com/lbl-srg/funnel'
Expand All @@ -31,12 +31,12 @@

required_named.add_argument(
"--reference",
help="Path of CSV file with reference data",
help="Path of two-column CSV file with reference data",
required=True
)
required_named.add_argument(
"--test",
help="Path of CSV file with test data",
help="Path of two-column CSV file with test data",
required=True
)
parser.add_argument(
Expand Down Expand Up @@ -89,7 +89,13 @@
data[s] = dict(x=[], y=[])
with open(vars(args)[s]) as csvfile:
spamreader = csv.reader(csvfile)
for row in spamreader:
for i, row in enumerate(spamreader):
if (l := len(row)) != 2:
raise IOError(
"The {} CSV file must have exactly two columns. Row {} contains {} elements.".format(
s, i, l
)
)
try:
data[s]['x'].append(float(row[0]))
data[s]['y'].append(float(row[1]))
Expand Down

0 comments on commit 0e6812f

Please sign in to comment.