When running the following code:
my_pwlf = pwlf.PiecewiseLinFit(x, y)res = my_pwlf.fit(4)xHat = np.linspace(min(x), max(x), num=10000)yHat = my_pwlf.predict(xHat)
I get the error:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pwlf/pwlf.py", line 55, in __init__ self.x_data = x[order_arg]TypeError: only integer scalar arrays can be converted to a scalar index
I have managed to work out what was causing this error but I will post this anyway in case others run into the same issue. The x and y array fed into the PiecewiseLinFit function has to be an np.array type.
To fix, I just changed the code to:
my_pwlf = pwlf.PiecewiseLinFit(np.array(x), np.array(y))
I just uploaded 0.2.1 to pypi, which now intelligently checks whether x, y, or breaks are ndarray type. If not, it will convert them. So this shouldn't be an issue for anyone else.
Hi there,
When running the following code:
my_pwlf = pwlf.PiecewiseLinFit(x, y)
res = my_pwlf.fit(4)
xHat = np.linspace(min(x), max(x), num=10000)
yHat = my_pwlf.predict(xHat)
I get the error:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pwlf/pwlf.py", line 55, in __init__ self.x_data = x[order_arg]
TypeError: only integer scalar arrays can be converted to a scalar index
I have managed to work out what was causing this error but I will post this anyway in case others run into the same issue. The x and y array fed into the PiecewiseLinFit function has to be an np.array type.
To fix, I just changed the code to:
my_pwlf = pwlf.PiecewiseLinFit(np.array(x), np.array(y))