Non-numpy functions like math.abs()
or math.log10()
don't play nicely with numpy arrays. Just replace the line raising an error with:
m = np.log10(np.abs(x))
Apart from that the np.polyfit()
call will not work because it is missing a parameter (and you are not assigning the result for further use anyway).