Validate the input parametersm, return True if valid, False otherwise
(self, params)
| 1708 | return details |
| 1709 | |
| 1710 | def valid_params(self, params): |
| 1711 | """Validate the input parametersm, return True if valid, False otherwise""" |
| 1712 | |
| 1713 | valid = True |
| 1714 | xmin = params.get('xmin') |
| 1715 | if xmin and xmin not in [XMIN.UNKNOWN, XMIN.AUTO, XMIN.PEAK]: |
| 1716 | logger.warn("param xmin unknown, ignoring {}".format(xmin)) |
| 1717 | valid = False |
| 1718 | |
| 1719 | xmax = params.get('xmax') |
| 1720 | if xmax and xmax not in [XMAX.UNKNOWN, XMIN.AUTO]: |
| 1721 | logger.warn("param xmax unknown, ignoring {}".format(xmax)) |
| 1722 | valid = False |
| 1723 | |
| 1724 | min_evals = params.get('min_evals') |
| 1725 | max_evals = params.get('max_evals') |
| 1726 | if min_evals and max_evals and min_evals >= max_evals: |
| 1727 | logger.warn("min_evals {} > max_evals {}".format(min_evals, max_evals)) |
| 1728 | valid = False |
| 1729 | elif max_evals and max_evals < -1: |
| 1730 | logger.warn(" max_evals {} < -1 ".format(max_evals)) |
| 1731 | valid = False |
| 1732 | |
| 1733 | # can not specify ww2x and conv2d_fft at same time |
| 1734 | if params.get('ww2x') and params.get('conv2d_fft'): |
| 1735 | logger.warn("can not specify ww2x and conv2d_fft") |
| 1736 | valid = False |
| 1737 | |
| 1738 | |
| 1739 | # can not specify intra and conv2d_fft at same time |
| 1740 | if params.get('intra') and params.get('conv2d_fft'): |
| 1741 | logger.warn("can not specify intra and conv2d_fft") |
| 1742 | valid = False |
| 1743 | |
| 1744 | # channels must be None, 'first', or 'last' |
| 1745 | channels = params.get('channels') |
| 1746 | if channels is not None and isinstance(channels,str): |
| 1747 | if channels.lower() != 'first' and channels.lower() != 'last': |
| 1748 | logger.warn("unknown channels {}".format(channels)) |
| 1749 | valid = False |
| 1750 | |
| 1751 | # layer ids must be all positive or all negative |
| 1752 | filters = params.get('layers') |
| 1753 | if filters is not None: |
| 1754 | filter_ids = [int(f) for f in filters if type(f) is int] |
| 1755 | |
| 1756 | if len(filter_ids) > 0: |
| 1757 | if np.max(filter_ids) > 0 and np.min(filter_ids) < 0: |
| 1758 | logger.warn("layer filter ids must be all > 0 or < 0: {}".format(filter_ids)) |
| 1759 | valid = False |
| 1760 | |
| 1761 | savefig = params.get('savefig') |
| 1762 | savedir = params.get('savedir') |
| 1763 | if savefig and isinstance(savefig,bool): |
| 1764 | logger.info("Saving all images to {}".format(savedir)) |
| 1765 | elif savefig and isinstance(savefig,str): |
| 1766 | params['savedir'] = savefig |
| 1767 | logger.info("Saving all images to {}".format(savedir)) |
no outgoing calls
no test coverage detected