Example #1
0
def reinit_devices():
    '''
    Reinitialize all devices and call `Device.activate` again on the current
    devise. Used as a "teardown" function in testing, if users want to reset
    their device (e.g. for multiple standalone runs in a single script),
    calling ``device.reinit()`` should normally be sufficient.
    '''
    from brian2 import restore_initial_state  # avoids circular import

    for device in all_devices.itervalues():
        device.reinit()

    if active_device is not None:
        # Reactivate the current device
        reset_device(active_device)

    restore_initial_state()
Example #2
0
def reinit_devices():
    '''
    Reinitialize all devices and call `Device.activate` again on the current
    devise. Used as a "teardown" function in testing, if users want to reset
    their device (e.g. for multiple standalone runs in a single script),
    calling ``device.reinit()`` should normally be sufficient.
    '''
    from brian2 import restore_initial_state  # avoids circular import

    for device in all_devices.itervalues():
        device.reinit()

    if active_device is not None:
        # Reactivate the current device
        reset_device(active_device)

    restore_initial_state()
Example #3
0
def reinit_devices():
    '''
    Reinitialize all devices, call `Device.activate` again on the current
    device and reset the preferences. Used as a "teardown" function in testing,
    if users want to reset their device (e.g. for multiple standalone runs in a
    single script), calling ``device.reinit()`` followed by
    ``device.activate()`` should normally be sufficient.

    Notes
    -----
    This also resets the `defaultclock`, i.e. a non-standard ``dt`` has to be
    set again.
    '''
    from brian2 import restore_initial_state  # avoids circular import

    for device in all_devices.values():
        device.reinit()

    if active_device is not None:
        # Reactivate the current device
        reset_device(active_device)

    restore_initial_state()
Example #4
0
def reinit_devices():
    '''
    Reinitialize all devices, call `Device.activate` again on the current
    device and reset the preferences. Used as a "teardown" function in testing,
    if users want to reset their device (e.g. for multiple standalone runs in a
    single script), calling ``device.reinit()`` followed by
    ``device.activate()`` should normally be sufficient.

    Notes
    -----
    This also resets the `defaultclock`, i.e. a non-standard ``dt`` has to be
    set again.
    '''
    from brian2 import restore_initial_state  # avoids circular import

    for device in all_devices.itervalues():
        device.reinit()

    if active_device is not None:
        # Reactivate the current device
        reset_device(active_device)

    restore_initial_state()
Example #5
0
def restore_device():
    from brian2 import restore_initial_state  # avoids circular import

    for device in all_devices.itervalues():
        device.reinit()
    restore_initial_state()
Example #6
0
    assert 'name' in dir(gp.main)

    # Check that the fiddling with getattr and setattr did not destroy the
    # access to standard attributes
    assert len(gp.prefs)
    assert gp.main._basename == 'main'


@pytest.mark.codegen_independent
def test_str_repr():
    # Just test whether str and repr do not throw an error and return something
    gp = BrianGlobalPreferences()
    gp.register_preferences('main',
                            'main category',
                            name=BrianPreference(True, 'some preference'))

    assert len(str(gp))
    assert len(repr(gp))
    assert len(str(gp.main))
    assert len(repr(gp.main))


if __name__ == '__main__':
    for t in [
            test_defaultvalidator, test_brianpreference,
            test_brianglobalpreferences, test_preference_name_checking,
            test_preference_name_access
    ]:
        t()
        restore_initial_state()
Example #7
0
    assert 'name' in dir(gp.main)

    # Check that the fiddling with getattr and setattr did not destroy the
    # access to standard attributes
    assert len(gp.prefs)
    assert gp.main._basename == 'main'


@with_setup(teardown=restore_initial_state)
def test_str_repr():
    # Just test whether str and repr do not throw an error and return something
    gp = BrianGlobalPreferences()    
    gp.register_preferences('main', 'main category',
                            name=BrianPreference(True, 'some preference'))
    
    assert len(str(gp))
    assert len(repr(gp))
    assert len(str(gp.main))
    assert len(repr(gp.main))

   
if __name__=='__main__':
    for t in [test_defaultvalidator,
              test_brianpreference,
              test_brianglobalpreferences,
              test_preference_name_checking,
              test_preference_name_access
              ]:
        t()
        restore_initial_state()
Example #8
0
def restore_device():
    from brian2 import restore_initial_state  # avoids circular import

    for device in all_devices.itervalues():
        device.reinit()
    restore_initial_state()