Пример #1
0
def test_process_combo_name():
    """select_combos.table_processing: test process_combo_name"""
    combo_names = [
        'test', '123test-test',
        'testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest']
    data = pandas.DataFrame(combo_names, columns=['combo_name'])
    log_filename = os.path.join(TEST_DIR, 'log.csv')
    # make sure the file does not exist yet
    if os.path.isfile(log_filename):
        os.remove(log_filename)

    # compose expected NEURON-compliant names
    expected_names = []
    nt.assert_true(tools.check_compliance_with_neuron(combo_names[0]))
    expected_names.append(combo_names[0])
    nt.assert_false(tools.check_compliance_with_neuron(combo_names[1]))
    name = combo_names[1].lstrip(digits).replace('-', '_')
    nt.assert_true(tools.check_compliance_with_neuron(name))
    expected_names.append(name)
    nt.assert_false(tools.check_compliance_with_neuron(combo_names[2]))
    name = tools.get_neuron_compliant_template_name(combo_names[2])
    nt.assert_true(tools.check_compliance_with_neuron(name))
    expected_names.append(name)

    expected_df = pandas.DataFrame(expected_names, columns=['combo_name'])

    table_processing.process_combo_name(data, log_filename)
    pandas.util.testing.assert_frame_equal(data, expected_df)
    nt.assert_true(os.path.isfile(log_filename))
    # clear output
    if os.path.isfile(log_filename):
        os.remove(log_filename)
Пример #2
0
def test_get_neuron_compliant_template_name():
    """bluepymm.tools: test get neuron-compliant template name"""
    name = 'test'
    nt.assert_true(tools.check_compliance_with_neuron(name))
    ret = tools.get_neuron_compliant_template_name(name)
    nt.assert_equal(ret, name)
    nt.assert_true(tools.check_compliance_with_neuron(ret))

    name = '123test-test'
    nt.assert_false(tools.check_compliance_with_neuron(name))
    ret = tools.get_neuron_compliant_template_name(name)
    nt.assert_equal(ret, name.lstrip(digits).replace('-', '_'))
    nt.assert_true(tools.check_compliance_with_neuron(ret))

    name = 'testtesttesttesttesttesttesttesttesttesttesttesttesttesttest'
    nt.assert_false(tools.check_compliance_with_neuron(name))
    ret = tools.get_neuron_compliant_template_name(name)
    nt.assert_true(tools.check_compliance_with_neuron(ret))
Пример #3
0
def process_combo_name(data, log_filename):
    """Make value corresponding to key 'combo_name' compliant with NEURON rules
    for template names. A log file is written out in csv format.

    Args:
        data: pandas.DataFrame with key 'combo_name'
        log_filename: path to log file
    """
    log_data = pandas.DataFrame()
    log_data['original_combo_name'] = data['combo_name'].copy()

    data['combo_name'] = data.apply(
        lambda x: tools.get_neuron_compliant_template_name(x['combo_name']),
        axis=1)

    log_data['neuron_compliant_combo_name'] = data['combo_name'].copy()
    log_data.to_csv(log_filename, index=False)