diff --git a/README.md b/README.md index aa489fc..374d641 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/pyfunnel/pyfunnel.py b/pyfunnel/pyfunnel.py index 057bb3d..7a5e83c 100755 --- a/pyfunnel/pyfunnel.py +++ b/pyfunnel/pyfunnel.py @@ -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' @@ -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( @@ -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]))