Skip to content

Commit 911632a

Browse files
committed
Provide exception message and change exception type
1 parent 535c953 commit 911632a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Specified exception types in Grid
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
In a few cases an `Exception` was thrown when an incorrect argument value
5+
was set in the `mpl_toolkits.axes_grid1.axes_grid.Grid`
6+
(= `mpl_toolkits.axisartist.axes_grid.Grid`) constructor. These are replaced
7+
as follows:
8+
9+
* Providing an incorrect value for *ngrids* now raises a `ValueError`
10+
* Providing an incorrect type for *rect* now raises a `TypeError`

lib/mpl_toolkits/axes_grid1/axes_grid.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def __init__(self, fig,
123123
ngrids = self._nrows * self._ncols
124124
else:
125125
if not 0 < ngrids <= self._nrows * self._ncols:
126-
raise Exception("")
126+
raise ValueError(
127+
"ngrids must be positive and not larger than nrows*ncols")
127128

128129
self.ngrids = ngrids
129130

@@ -147,7 +148,7 @@ def __init__(self, fig,
147148
elif len(rect) == 4:
148149
self._divider = Divider(fig, rect, **kw)
149150
else:
150-
raise Exception("")
151+
raise TypeError("Incorrect rect format")
151152

152153
rect = self._divider.get_position()
153154

0 commit comments

Comments
 (0)