Beispiel #1
0
def validate_lonlatbox(value):
    validate = try_and_error(validate_float, validate_str)
    try:
        return validate_none(value)
    except (TypeError, ValueError):
        try:
            return validate_str(value)
        except (TypeError, ValueError):
            if len(value) != 4:
                raise ValueError("Need 4 values for longitude-latitude box, "
                                 "got %i" % len(value))
            return list(map(validate, value))
Beispiel #2
0
 def validate(val):
     if isinstance(val, six.string_types) and val.startswith('poly'):
         try:
             int(val[4:])
         except ValueError:
             raise ValueError("Polynomials must be of the form 'poly<deg>' "
                              "(e.g. 'poly3'), not %s!" % val)
         else:
             return val
     elif hasattr(val, 'fit') and hasattr(val, 'predict'):
         return val
     return try_and_error(
         validate_callable, validate_none,
         ValidateInStrings('fit', ['fit', 'linear', 'robust'], True))(val)
Beispiel #3
0
def validate_lsm(val):
    res_validation = try_and_error(validate_bool, validate_str)
    try:
        val = res_validation(val)
    except (ValueError, TypeError):
        pass
    else:
        return [val, 1.0]
    try:
        val = validate_float(val)
    except (ValueError, TypeError):
        pass
    else:
        return [True, val]
    res, lw = val
    return [res_validation(res), validate_float(lw)]
Beispiel #4
0
def validate_fix(val):
    if val is None:
        return [None]
    try:
        val = validate_float(val)
        return [[0, val]]
    except ValueError:
        pass
    msg = 'Values for the fix formatoptions must be of length 2!'
    validator = try_and_error(validate_none, validate_list(float))
    try:
        val = validator(val)
    except ValueError:
        val = list(map(validator, val))
        if not all(v is None or len(v) == 2 for v in val):
            raise ValueError(msg)
    else:
        if val is not None and len(val) != 2:
            raise ValueError(msg)
    return val
Beispiel #5
0
def validate_p0(value):
    value = safe_list(value)
    for i, v in enumerate(value):
        value[i] = try_and_error(ValidateList(float),
                                 ValidateInStrings('p0', ['auto'], True))(v)
    return value
Beispiel #6
0
    'plotter.linreg.param_bounds': [
        None, validate_param_bounds,
        'fmt key to specify the boundaries of the fit'],
    'plotter.linreg.p0': [
        'auto', validate_p0,
        'fmt key to specify the initial parameters of the fit'],
    'plotter.linreg.fix': [
        None, validate_fix,
        'fmt key to set a fix point for the linear regression fit'],
    'plotter.linreg.fit': [
        'fit', validate_fit, 'The model to use for fitting a model'],
    'plotter.linreg.nboot': [
        1000, validate_int,
        'Number of bootstrap resamples to estimate the confidence interval'],
    'plotter.linreg.ci': [
        95, try_and_error(validate_none, validate_float),
        'Size of the confidence interval'],
    'plotter.linreg.id_color': [
        None, psyps_rc.validate['plotter.simple.color'],
        'fmt key to modify the color cycle of the ideal lines in a fit plot'],
    'plotter.linreg.ideal': [
        None, validate_ideal,
        'The ideal lines to plot'],
    'plotter.linreg.bootstrap.random_seed': [
        None, try_and_error(validate_none, validate_int),
        'The seed to use for the bootstrap algorithm to estimate the '
        'confidence interval'],

    # combined density and linear regression plot
    'plotter.densityreg.lineplot': [
        '-', try_and_error(validate_none, validate_str,
Beispiel #7
0
 # MapBase
 'plotter.maps.lonlatbox': [
     None, validate_lonlatbox,
     'fmt key to define the longitude latitude box of the data'
 ],
 'plotter.maps.map_extent': [
     None, validate_lonlatbox,
     'fmt key to define the extent of the map plot'
 ],
 'plotter.maps.clip': [
     None, validate_bool_maybe_none,
     'fmt key to define clip the axes outside the latitudes'
 ],
 'plotter.maps.clon': [
     None,
     try_and_error(validate_none, validate_float, validate_str),
     'fmt key to specify the center longitude of the projection'
 ],
 'plotter.maps.clat': [
     None,
     try_and_error(validate_none, validate_float, validate_str),
     'fmt key to specify the center latitude of the projection'
 ],
 # TODO: Implement the drawing of shape files on a map
 # 'plotter.maps.lineshapes': [None, try_and_error(
 #     validate_none, validate_dict, validate_str, validate_stringlist)],
 'plotter.maps.grid_labels': [
     None, validate_bool_maybe_none,
     'fmt key to draw labels of the lat-lon-grid'
 ],
 'plotter.maps.grid_labelsize': [