Beispiel #1
0
def set_help_width(max_width=30):
    """Return a wider HelpFormatter, if possible."""
    try:
        # https://stackoverflow.com/a/5464440
        return lambda prog: ArgumentDefaultsHelpFormatter(prog, max_help_position=max_width)
    except TypeError:
        warnings.warn("argparse help formatter failed, falling back.")
        return ArgumentDefaultsHelpFormatter
Beispiel #2
0
def parse_args():
    parser = ArgumentParser(formatter_class=lambda prog: ArgumentDefaultsHelpFormatter(prog, max_help_position=100))

    parser.add_argument("--source-dir", type=Path, metavar="PATH", required=True, help="path to a directory containing categorized binary images")
    parser.add_argument("--output-dir", type=Path, metavar="PATH", required=True, help="path to a directory used for storing output assets")

    parser.add_argument("--border-blur", type=int, metavar="INT", default=75, help="size of the blur used for border detection")
    parser.add_argument("--border-threshold", type=int, metavar="INT", default=70, help="threshold used for border detection")

    parser.add_argument("--object-blur", type=int, metavar="INT", default=25, help="size of the blur used for object detection")
    parser.add_argument("--object-threshold", type=int, metavar="INT", default=120, help="threshold used for object detection")

    parser.add_argument("--corner-margin", type=int, metavar="INT", default=0, help="margin outside the detection region")
    parser.add_argument("--edge-margin", type=int, metavar="INT", default=122, help="margin outside the detection region")

    parser.add_argument("--min-pixel-count", type=int, metavar="INT", default=1024, help="minimum number of pixels required for a candidate object")

    parser.add_argument("--debug", action="store_true", help="enable debug mode")

    return parser.parse_args()
Beispiel #3
0
        # Calculate AeT for each metric in windows
        combined = []
        for m in metrics:
            config = m.pop('config')
            combined.append({
                'stats': self.extract_stats(relevant, **config),
                **m
            })
        return combined


if __name__ == '__main__':

    parser = ArgumentParser(
        description='Calculate AeT drift over rolling thresholds',
        formatter_class=lambda prog: ArgumentDefaultsHelpFormatter(
            prog, width=120, max_help_position=50))
    parser.add_argument('csv_path',
                        type=str,
                        help='path to heart rate CSV timeseries')
    parser.add_argument('-e',
                        '--end_time',
                        type=hms_str2delta,
                        required=True,
                        help='timestamp to stop rolling at')
    parser.add_argument('-f',
                        '--frequency',
                        type=int,
                        default=1,
                        help='number of seconds to slide window each time')
    parser.add_argument('-s',
                        '--start_time',
Beispiel #4
0
def arg_help_formatter(prog):
    return ArgumentDefaultsHelpFormatter(prog=prog,
                                         indent_increment=2,
                                         max_help_position=70,
                                         width=140)
Beispiel #5
0
 def __formatter(max_help_position, width=90):
     return lambda prog: ArgumentDefaultsHelpFormatter(prog,
                                     max_help_position=max_help_position, width=width)