python - PyCharm Type error Message -
i'm newbie trying out ml/dbn in python (3.4) under pycharm (comm.ed 4.5). following definition
def make_thetas(xmin,xmax,n):     xs = np.linespace(xmin,xmax,n)     widths = (xs[1:] - xs[:-1])/2.0     thetas = xs[:-1] + widths     return thetas throws error "class 'tuple' not define 'sub', '-' operator cannot used on instance" on - operator on third line (widths = ....) ideas on how code running under pycharm - works alright in interactive python window.
 thx.
to all,
 after g'g lot have found workaround seems work within pycharm. workaround because (even python newbie) expected python not need explicit typecasting, not when using datatypes imported lib such numpy.  
    def make_thetas(xmin,xmax,n):     xs = np.array(np.linspace(xmin,xmax,n))     widths = (xs[1:] - xs[:-1])/2.0     thetas = xs[:-1]+ widths     return thetas using docstrings type-hinting such below did not work
def make_thetas(xmin,xmax,n):     """     @type xs: np.multiarray.ndarray     """     xs = np.linspace(xmin,xmax,n)     widths = (xs[1:] - xs[:-1])/2.0  # error msg 1     thetas = xs[:-1]+ widths         # error msg 2  followup of error 1     return thetas error msg 1: '-' class 'tuple' not define 'sub', '-' operator cannot used on instances error msg 2: 'widths' expected type 'tuple', got 'float' instead
 maybe there other possibilities of type-hinting work...
 thx
Comments
Post a Comment