Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specified two-column csv file #78

Merged
merged 10 commits into from
Apr 16, 2024
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
Binary file modified pyfunnel/lib/linux64/libfunnel.so
Binary file not shown.
8 changes: 5 additions & 3 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,6 +89,8 @@
data[s] = dict(x=[], y=[])
with open(vars(args)[s]) as csvfile:
spamreader = csv.reader(csvfile)
if (len(next(spamreader)) != 2):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that if you use next here, the next iteration on the iterator (for loop below) starts at index 1 and not 0, i.e., the first row is skipped.
Why not test len(spamreader[0])? Or each line within the for loop: len(row)?

raise RuntimeError("The {} CSV file must have exactly two columns.".format(s))
Copy link
Collaborator

@AntoineGautier AntoineGautier Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this rather be an IOError?

for row in spamreader:
try:
data[s]['x'].append(float(row[0]))
Expand Down
Loading