Changeset 724

Show
Ignore:
Timestamp:
08/09/10 23:28:14 (1 year ago)
Author:
dmitrey
Message:

some changes for FD and DA + 2 FD testcases

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • PythonPackages/DerApproximator/DerApproximator.py

    r564 r724  
    1313    """ 
    1414    Usage: get_d1(fun, x, diffInt=1.5e-8, pointVal = None, args=(), stencil = 3, varForDifferentiation = None, exactShape = False) 
    15     fun: R^n -> R^m, x0 from R^n: function and point where derivatives should be obtained  
     15    fun: R^n -> R^m, x: Python list (not tuple!) or numpy array from R^n: function and point where derivatives should be obtained  
    1616    diffInt - step for stencil 
    1717    pointVal - fun(x) if known (it is used from OpenOpt and FuncDesigner) 
     
    2828    if atleast_1d(diffInt).size > 1: assert type(vars) == ndarray, 'not implemented yet' 
    2929     
    30     if type(vars) not in [list, tuple] or isscalar(vars[0]): 
     30    if type(vars) == tuple: 
     31        Vars = [asfarray(var) for var in vars] 
     32    elif type(vars) not in [list, tuple] or isscalar(vars[0]): 
    3133        Vars = [vars, ] 
    3234    else:  
     
    5658        else: 
    5759            S = asfarray([Args[i]]) 
    58              
     60        S = atleast_1d(S) 
    5961        agregate_counter = 0 
    6062        assert asarray(Args[i]).ndim <= 1, 'derivatives for more than single dimension variables are not implemented yet' 
     
    7375        for j in xrange(S.size): 
    7476            di = float(asscalar(diff_int[j])) 
    75             tmp = S[j] 
     77            tmp = S[j] #if S.ndim > 0 else asscalar(S) 
    7678            di = diff_int[j] 
    7779            di2 = di / 2.0 
     
    113115         
    114116        r.append(asfarray(d1)) 
    115     if varForDifferentiation is not None or isscalar(vars) or (type(vars) in [list, tuple, ndarray] and isscalar(vars[0])): r = d1 
     117 
     118    if varForDifferentiation is not None or isscalar(vars): r = d1 
    116119    else: r = tuple(r) 
    117120    return r 
  • PythonPackages/FuncDesigner/FuncDesigner/ooFun.py

    r723 r724  
    914914         
    915915        #assert all([elem.ndim > 1 for elem in derivativeSelf]) 
     916       # assert len(derivativeSelf[0])!=16 
     917        #assert (type(derivativeSelf[0]) in (int, float)) or derivativeSelf[0][0]>480.00006752 or derivativeSelf[0][0]<480.00006750 
    916918        return derivativeSelf 
    917919 
  • PythonPackages/FuncDesigner/FuncDesigner/ooPoint.py

    r723 r724  
    1414    def __init__(self, *args, **kwargs): 
    1515        if args: 
    16             items = [(key, asfarray(val) if type(val) != ndarray else val) for key, val in args[0]] 
     16            items = [(key, asfarray(val) if type(val) != ndarray else val) for key, val in args[0]] if not isinstance(args[0], dict) else args[0].items() 
    1717        elif kwargs: 
    1818            items = [(key, asfarray(val) if type(val) != ndarray else val) for key, val in kwargs.items()] 
  • PythonPackages/FuncDesigner/FuncDesigner/ooVar.py

    r723 r724  
    77class oovar(oofun): 
    88    is_oovar = True 
    9     shape = nan 
    10     fixed = False 
    11     initialized = False 
     9    #shape = nan 
     10    #fixed = False 
     11    #initialized = False 
    1212    is_linear = True 
    1313    _unnamedVarNumber = 1#static variable for oovar class