Skip to content Skip to sidebar Skip to footer

Pycharm Type Error Message

I'm a newbie trying out ML/DBN in Python (3.4) under PyCharm (Comm.Ed 4.5). The following definition def make_thetas(xmin,xmax,n): xs = np.linespace(xmin,xmax,n) widths = (

Solution 1:

To All, After G'g a lot I have found a workaround that seems to work within PyCharm. I say workaround because (even as a Python newbie) I expected that Python does not need explicit typecasting, especially not when using datatypes imported from a lib such as Numpy.

defmake_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 for type-hinting such as below did not work

defmake_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 1return thetas

Error Msg 1: '-' Class 'tuple' does not define 'sub', so the '-' operator cannot be used on its instances Error Msg 2: 'widths' Expected type 'tuple', got 'float' instead Maybe there are other possibilities of type-hinting that would work... Thx

Post a Comment for "Pycharm Type Error Message"