Skip to content

Commit d2d7a92

Browse files
committed
add Exception if rows / cols <= 0
1 parent 4ee9b59 commit d2d7a92

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

plotly/tools.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -401,19 +401,19 @@ def get_subplots(rows=1, columns=1, print_grid=False, **kwargs):
401401
402402
Keywords arguments with constant defaults:
403403
404-
rows (int, default=1):
404+
rows (kwarg, int greater than 0, default=1):
405405
Number of rows, evenly spaced vertically on the figure.
406406
407-
columns (int, default=1):
407+
columns (kwarg, int greater than 0, default=1):
408408
Number of columns, evenly spaced horizontally on the figure.
409409
410-
horizontal_spacing (float in [0,1], default=0.1):
410+
horizontal_spacing (kwarg, float in [0,1], default=0.1):
411411
Space between subplot columns. Applied to all columns.
412412
413-
vertical_spacing (float in [0,1], default=0.05):
413+
vertical_spacing (kwarg, float in [0,1], default=0.05):
414414
Space between subplot rows. Applied to all rows.
415415
416-
print_grid (True | False, default=False):
416+
print_grid (kwarg, True | False, default=False):
417417
If True, prints a tab-delimited string representation
418418
of your plot grid.
419419
@@ -433,10 +433,12 @@ def get_subplots(rows=1, columns=1, print_grid=False, **kwargs):
433433
)
434434

435435
# Throw exception for non-integer rows and columns
436-
if not isinstance(rows, int):
437-
raise Exception("Keyword argument 'rows' must be an int")
438-
if not isinstance(columns, int):
439-
raise Exception("Keyword argument 'columns' must be an int")
436+
if not isinstance(rows, int) or rows <= 0:
437+
raise Exception("Keyword argument 'rows' "
438+
"must be an int greater than 0")
439+
if not isinstance(columns, int) or columns <= 0:
440+
raise Exception("Keyword argument 'columns' "
441+
"must be an int greater than 0")
440442

441443
# Throw exception if non-valid kwarg is sent
442444
VALID_KWARGS = ['horizontal_spacing', 'vertical_spacing']
@@ -550,10 +552,10 @@ def make_subplots(rows=1, cols=1,
550552
551553
Keywords arguments with constant defaults:
552554
553-
rows (kwarg, int, default=1):
555+
rows (kwarg, int greater than 0, default=1):
554556
Number of rows in the subplot grid.
555557
556-
cols (kwarg, int, default=1):
558+
cols (kwarg, int greater than 0, default=1):
557559
Number of columns in the subplot grid.
558560
559561
shared_xaxes (kwarg, boolean or list, default=False)
@@ -651,10 +653,12 @@ def make_subplots(rows=1, cols=1,
651653
"""
652654

653655
# Throw exception for non-integer rows and cols
654-
if not isinstance(rows, int):
655-
raise Exception("Keyword argument 'rows' must be an int")
656-
if not isinstance(cols, int):
657-
raise Exception("Keyword argument 'cols' must be an int")
656+
if not isinstance(rows, int) or rows <= 0:
657+
raise Exception("Keyword argument 'rows' "
658+
"must be an int greater than 0")
659+
if not isinstance(cols, int) or cols <= 0:
660+
raise Exception("Keyword argument 'cols' "
661+
"must be an int greater than 0")
658662

659663
# Dictionary of things start_cell
660664
START_CELL_all = {

0 commit comments

Comments
 (0)