def get_integrator(integrator):
    """Return the scipy.integrator indicated by an index, name, or integrator_function

    >> get_integrator(0)
    """
    integrator_types = set(['trapz', 'cumtrapz', 'simps', 'romb'])
    integrator_funcs = [integrate.trapz, integrate.cumtrapz, integrate.simps, integrate.romb]

    if isinstance(integrator, int) and 0 <= integrator < len(integrator_types):
        integrator = integrator_types[integrator]
    if isinstance(integrator, basestring) and integrator in integrator_types:
        return getattr(integrate, integrator)
    elif integrator in integrator_funcs:
        return integrator
    else:
        print('Unsupported integration rule: {0}'.format(integrator))
        print('Expecting one of these sample-based integration rules: %s' % (str(list(integrator_types))))
        raise AttributeError
    return integrator
def get_integrator ( integrator ) : integrator_types = set ( [ 'trapz' , 'cumtrapz' , 'simps' , 'romb' ] ) integrator_funcs = [ integrate . trapz , integrate . cumtrapz , integrate . simps , integrate . romb ] if isinstance ( integrator , int ) and 0 <= integrator < len ( integrator_types ) : integrator = integrator_types [ integrator ] if isinstance ( integrator , basestring ) and integrator in integrator_types : return getattr ( integrate , integrator ) elif integrator in integrator_funcs : return integrator else : print ( 'Unsupported integration rule: {0}' . format ( integrator ) ) print ( 'Expecting one of these sample-based integration rules: %s' % ( str ( list ( integrator_types ) ) ) ) raise AttributeError return integrator
Return the scipy.integrator indicated by an index, name, or integrator_function

    >> get_integrator(0)