def interpret_arguments(wave, points, arguments):
    # N
    try:
        N = int(arguments['N'])
        if N < 0:
            raise ValueError
    except:
        raise InvalidArgumentError("Invalid filter order "
                                   "{}".format(arguments['N']))
    # btype
    if (arguments['btype']
            not in ['lowpass', 'highpass', 'bandpass', 'bandstop']):
        raise InvalidArgumentError("Invalid filter type "
                                   "{}".format(arguments['btype']))
    btype = arguments['btype']
    # Wn
    try:
        Wn = []
        if btype in ['bandpass', 'bandstop']:
            Wn_strings = arguments['Wn'].split(',')
            Wn = np.array([float(string) for string in Wn_strings])
        else:
            Wn = float(arguments['Wn'])
    except:
        raise InvalidArgumentError("Invalid cutoff frequency for this type"
                                   "{}".format(arguments['Wn']))
    if type(Wn) == float:
        _testvals = [Wn]
    else:
        _testvals = Wn
    if any(val > wave.sample_rate / 2 for val in _testvals):
        raise InvalidArgumentError("Cutoff frequency may not be greater than "
                                   "half of waveform's sample rate.")
    return {'N': N, 'Wn': Wn, 'btype': btype}
def execute(waves, points, begin_time, end_time, arguments):
    """Sprawdza poprawność argumentów i wykonuje procedurę."""
    valid, error_message = validate_arguments(waves, points, arguments)
    if not valid:
        raise InvalidArgumentError(error_message)
    arguments = interpret_arguments(arguments)
    return procedure(waves, points, begin_time, end_time, arguments)
def interpret_arguments(wave, points, arguments):
    "Sprawdza, czy podane argumenty są poprawne."
    #a
    try:
        a = float(arguments['a'])
    except:
        InvalidArgumentError("Invalid filter order "
                             "{}".format(arguments['a']))
    #b
    try:
        b = float(arguments['b'])
    except:
        raise InvalidArgumentError("Invalid filter order "
                                   "{}".format(arguments['b']))

    return {'a': a, 'b': b}
Beispiel #4
0
def interpret_arguments(waves, points, arguments):
    output_arguments = {}
    for key, item in arguments.items():
        try:
            output_arguments[key] = float(item)
        except:
            raise InvalidArgumentError("{} is invalid.".format(arguments[key]))
    return output_arguments
def interpret_arguments(waves, points, arguments):
    output_arguments = {}
    for key, item in arguments.items():
        if (item != '+' and item != '-' and item != '*' and item != 'sqr'
                and item != '/'):
            raise InvalidArgumentError("{} is invalid.".format(arguments[key]))
        else:
            output_arguments[key] = item
    return output_arguments
def interpret_arguments(wave, points, arguments):
    "Sprawdza, czy podane argumenty są poprawne."
    #a
    try:
        a = int(arguments['Sample count'])
    except:
        raise InvalidArgumentError("Invalid filter order "
                                   "{}".format(arguments['Ilość próbek']))

    return {'Sample count': a}
def interpret_arguments(waves, points, arguments):
    # net
    try:
        net = pickle.load(open(arguments['net'], 'rb'))
    except:
        raise InvalidArgumentError("Invalid neural net file")
    # focus_range
    try:
        focus_range = [
            float(string) for string in arguments['focus_range'].split(',')
        ]
    except:
        raise InvalidArgumentError("Invalid focus range")
    if len(focus_range) != 2:
        raise InvalidArgumentError("Invalid number of focus range values")
    try:
        test_every = float(arguments['test_every'])
    except:
        raise InvalidArgumentError("Invalid `test_every` value")
    return {'net': net, 'focus_range': focus_range, 'test_every': test_every}
Beispiel #8
0
def interpret_arguments(wave, points, arguments):
    "Sprawdza, czy podane argumenty są poprawne."
    #u
    try:
        u = float(arguments['u'])
    except:
        InvalidArgumentError("Invalid filter order "
                             "{}".format(arguments['u']))

    return {
        'u': u,
    }