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

only allow window sizes of 1 and higher #252

Merged
merged 1 commit into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ros2topic/ros2topic/verb/bw.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
DEFAULT_WINDOW_SIZE = 100


def unsigned_int(string):
def positive_int(string):
try:
value = int(string)
except ValueError:
value = -1
if value < 0:
raise ArgumentTypeError('value must be non-negative integer')
if value <= 0:
raise ArgumentTypeError('value must be a positive integer')
return value


Expand All @@ -68,7 +68,7 @@ def add_arguments(self, parser, cli_name):
arg.completer = TopicNameCompleter(
include_hidden_topics_key='include_hidden_topics')
parser.add_argument(
'--window', '-w', type=unsigned_int, default=DEFAULT_WINDOW_SIZE,
'--window', '-w', type=positive_int, default=DEFAULT_WINDOW_SIZE,
help='window size, in # of messages, for calculating rate '
'(default: %d)' % DEFAULT_WINDOW_SIZE, metavar='WINDOW')

Expand Down
8 changes: 4 additions & 4 deletions ros2topic/ros2topic/verb/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
DEFAULT_WINDOW_SIZE = 10000


def unsigned_int(string):
def positive_int(string):
try:
value = int(string)
except ValueError:
value = -1
if value < 0:
raise ArgumentTypeError('value must be non-negative integer')
if value <= 0:
raise ArgumentTypeError('value must be a positive integer')
return value


Expand All @@ -68,7 +68,7 @@ def add_arguments(self, parser, cli_name):
arg.completer = TopicNameCompleter(
include_hidden_topics_key='include_hidden_topics')
parser.add_argument(
'--window', '-w', type=unsigned_int, default=DEFAULT_WINDOW_SIZE,
'--window', '-w', type=positive_int, default=DEFAULT_WINDOW_SIZE,
help='window size, in # of messages, for calculating rate, '
'string to (default: %d)' % DEFAULT_WINDOW_SIZE)

Expand Down
8 changes: 4 additions & 4 deletions ros2topic/ros2topic/verb/hz.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
DEFAULT_WINDOW_SIZE = 10000


def unsigned_int(string):
def positive_int(string):
try:
value = int(string)
except ValueError:
value = -1
if value < 0:
raise ArgumentTypeError('value must be non-negative integer')
if value <= 0:
raise ArgumentTypeError('value must be a positive integer')
return value


Expand All @@ -74,7 +74,7 @@ def add_arguments(self, parser, cli_name):
include_hidden_topics_key='include_hidden_topics')
parser.add_argument(
'--window', '-w',
dest='window_size', type=unsigned_int, default=DEFAULT_WINDOW_SIZE,
dest='window_size', type=positive_int, default=DEFAULT_WINDOW_SIZE,
help='window size, in # of messages, for calculating rate '
'(default: %d)' % DEFAULT_WINDOW_SIZE, metavar='WINDOW')
parser.add_argument(
Expand Down