def validate_input(): _generic('output_path', 'string') _generic('name', 'string') _generic('fig', mpl.figure.Figure) _generic('fig_ext', 'string') _levels('datasets', (_generic(None, 'mapping'), _generic(None, 'mapping')))
def _validate_transform_bwd(x, mn_tuple, overcomplete_mn_tuple=None): """ Validate a 2D transform. Parameters ---------- x : ndarray The m*n x 1 vector representing the associated column stacked matrix. mn_tuple : tuple of int `(m, n)` - `m` number of rows in the associated matrix, `n` number of columns in the associated matrix. overcomplete_mn_tuple : tuple of int, optional `(mo, no)` - `mo` number of rows in the associated matrix, `no` number of columns in the associated matrix. """ _levels('mn_tuple', (_generic(None, 'explicit collection', len_=2), _numeric(None, 'integer', range_='[1;inf)'))) m, n = mn_tuple if overcomplete_mn_tuple is None: shape = (m * n, 1) else: _generic('overcomplete_mn_tuple', 'explicit collection', len_=2) _numeric(('overcomplete_mn_tuple', 0), 'integer', range_='[{};inf)'.format(m)) _numeric(('overcomplete_mn_tuple', 1), 'integer', range_='[{};inf)'.format(n)) shape = (overcomplete_mn_tuple[0] * overcomplete_mn_tuple[1], 1) _numeric('x', ('integer', 'floating', 'complex'), shape=shape)
def validate_input(): _levels('settings', (_generic(None, 'mapping'), _generic(None, 'mapping'))) _generic('cmap', ('string', tuple), ignore_none=True) if isinstance(cmap, tuple): _generic(('cmap', 0), 'string') _generic(('cmap', 1), mpl.colors.Colormap)
def validate_input(): _numeric('data', ('integer', 'floating'), shape=(-1,)) _levels('hdrs', (_generic(None, 'explicit collection'), _generic(None, 'explicit collection', len_=2))) for i in range(len(hdrs)): _generic(('hdrs', i, 0), 'string')
def validate_input(): _numeric('img', ('integer', 'floating', 'complex'), shape=(-1, -1)) _levels( 'transforms', (_generic(None, 'explicit collection'), _generic(None, 'string', value_in=_utils.get_transform_names()))) _generic('output_path', 'string', ignore_none=True) _generic('fig_ext', 'string')
def validate_input(): _generic('attrs', 'mapping', has_keys=( 'xCenter', 'yCenter', 'xPoints', 'yPoints', 'pointSpacing')) _levels('points', (_generic(None, 'explicit collection', len_=self.attrs['yPoints']), _generic(None, 'explicit collection', len_=self.attrs['xPoints']), _generic(None, Point, ignore_none=True)))
def validate_input(): _generic('func', 'function') _generic('conj_trans', 'function') _generic('args', 'explicit collection') _levels('shape', (_generic(None, 'explicit collection', len_=2), _numeric(None, 'integer'))) _numeric('is_complex', 'boolean') _numeric('is_valid', 'boolean')
def validate_input(): _generic('params', 'mapping') _levels('valids', ( _generic(None, 'mapping', has_keys=tuple(params.keys())), _generic(None, 'explicit collection'))) for key in valids.keys(): _generic(('valids', key, 0), 'string', value_in=tuple(self._funcs.keys()))
def validate_output(): _levels('coefficients', (_generic(None, 'explicit collection'), _numeric(None, ('integer', 'floating', 'complex'), shape=img.shape))) _levels('reconstructions', (_generic(None, 'explicit collection'), _numeric(None, ('integer', 'floating', 'complex'), shape=img.shape)))
def validate_input(): _generic('params', 'mapping') _levels('valids', (_generic(None, 'mapping', has_keys=tuple(params.keys())), _generic(None, 'explicit collection'))) for key in valids.keys(): _generic(('valids', key, 0), 'string', value_in=tuple(self._funcs.keys()))
def validate_input(): _levels('hdrs', (_generic(None, 'explicit collection'), _generic(None, 'explicit collection', len_=2))) for i in range(len(hdrs)): _generic(('hdrs', i, 0), 'string') _numeric('width', 'integer', range_='[1;inf)') _numeric('height', 'integer', range_='[1;inf)') _numeric('data', ('integer', 'floating'), shape=(height * width,))
def validate_input(): _numeric('img', ('integer', 'floating', 'complex'), shape=(-1, -1)) _levels('reconstructions', (_generic(None, 'explicit collection'), _numeric(None, ('integer', 'floating', 'complex'), shape=img.shape))) _levels('fractions', (_generic(None, 'explicit collection'), _numeric(None, 'floating', range_='[0;1]'))) _numeric('return_vals', 'boolean') _generic('output_path', 'string', ignore_none=True) _generic('fig_ext', 'string')
def validate_input(): _levels('shape', (_generic(None, 'explicit collection', len_=2), _numeric(None, 'integer', range_='[1;inf)'))) if overcomplete_shape is not None: _generic('overcomplete_shape', 'explicit collection', len_=2), _numeric(('overcomplete_shape', 0), 'integer', range_='[{};inf)'.format(shape[0])) _numeric(('overcomplete_shape', 1), 'integer', range_='[{};inf)'.format(shape[1]))
def validate_input(): _generic('attrs', 'mapping', has_keys=('xPixels', 'yPixels')) _levels('buffers', (_generic( None, 'explicit collection'), _generic(None, Buffer))) attrs = self.attrs for i, buffer_ in enumerate(buffers): if buffer_.attrs['bufferLabel'][:9] != 'Thumbnail': _numeric('buffers[{}].data'.format(i), ('integer', 'floating'), shape=(attrs['yPixels'], attrs['xPixels']), var=buffer_.data)
def validate_input(): _levels('matrices', (_generic(None, 'explicit collection'), _numeric(None, ('integer', 'floating', 'complex'), shape=(-1, -1)))) for i in range(len(matrices) - 1): if matrices[i].shape[1] != matrices[i + 1].shape[0]: msg = ('The value of >>matrices[{}].shape[1]<<, {!r}, ' 'must be equal to the value of ' '>>matrices[{}].shape[0]<<, {!r}.') raise ValueError( msg.format(i, matrices[i].shape[1], i + 1, matrices[i + 1].shape[0]))
def validate_input(): _levels('curves', (_generic(None, 'collection'), _generic(None, 'mapping', has_keys=('delta', 'rho', 'label')))) for i, curve in enumerate(curves): _numeric(('curves', i, 'delta'), 'floating', range_='[0;1]', shape=(-1,)) _numeric(('curves', i, 'rho'), 'floating', range_='[0;1]', shape=(curve['delta'].shape[0],)) _generic(('curves', i, 'label'), 'string') _numeric('plot_l1', 'boolean') _generic('output_path', 'string', ignore_none=True)
def validate_input(): _levels( 'curves', (_generic(None, 'collection'), _generic(None, 'mapping', has_keys=('delta', 'rho', 'label')))) for i, curve in enumerate(curves): _numeric(('curves', i, 'delta'), 'floating', range_='[0;1]', shape=(-1, )) _numeric(('curves', i, 'rho'), 'floating', range_='[0;1]', shape=(curve['delta'].shape[0], )) _generic(('curves', i, 'label'), 'string') if 'yerr' in curve: _numeric(('curves', i, 'yerr'), 'floating', range_='[0;1]', shape=(2, curve['delta'].shape[0])) _numeric('plot_l1', 'boolean') _generic('output_path', 'string', ignore_none=True) _generic('legend_loc', 'string') _numeric('errorevery', 'integer', range_='[1;inf)', ignore_none=True) _levels( 'reference_curves', (_generic(None, 'collection', ignore_none=True), _generic(None, 'mapping', has_keys=('delta', 'rho', 'label')))) if reference_curves is not None: for i, ref_curve in enumerate(reference_curves): _numeric(('reference_curves', i, 'delta'), 'floating', range_='[0;1]', shape=(-1, )) _numeric(('reference_curves', i, 'rho'), 'floating', range_='[0;1]', shape=(ref_curve['delta'].shape[0], )) _generic(('reference_curves', i, 'label'), 'string') if 'style' in ref_curve: _generic(('reference_curves', i, 'style'), 'mapping')
def validate_input(): _generic('func', 'function') _generic('namespace', 'mapping') _levels('args_list', (_generic(None, 'collection', ignore_none=True), _generic(None, 'explicit collection'))) _levels('kwargs_list', (_generic(None, 'collection', ignore_none=True), _generic(None, 'mapping'))) if args_list is None and kwargs_list is None: msg = ('The value of >>args_list<<, {!r}, and/or the value of ' '>>kwargs_list<<, {!r}, must be different from {!r}.') raise ValueError(msg.format(args_list, kwargs_list, None)) elif args_list is not None and kwargs_list is not None: if len(args_list) != len(kwargs_list): msg = ('The value of >>len(args_list)<<, {!r}, must be equal ' 'to the value of >>len(kwargs_list)<<, {!r}.') raise ValueError(msg.format(len(args_list), len(kwargs_list))) _numeric('maxtasks', 'integer', range_='(0;inf)', ignore_none=True)
def validate_input(): _generic('func', 'function') _generic('namespace', 'mapping') _levels('args_list', (_generic(None, 'collection', ignore_none=True), _generic(None, 'explicit collection'))) _levels('kwargs_list', (_generic( None, 'collection', ignore_none=True), _generic(None, 'mapping'))) if args_list is None and kwargs_list is None: msg = ('The value of >>args_list<<, {!r}, and/or the value of ' '>>kwargs_list<<, {!r}, must be different from {!r}.') raise ValueError(msg.format(args_list, kwargs_list, None)) elif args_list is not None and kwargs_list is not None: if len(args_list) != len(kwargs_list): msg = ('The value of >>len(args_list)<<, {!r}, must be equal ' 'to the value of >>len(kwargs_list)<<, {!r}.') raise ValueError(msg.format(len(args_list), len(kwargs_list))) _numeric('maxtasks', 'integer', range_='(0;inf)', ignore_none=True)
def validate_input(): _levels( 'files', (_generic(None, 'explicit collection'), _generic(None, File))) if len(files) < 1: msg = 'The value of >>len(files)<<, {!r}, must be > 0.' raise ValueError(msg.format(len(files))) attrs = [{ name: value for name, value in file_.attrs.items() if name in self._params } for file_ in files] for i in range(1, len(files)): if attrs[i] != attrs[0]: raise ValueError('The values of >>files<< must have the ' 'same settings.') _levels('paths', (_generic(None, 'explicit collection', len_=len(files)), _generic(None, 'string')))
def validate_input(): _levels('columns', (_generic(None, 'explicit collection'), _generic(None, 'explicit collection'))) if len(columns) > 0: _levels('columns', (_generic(None, 'explicit collection'), _generic(None, 'explicit collection', len_=len(columns[0])))) _levels('headers', (_generic(None, 'explicit collection', len_=len(columns), ignore_none=True), _generic(None, 'string'))) try: _generic('bars', 'string') except TypeError: _levels('bars', (_generic(None, 'explicit collection', len_=len(columns) - 1), _generic(None, 'string')))
def validate_input(): _levels('columns', (_generic(None, 'explicit collection'), _generic(None, 'explicit collection'))) if len(columns) > 0: _levels('columns', (_generic(None, 'explicit collection'), _generic(None, 'explicit collection', len_=len(columns[0])))) _levels('headers', (_generic(None, 'explicit collection', len_=len(columns), ignore_none=True), _generic(None, 'string'))) try: _generic('bars', 'string') except TypeError: _levels('bars', (_generic(None, 'explicit collection', len_=len(columns) - 1), _generic(None, 'string')))
def validate_input(): _levels('coefficients', (_generic(None, 'explicit collection'), _numeric(None, ('integer', 'floating', 'complex'), shape=(-1, -1)))) _levels('reconstructions', (_generic(None, 'explicit collection', len_=len(coefficients)), _numeric(None, ('integer', 'floating', 'complex'), shape=(-1, -1)))) _generic('transform', 'string', value_in=_utils.get_transform_names()) _levels('fractions', (_generic(None, 'explicit collection', len_=len(coefficients)), _numeric(None, 'floating', range_='[0;1]'))) _generic('output_path', 'string', ignore_none=True) _generic('fig_ext', 'string')
def validate_input(): _generic('attrs', 'mapping', has_keys=('fileType', )) _levels('buffers', (_generic( None, 'explicit collection'), _generic(None, BaseClass)))
The seed used when picking seeds for generating data for the monte carlo simulations (the default is None, which implies an arbitrary seed). """ from __future__ import division from magni.utils.config import Configger as _Configger from magni.utils.validation import validate_generic as _generic from magni.utils.validation import validate_levels as _levels from magni.utils.validation import validate_numeric as _numeric configger = _Configger( {'coefficients': 'rademacher', 'delta': [0.0, 1.0], 'monte_carlo': 1, 'problem_size': 800, 'rho': [0.0, 1.0], 'seed': None}, {'coefficients': _generic(None, 'string', value_in=('rademacher', 'gaussian')), 'delta': _levels(None, ( _generic(None, 'explicit collection'), _numeric(None, 'floating', range_='[0;1]'))), 'monte_carlo': _numeric(None, 'integer', range_='[1;inf)'), 'rho': _levels(None, ( _generic(None, 'explicit collection'), _numeric(None, 'floating', range_='[0;1]'))), 'problem_size': _numeric(None, 'integer', range_='[1;inf)'), 'seed': _numeric(None, 'integer', range_='[0;inf)', ignore_none=True)})
def validate_input(): _levels('brews', (_generic(None, 'mapping'), _generic(None, 'explicit collection'), _generic(None, 'explicit collection', len_=3), _numeric(None, 'integer', range_='[0;255]')))
def validate_input(): _levels('settings', (_generic(None, 'mapping'), _generic(None, 'mapping'))) _generic('cmap', 'string', ignore_none=True)
def validate_input(): _levels('brews', (_generic(None, 'mapping'), _generic(None, 'explicit collection'), _generic(None, 'explicit collection', len_=3), _numeric(None, 'integer', range_='[0;255]')))
def validate_input(): _levels('shape', (_generic(None, 'explicit collection', len_=2), _numeric(None, 'integer', range_='[1;inf)')))
value_in=(np.float, getattr(np, 'float16', np.float_), getattr(np, 'float32', np.float_), getattr(np, 'float64', np.float_), getattr(np, 'float128', np.float_), getattr(np, 'complex64', np.complex_), getattr(np, 'complex128', np.complex_), getattr(np, 'complex256', np.complex_))), 'report_A_asq_setup': _numeric(None, 'boolean'), 'report_history': _numeric(None, 'boolean'), 'stop_criterion': _generic(None, 'class', superclass=_StopCriterion), 'sum_approximation_constant': _levels( None, (_generic(None, 'mapping', keys_in=('rangan', 'krzakala'), len_=1), _numeric(None, ('integer', 'floating'), range_='(0;inf)'))), 'tolerance': _numeric(None, 'floating', range_='[0;inf)'), 'true_solution': _numeric(None, ('integer', 'floating', 'complex'), shape=(-1, 1), ignore_none=True), 'warm_start': _levels( None, (_generic(None, 'explicit collection', len_=2, ignore_none=True), _numeric(None, ('integer', 'floating', 'complex'), shape=(-1, 1)))) })
def validate_input(): _numeric('img', ('integer', 'floating', 'complex'), shape=(-1, -1)) _generic('transform', 'string', value_in=_utils.get_transform_names()) _levels('fractions', (_generic(None, 'explicit collection'), _numeric(None, 'floating', range_='[0;1]')))
def validate_input(): _levels( 'imgs', (_generic(None, 'explicit collection'), _numeric(None, ('boolean', 'integer', 'floating'), shape=(-1, -1)))) _numeric('rows', 'integer', range_='[1;inf)') _levels('titles', (_generic( None, 'explicit collection', len_=len(imgs), ignore_none=True), _generic(None, 'string'))) _levels('x_labels', (_generic( None, 'explicit collection', len_=len(imgs), ignore_none=True), _generic(None, 'string'))) _levels('y_labels', (_generic( None, 'explicit collection', len_=len(imgs), ignore_none=True), _generic(None, 'string'))) _levels('x_ticklabels', (_generic(None, 'explicit collection', ignore_none=True), _generic(None, ('explicit collection', 'string')), _generic(None, 'string'))) _levels('y_ticklabels', (_generic(None, 'explicit collection', ignore_none=True), _generic(None, ('explicit collection', 'string')), _generic(None, 'string'))) _generic('cbar_label', 'string', ignore_none=True) _levels( 'fixed_clim', (_generic(None, 'explicit collection', len_=2, ignore_none=True), _numeric(None, ('integer', 'floating')))) _numeric('normalise', 'boolean')
None, 'system_matrix': 'USE' }, { 'algorithm_kwargs': _generic(None, 'mapping'), 'coefficients': _generic(None, 'string', value_in=('rademacher', 'gaussian', 'laplace', 'bernoulli')), 'custom_noise_factory': _generic(None, (_FunctionType, _Callable)), 'custom_system_matrix_factory': _generic(None, (_FunctionType, _Callable)), 'delta': _levels(None, (_generic(None, 'explicit collection'), _numeric(None, 'floating', range_='[0;1]'))), 'logit_solver': _generic(None, 'string', value_in=('built-in', 'sklearn')), 'maxpoints': _numeric(None, 'integer', range_='[1;inf)', ignore_none=True), 'monte_carlo': _numeric(None, 'integer', range_='[1;inf)'), 'noise': _generic(None, 'string', value_in=('AWGN', 'AWLN', 'custom'), ignore_none=True), 'problem_size': _numeric(None, 'integer', range_='[1;inf)'), 'rho': _levels(None, (_generic(None, 'explicit collection'),
def validate_input(): _generic('attrs', 'mapping', has_keys=('bufferLabel', )) _levels('data', (_generic(None, 'explicit collection'), _generic(None, (Grid, Point, Chunk))))
def validate_input(): _levels('buffers', (_generic( None, 'explicit collection'), _generic(None, Buffer)))
def validate_input(): _generic('attrs', 'mapping', has_keys=tuple(Point._params.keys())) _levels( 'chunks', (_generic(None, 'explicit collection'), _generic(None, Chunk)))