Esempio n. 1
0
def test_neurolucida_format_convert():
    with open("test/neurolucida.asc", "rt") as fp:
        data = fp.read()
        out, err = command.run_lmeasure(data, *lm_metrics)
        command.check_errors(err)

        swc = command.run_convert(data)
        out, err = command.run_lmeasure(swc, *lm_metrics)
        command.check_errors(err)
Esempio n. 2
0
def lmeasure():
    if request.method == "OPTIONS":
        resp = jsonify(measure_options)
        resp.headers['Allow'] = "POST,OPTIONS"
        return resp
    elif request.method == "POST":
        if request.is_json:
            d = request.get_json()
        else:
            d = request.form
        if "data" not in d:
            return jsonify({"error": "no 'data' field in request"}), 400
        if "metrics" not in d:
            metrics = command.lm_function_names
        elif isinstance(d["metrics"], str):
            metrics = (d["metrics"], )
        elif isinstance(d["metrics"], list):
            metrics = d["metrics"]
        app.logger.debug('requested metrics: %s', metrics)
        try:
            out, err = command.run_lmeasure(d["data"], *metrics)
            app.logger.debug('stdout: %s', out)
            app.logger.debug('stderr: %s', err)
            command.check_errors(err)
            measures = [d for d in command.parse_results(out)]
        except KeyError as e:
            return jsonify({"error":
                            "bad metric '{}' requested".format(e)}), 400
        except RuntimeError as e:
            return jsonify({"error": "l-measure failed: {!s}".format(e)}), 400
        else:
            return jsonify({"error": None, "measures": measures})
Esempio n. 3
0
def test_metric_names_match_list():
    with open("test/neuron.swc", "rt") as fp:
        data = fp.read()
        out, err = command.run_lmeasure(data, *lm_metrics)
        command.check_errors(err)
        result = tuple(command.parse_results(out))
        assert_sequence_equal([x['metric'] for x in result], lm_metrics)
Esempio n. 4
0
def test_neurolucida_format_ok():
    with open("test/neurolucida.asc", "rt") as fp:
        data = fp.read()
        out, err = command.run_lmeasure(data, lm_metrics[0])
        command.check_errors(err)
        tuple(command.parse_results(out))
Esempio n. 5
0
def test_bad_metric_raises_error():
    data = "blah blah blah"
    out, err = command.run_lmeasure(data, "amazingness")
Esempio n. 6
0
def test_no_metrics_raises_error():
    data = "blah blah blah"
    out, err = command.run_lmeasure(data)
Esempio n. 7
0
def test_garbage_input_raises_error():
    data = "blah blah blah"
    out, err = command.run_lmeasure(data, lm_metrics[0])
    command.check_errors(err)
Esempio n. 8
0
def test_blank_file_rasies_error():
    with open("test/blank.swc", "rt") as fp:
        data = fp.read()
        out, err = command.run_lmeasure(data, lm_metrics[0])
        command.check_errors(err)