From a4d4736e13a0ff942503baf61960006d3ddcb278 Mon Sep 17 00:00:00 2001 From: Francesco Pannarale Date: Wed, 22 Jan 2025 02:29:42 -0800 Subject: [PATCH 1/3] pycbc.types.angle_as_radians, pycbc_pygrb_grb_info_table, pycbc_make_sky_grid docstrings --- bin/pycbc_make_sky_grid | 3 +++ bin/pygrb/pycbc_pygrb_grb_info_table | 6 +++++- pycbc/types/optparse.py | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/pycbc_make_sky_grid b/bin/pycbc_make_sky_grid index c4d8da61f2a..72316cf5f07 100644 --- a/bin/pycbc_make_sky_grid +++ b/bin/pycbc_make_sky_grid @@ -9,6 +9,9 @@ statistics. The grid is constructed following the method described in Section V of https://arxiv.org/abs/1410.6042. + +Please refer to help(pycbc.types.angle_as_radians) for the recommended +configuration file syntax for angle arguments. """ import numpy as np diff --git a/bin/pygrb/pycbc_pygrb_grb_info_table b/bin/pygrb/pycbc_pygrb_grb_info_table index a4a605d631d..31912068605 100644 --- a/bin/pygrb/pycbc_pygrb_grb_info_table +++ b/bin/pygrb/pycbc_pygrb_grb_info_table @@ -16,7 +16,11 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -"""Create GRB info table.""" +"""Create GRB info table. + +Please refer to help(pycbc.types.angle_as_radians) for the recommended +configuration file syntax for angle arguments. +""" # ============================================================================= # Preamble diff --git a/pycbc/types/optparse.py b/pycbc/types/optparse.py index f05a4944726..302ca6a6775 100644 --- a/pycbc/types/optparse.py +++ b/pycbc/types/optparse.py @@ -545,6 +545,11 @@ def angle_as_radians(s): (e.g. 12deg, 1rad), " " (e.g. 12 deg, 1 rad) or just "", in which case the unit will be assumed to be radians. + When writing angles in configuration files, the format " " + prevents errors with negative values when Pegasus generates the .sh + file for executables that rely on this function and require angles + in their command line. + To be used as type in argparse arguments. """ # if `s` converts to a float then there is no unit, so assume radians From ebe123e3ac42baa5e7c3ad134c6f0342cfa75c36 Mon Sep 17 00:00:00 2001 From: Francesco Pannarale Date: Wed, 22 Jan 2025 02:37:00 -0800 Subject: [PATCH 2/3] Better docstring --- pycbc/types/optparse.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pycbc/types/optparse.py b/pycbc/types/optparse.py index 302ca6a6775..dd7d6934e77 100644 --- a/pycbc/types/optparse.py +++ b/pycbc/types/optparse.py @@ -545,10 +545,11 @@ def angle_as_radians(s): (e.g. 12deg, 1rad), " " (e.g. 12 deg, 1 rad) or just "", in which case the unit will be assumed to be radians. - When writing angles in configuration files, the format " " - prevents errors with negative values when Pegasus generates the .sh - file for executables that rely on this function and require angles - in their command line. + When writing angles in configuration files as options to be passed to + executables that rely on this function and require angles in their command + line, the format " ", with the quotation marks included, + prevents errors with negative values due to how Pegasus renders options in + .sh files. To be used as type in argparse arguments. """ From dfe5a99de01a639b036edb6e4f89d84e3ad36b07 Mon Sep 17 00:00:00 2001 From: Francesco Pannarale Date: Wed, 22 Jan 2025 15:24:02 +0100 Subject: [PATCH 3/3] Update pycbc/types/optparse.py Co-authored-by: Tito Dal Canton --- pycbc/types/optparse.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pycbc/types/optparse.py b/pycbc/types/optparse.py index dd7d6934e77..e9382e16a59 100644 --- a/pycbc/types/optparse.py +++ b/pycbc/types/optparse.py @@ -545,11 +545,14 @@ def angle_as_radians(s): (e.g. 12deg, 1rad), " " (e.g. 12 deg, 1 rad) or just "", in which case the unit will be assumed to be radians. - When writing angles in configuration files as options to be passed to - executables that rely on this function and require angles in their command - line, the format " ", with the quotation marks included, - prevents errors with negative values due to how Pegasus renders options in - .sh files. + Note that the format "", with a negative value and no space, + is not parsed correctly by argparse; for more information, see + https://stackoverflow.com/questions/16174992/cant-get-argparse-to-read-quoted-string-with-dashes-in-it + + Note: when writing angles in workflow configuration files as options to be + passed to executables that rely on this function and require angles in their + command line, the format " ", with the quotation marks + included, is required due to how Pegasus renders options in .sh files. To be used as type in argparse arguments. """