示例#1
0
def test_create_hoc():
    mech = utils.make_mech()
    parameters = utils.make_parameters()

    hoc = create_hoc.create_hoc([mech, ], parameters, template_name='CCell')
    nt.ok_('load_file' in hoc)
    nt.ok_('CCell' in hoc)
    nt.ok_('begintemplate' in hoc)
    nt.ok_('endtemplate' in hoc)
示例#2
0
def test_serialize():
    parameters = utils.make_parameters()

    for param in parameters:
        serialized = param.to_dict()
        nt.ok_(isinstance(json.dumps(serialized), str))
        deserialized = instantiator(serialized)
        nt.ok_(isinstance(deserialized, param.__class__))
        nt.eq_(deserialized.name, param.__class__.__name__)
示例#3
0
def test__generate_parameters():
    parameters = utils.make_parameters()

    section_params, range_params = create_hoc._generate_parameters(parameters)

    nt.eq_(len(section_params[1]), 2)
    nt.eq_(len(section_params[4]), 2)
    nt.eq_(section_params[4][0], 'somatic')
    nt.eq_(len(section_params[4][1]), 2)
示例#4
0
def test_create_hoc():
    """ephys.create_hoc: Test create_hoc"""
    mech = utils.make_mech()
    parameters = utils.make_parameters()

    hoc = create_hoc.create_hoc([mech, ], parameters, template_name='CCell')
    nt.ok_('load_file' in hoc)
    nt.ok_('CCell' in hoc)
    nt.ok_('begintemplate' in hoc)
    nt.ok_('endtemplate' in hoc)
示例#5
0
def test__generate_parameters():
    parameters = utils.make_parameters()

    global_params, section_params, range_params = \
        create_hoc._generate_parameters(parameters)

    nt.eq_(global_params, {'NrnGlobalParameter': 65})
    nt.eq_(len(section_params[1]), 2)
    nt.eq_(len(section_params[4]), 2)
    nt.eq_(section_params[4][0], 'somatic')
    nt.eq_(len(section_params[4][1]), 2)
def test__generate_parameters():
    parameters = utils.make_parameters()

    global_params, section_params, range_params = \
        create_hoc._generate_parameters(parameters)

    nt.eq_(global_params, {'NrnGlobalParameter': 65})
    nt.eq_(len(section_params[1]), 2)
    nt.eq_(len(section_params[4]), 2)
    nt.eq_(section_params[4][0], 'somatic')
    nt.eq_(len(section_params[4][1]), 2)
示例#7
0
def test__generate_parameters():
    """ephys.create_hoc: Test _generate_parameters"""
    parameters = utils.make_parameters()

    global_params, section_params, range_params = \
        create_hoc._generate_parameters(parameters)

    nt.assert_equal(global_params, {'NrnGlobalParameter': 65})
    nt.assert_equal(len(section_params[1]), 2)
    nt.assert_equal(len(section_params[4]), 2)
    nt.assert_equal(section_params[4][0], 'somatic')
    nt.assert_equal(len(section_params[4][1]), 2)
    nt.assert_equal(range_params, [])
示例#8
0
def test__generate_parameters():
    """ephys.create_hoc: Test _generate_parameters"""
    parameters = utils.make_parameters()

    global_params, section_params, range_params, location_order = \
        create_hoc._generate_parameters(parameters)

    nt.assert_equal(global_params, {'NrnGlobalParameter': 65})
    nt.assert_equal(len(section_params[1]), 2)
    nt.assert_equal(len(section_params[4]), 2)
    nt.assert_equal(section_params[4][0], 'somatic')
    nt.assert_equal(len(section_params[4][1]), 2)
    nt.assert_equal(range_params, [])
    nt.assert_equal(location_order, DEFAULT_LOCATION_ORDER)
示例#9
0
def test_create_hoc_filename():
    """ephys.create_hoc: Test create_hoc template_filename"""
    mech = utils.make_mech()
    parameters = utils.make_parameters()

    hoc = create_hoc.create_hoc([mech, ],
                                parameters, template_name='CCell',
                                template_filename='test.jinja2',
                                template_dir=os.path.join(
                                    os.path.dirname(__file__),
                                    'testdata'))
    nt.ok_('load_file' in hoc)
    nt.ok_('CCell' in hoc)
    nt.ok_('begintemplate' in hoc)
    nt.ok_('endtemplate' in hoc)
    nt.ok_('Test template' in hoc)
示例#10
0
def test_create_hoc_filename():
    """ephys.create_hoc: Test create_hoc template_filename"""
    mech = utils.make_mech()
    parameters = utils.make_parameters()

    hoc = create_hoc.create_hoc([
        mech,
    ],
                                parameters,
                                template_name='CCell',
                                template_filename='test.jinja2',
                                template_dir=os.path.join(
                                    os.path.dirname(__file__), 'testdata'))
    nt.ok_('load_file' in hoc)
    nt.ok_('CCell' in hoc)
    nt.ok_('begintemplate' in hoc)
    nt.ok_('endtemplate' in hoc)
    nt.ok_('Test template' in hoc)
示例#11
0
def test_create_hoc_filename():
    """ephys.create_hoc: Test create_hoc template_filename"""
    mech = utils.make_mech()
    parameters = utils.make_parameters()
    custom_param_val = 'printf("Hello world!")'

    hoc = create_hoc.create_hoc([mech, ],
                                parameters, template_name='CCell',
                                template_filename='test.jinja2',
                                template_dir=os.path.join(
                                    os.path.dirname(__file__),
                                    'testdata'),
                                custom_jinja_params={
                                    'custom_param': custom_param_val})
    nt.ok_('load_file' in hoc)
    nt.ok_('CCell' in hoc)
    nt.ok_('begintemplate' in hoc)
    nt.ok_('endtemplate' in hoc)
    nt.ok_('Test template' in hoc)
    nt.ok_(custom_param_val in hoc)