[SciPy-dev] openopt example mmp_1.py

Alan G Isaac aisaac@american....
Sun Feb 3 07:35:31 CST 2008


On Sun, 03 Feb 2008, dmitrey apparently wrote:
> p.err('incorrect func index type!')

Change this to:
p.err('%s is an unknown func index type!'%type(ind))

Stylistically, I'd prefer something with less type checking.  
Perhaps something along the lines of the following.  (Untested.)

Cheers,
Alan Isaac


def getCorrectInd(p, ind):
    if type(ind) in [NoneType, list, tuple]:
        result = ind
    else:
        try:
            result = atleast_1d(ind).tolist()
        except:
            raise ValueError('%s is an unknown func index type!'%type(ind))
    return result




More information about the Scipy-dev mailing list