|
3 | 3 | from matplotlib import scale
|
4 | 4 | from scipy import stats
|
5 | 5 |
|
6 |
| -from .probscale import ProbScale, _minimal_norm |
| 6 | +from .probscale import ProbScale |
| 7 | +from .probscale import _minimal_norm |
| 8 | +from . import validate |
7 | 9 |
|
8 | 10 |
|
9 | 11 | scale.register_scale(ProbScale)
|
10 | 12 |
|
11 | 13 |
|
12 |
| -def _check_ax_obj(ax): |
13 |
| - """ Checks if a value if an Axes. If None, a new one is created. |
14 |
| -
|
15 |
| - """ |
16 |
| - |
17 |
| - if ax is None: |
18 |
| - fig, ax = pyplot.subplots() |
19 |
| - elif isinstance(ax, pyplot.Axes): |
20 |
| - fig = ax.figure |
21 |
| - else: |
22 |
| - msg = "`ax` must be a matplotlib Axes instance or None" |
23 |
| - raise ValueError(msg) |
24 |
| - |
25 |
| - return fig, ax |
26 |
| - |
27 |
| - |
28 |
| -def _check_fit_arg(arg, argname): |
29 |
| - valid_args = ['x', 'y', 'both', None] |
30 |
| - if arg not in valid_args: |
31 |
| - msg = 'Invalid value for {} ({}). Must be on of {}.' |
32 |
| - raise ValueError(msg.format(argname, arg, valid_args)) |
33 |
| - |
34 |
| - return arg |
35 |
| - |
36 |
| - |
37 |
| -def _check_ax_name(axname, argname): |
38 |
| - valid_args = ['x', 'y'] |
39 |
| - if axname.lower() not in valid_args: |
40 |
| - msg = 'Invalid value for {} ({}). Must be on of {}.' |
41 |
| - raise ValueError(msg.format(argname, arg, valid_args)) |
42 |
| - |
43 |
| - return axname.lower() |
44 |
| - |
45 |
| - |
46 |
| -def _check_ax_type(axtype): |
47 |
| - if axtype.lower() not in ['pp', 'qq', 'prob']: |
48 |
| - raise ValueError("invalid axtype: {}".format(axtype)) |
49 |
| - return axtype.lower() |
50 |
| - |
51 |
| - |
52 | 14 | def probplot(data, ax=None, axtype='prob', probax='x',
|
53 | 15 | otherscale='linear', xlabel=None, ylabel=None,
|
54 | 16 | bestfit=False, return_results=False,
|
@@ -99,15 +61,15 @@ def probplot(data, ax=None, axtype='prob', probax='x',
|
99 | 61 | """
|
100 | 62 |
|
101 | 63 | # check input values
|
102 |
| - fig, ax = _check_ax_obj(ax) |
103 |
| - probax = _check_ax_name(probax, 'probax') |
| 64 | + fig, ax = validate.axes_object(ax) |
| 65 | + probax = validate.axis_name(probax, 'x') |
104 | 66 |
|
105 | 67 | # default values for plotting options
|
106 | 68 | scatter_kws = {} if scatter_kws is None else scatter_kws.copy()
|
107 | 69 | line_kws = {} if line_kws is None else line_kws.copy()
|
108 | 70 |
|
109 | 71 | # check axtype
|
110 |
| - axtype = _check_ax_type(axtype) |
| 72 | + axtype = validate.axis_type(axtype) |
111 | 73 |
|
112 | 74 | # compute the plotting positions and sort the data
|
113 | 75 | qntls, datavals = stats.probplot(data, fit=False)
|
@@ -205,8 +167,8 @@ def _fit_line(x, y, xhat=None, fitprobs=None, fitlogs=None, dist=None):
|
205 | 167 |
|
206 | 168 | """
|
207 | 169 |
|
208 |
| - fitprobs = _check_fit_arg(fitprobs, "fitprobs") |
209 |
| - fitlogs = _check_fit_arg(fitlogs, "fitlogs") |
| 170 | + fitprobs = validate.fit_argument(fitprobs, "fitprobs") |
| 171 | + fitlogs = validate.fit_argument(fitlogs, "fitlogs") |
210 | 172 |
|
211 | 173 | # maybe set xhat to default values
|
212 | 174 | if xhat is None:
|
|
0 commit comments