|
4 | 4 | from plantcv.plantcv import plot_image |
5 | 5 |
|
6 | 6 |
|
7 | | -def _debug(visual, filename=None, **kwargs): |
8 | | - """ |
9 | | - Save or display a visual for debugging. |
| 7 | +def _debug(visual, filename=None, verbosity_level=0, **kwargs): |
| 8 | + """Save or display a visual for debugging. |
10 | 9 |
|
11 | | - Inputs: |
12 | | - visual - An image or plot to display for debugging |
13 | | - filename - An optional filename to save the visual to (default: None) |
14 | | - kwargs - key-value arguments to xarray.plot method |
| 10 | + Parameters |
| 11 | + ---------- |
| 12 | + visual : numpy.ndarray |
| 13 | + An image or plot to display for debugging |
| 14 | + filename : str, optional |
| 15 | + An optional filename to save the visual to (default: None) |
| 16 | + verbosity_level : int, optional |
| 17 | + Threshold for params.verbose to make debug image. |
| 18 | + Defaults to 0, which essentially ignores params.verbose |
| 19 | + **kwargs : dict |
| 20 | + Key-value arguments to xarray.plot method |
15 | 21 |
|
16 | | - :param visual: numpy.ndarray |
17 | | - :param filename: str |
18 | | - :param kwargs: dict |
| 22 | + Returns |
| 23 | + ------- |
| 24 | + None |
19 | 25 | """ |
20 | | - # Auto-increment the device counter |
21 | | - params.device += 1 |
| 26 | + # if verbose from params is at least to the verbosity level, make debug images |
| 27 | + if params.verbose >= verbosity_level: |
| 28 | + # Auto-increment the device counter |
| 29 | + params.device += 1 |
22 | 30 |
|
23 | | - if params.debug == "print": |
24 | | - # If debug is print, save the image to a file |
25 | | - print_image(img=visual, filename=filename, **kwargs) |
26 | | - elif params.debug == "plot": |
27 | | - # If debug is plot, print to the plotting device |
28 | | - plot_image(img=visual, **kwargs) |
| 31 | + if params.debug == "print": |
| 32 | + # If debug is print, save the image to a file |
| 33 | + print_image(img=visual, filename=filename, **kwargs) |
| 34 | + elif params.debug == "plot": |
| 35 | + # If debug is plot, print to the plotting device |
| 36 | + plot_image(img=visual, **kwargs) |
0 commit comments