Beispiel #1
0
 def __init__(self, name=None, closure=None, mxpointer=None):
     if mxpointer is None:
         if name and closure:
             raise ValueError, "Specify name OR closure"
         elif name:
             mxpointer = mx.create_function_handle(name=name)
         elif closure:
             mxpointer = mx.create_function_handle(closure=closure)
         else:
             raise ValueError, ("Must specify a function name or "
                                "MATLAB closure literal")
     super(function_handle, self).__init__(mxpointer=mxpointer)
Beispiel #2
0
def test_bare_func_notboth():
    '''
    Function handle may not be instantiated with both
    a name and a closure string.
    '''
    return mx.create_function_handle(name="sin",
                                     closure="@(x)x+1",
                                     wrap=False)
Beispiel #3
0
def test_bare_func_notafunc():
    '''
    Closure must evaluate to a function handle
    '''
    return mx.create_function_handle(closure="42", wrap=False)
Beispiel #4
0
def test_bare_func_badsyntax():
    '''
    Closure must be valid MATLAB syntax.
    '''
    return mx.create_function_handle(closure="@(x)$$$", wrap=False)
Beispiel #5
0
def test_bare_closure():
    '''
    Test creation of bare anonymous function handle
    '''
    return mx.create_function_handle(closure="@(x)x+1", wrap=False)
Beispiel #6
0
def test_bare_funchandle():
    '''
    Test creation of bare function handle
    '''
    return mx.create_function_handle(name="sin", wrap=False)