예제 #1
0
파일: test_utils.py 프로젝트: MFSY/NeuroM
def test_ignore_exceptions():
    pop = utils.load_neurons((NO_SOMA_FILE, ), ignored_exceptions=(SomaError, ))
    nt.eq_(len(pop), 0)

    pop = utils.load_neurons((NO_SOMA_FILE, ),
                             ignored_exceptions=(SomaError, RawDataError, ))
    nt.eq_(len(pop), 0)
예제 #2
0
def test_load_neurons_filenames():
    pop = utils.load_neurons(FILENAMES, name='test123')
    assert len(pop.neurons) == 2
    assert pop.name == 'test123'
    for nrn, name in zip(pop.neurons, NRN_NAMES):
        assert isinstance(nrn, Neuron)
        assert nrn.name == name
예제 #3
0
def test_load_neurons_directory_name():
    pop = utils.load_neurons(VALID_DATA_PATH, name='test123')
    nt.assert_equal(len(pop.neurons), 4)
    nt.assert_equal(len(pop), 4)
    nt.assert_equal(pop.name, 'test123')
    for nrn in pop:
        nt.assert_true(isinstance(nrn, Neuron))
예제 #4
0
def test_load_neurons_filenames():
    pop = utils.load_neurons(FILENAMES, name='test123')
    nt.assert_equal(len(pop.neurons), 2)
    nt.assert_equal(pop.name, 'test123')
    for nrn, name in zip(pop.neurons, NRN_NAMES):
        nt.assert_true(isinstance(nrn, Neuron))
        nt.assert_equal(nrn.name, name)
예제 #5
0
def test_load_neurons_directory_name():
    pop = utils.load_neurons(VALID_DATA_PATH, name='test123')
    assert len(pop.neurons) == 4
    assert len(pop) == 4
    assert pop.name == 'test123'
    for nrn in pop:
        assert isinstance(nrn, Neuron)
예제 #6
0
def test_load_neurons_directory():
    pop = utils.load_neurons(VALID_DATA_PATH)
    assert len(pop.neurons) == 4
    assert len(pop) == 4
    assert pop.name == 'valid_set'
    for nrn in pop:
        assert isinstance(nrn, Neuron)
예제 #7
0
def test_load_neurons_directory():
    pop = utils.load_neurons(VALID_DATA_PATH)
    nt.assert_equal(len(pop.neurons), 4)
    nt.assert_equal(len(pop), 4)
    nt.assert_equal(pop.name, 'valid_set')
    for nrn in pop:
        nt.assert_true(isinstance(nrn, Neuron))
예제 #8
0
def test_load_neurons_directory_name():
    pop = utils.load_neurons(VALID_DATA_PATH, name='test123')
    nt.assert_equal(len(pop.neurons), 5)
    nt.assert_equal(len(pop), 5)
    nt.assert_equal(pop.name, 'test123')
    for nrn in pop:
        nt.assert_true(isinstance(nrn, Neuron))
예제 #9
0
def test_load_neurons_filenames():

    pop = utils.load_neurons(FILENAMES, name='test123')
    nt.assert_equal(len(pop.neurons), 3)
    nt.assert_equal(pop.name, 'test123')
    for nrn, name in zip(pop.neurons, NRN_NAMES):
        nt.assert_true(isinstance(nrn, Neuron))
        nt.assert_equal(nrn.name, name)
예제 #10
0
def test_load_neurons_directory():

    pop = utils.load_neurons(VALID_DATA_PATH)
    nt.assert_equal(len(pop.neurons), 5)
    nt.assert_equal(len(pop), 5)
    nt.assert_equal(pop.name, 'valid_set')
    for nrn in pop:
        nt.assert_true(isinstance(nrn, Neuron))
예제 #11
0
def test_load_neurons():
    # List of strings
    nrns = utils.load_neurons(map(str, FILES), neuron_loader=_mock_load_neuron)
    for i, nrn in enumerate(nrns):
        assert nrn.name == FILES[i].stem

    with pytest.raises(NeuroMError):
        utils.load_neurons(MISSING_PARENTS_FILE, )

    # Single string
    nrns = utils.load_neurons(str(FILES[0]), neuron_loader=_mock_load_neuron)
    assert nrns[0].name == FILES[0].stem

    # Single Path
    nrns = utils.load_neurons(FILES[0], neuron_loader=_mock_load_neuron)
    assert nrns[0].name == FILES[0].stem

    # sequence of strings
    nrns = utils.load_neurons(map(str, FILES), neuron_loader=_mock_load_neuron)
    for i, nrn in enumerate(nrns):
        assert nrn.name == FILES[i].stem

    # sequence of Path objects
    nrns = utils.load_neurons(FILES, neuron_loader=_mock_load_neuron)
    for nrn, file in zip(nrns, FILES):
        assert nrn.name == file.stem

    # string path to a directory
    nrns = utils.load_neurons(str(SWC_PATH), neuron_loader=_mock_load_neuron)
    # is subset so that if new morpho are added to SWC_PATH, the test does not break
    assert {f.stem for f in FILES}.issubset({nrn.name for nrn in nrns})

    # Path path to a directory
    nrns = utils.load_neurons(SWC_PATH, neuron_loader=_mock_load_neuron)
    # is subset so that if new morpho are added to SWC_PATH, the test does not break
    assert {f.stem for f in FILES}.issubset({nrn.name for nrn in nrns})
예제 #12
0
def test_load_neurons():
    # List of strings
    nrns = utils.load_neurons(map(str, FILES), neuron_loader=_mock_load_neuron)
    for i, nrn in enumerate(nrns):
        nt.assert_equal(nrn.name, FILES[i].stem)

    nt.assert_raises(RawDataError, utils.load_neurons,
                     (MISSING_PARENTS_FILE, ))

    # Single string
    nrns = utils.load_neurons(str(FILES[0]), neuron_loader=_mock_load_neuron)
    nt.assert_equal(nrns[0].name, FILES[0].stem)

    # Single Path
    nrns = utils.load_neurons(FILES[0], neuron_loader=_mock_load_neuron)
    nt.assert_equal(nrns[0].name, FILES[0].stem)

    # sequence of strings
    nrns = utils.load_neurons(map(str, FILES), neuron_loader=_mock_load_neuron)
    for i, nrn in enumerate(nrns):
        nt.assert_equal(nrn.name, FILES[i].stem)

    # sequence of Path objects
    nrns = utils.load_neurons(FILES, neuron_loader=_mock_load_neuron)
    for nrn, file in zip(nrns, FILES):
        nt.assert_equal(nrn.name, file.stem)

    # string path to a directory
    nrns = utils.load_neurons(str(SWC_PATH), neuron_loader=_mock_load_neuron)
    # is subset so that if new morpho are added to SWC_PATH, the test does not break
    nt.assert_true({f.stem
                    for f in FILES}.issubset({nrn.name
                                              for nrn in nrns}))

    # Path path to a directory
    nrns = utils.load_neurons(SWC_PATH, neuron_loader=_mock_load_neuron)
    # is subset so that if new morpho are added to SWC_PATH, the test does not break
    nt.assert_true({f.stem
                    for f in FILES}.issubset({nrn.name
                                              for nrn in nrns}))

    nt.assert_raises(SomaError, utils.load_neurons, NO_SOMA_FILE)
예제 #13
0
def test_load_neurons():
    nrns = utils.load_neurons(FILES, neuron_loader=_mock_load_neuron)
    for i, nrn in enumerate(nrns):
        nt.assert_equal(nrn.name, _get_name(FILES[i]))
예제 #14
0
def test_load_neurons():
    nrns = utils.load_neurons(FILES, neuron_loader=_mock_load_neuron)
    for i, nrn in enumerate(nrns):
        nt.assert_equal(nrn.name, _get_name(FILES[i]))
예제 #15
0
파일: test_utils.py 프로젝트: MFSY/NeuroM
def test_load_neurons():
    nrns = utils.load_neurons(FILES, neuron_loader=_mock_load_neuron)
    for i, nrn in enumerate(nrns):
        nt.assert_equal(nrn.name, _get_name(FILES[i]))
    nt.assert_raises(SomaError, utils.load_neurons, NO_SOMA_FILE)
예제 #16
0
def test_ignore_exceptions():
    with pytest.raises(NeuroMError):
        utils.load_neurons(MISSING_PARENTS_FILE, )
    pop = utils.load_neurons((MISSING_PARENTS_FILE, ),
                             ignored_exceptions=(RawDataError, ))
    assert len(pop) == 0
예제 #17
0
def test_ignore_exceptions():
    nt.assert_raises(RawDataError, utils.load_neurons,
                     (MISSING_PARENTS_FILE, ))
    pop = utils.load_neurons((MISSING_PARENTS_FILE, ),
                             ignored_exceptions=[RawDataError])
    nt.eq_(len(pop), 0)