This page lists some frequent errors and what likely causes them
This means that the code contains a syntax error. Because of this python cannot understand you code and is not in a good position to help you fix the problem. It will show you the position where it gets too confused to continue, which might be a bit further than where the actual error is, in particular when parenthesis and brackets are not balancing.
This normally happens when you forget the multiplication sign between an integer and a factor in brackets. For example
3(x-y)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-112ceb8d6610> in <module>()
----> 1 3(x-y)
TypeError: 'int' object is not callable
This normally happens when you forget the multiplication sign between a floating point number and a factor in brackets. For example
math.sqrt(6)(1+x)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-11-fadeefc6473a> in <module>()
----> 1 math.sqrt(6)(1+x)
TypeError: 'float' object is not callable
the sqrt call returns a floating point number and python then tries to evaluate
2.449489742783178(1+x)
and that is where the error occurs. To fix it just use a *
between the float and the parenthesis
This error can happen when you use a numpy array in the range
function
try to index into a numpy array with a bad index (ie not an integer or a list of integers)
xs = numpy.zeros(100)
indices = numpy.arange(1,10,2)
range(indices)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-16-4ccf4c054b86> in <module>()
1 indices = numpy.arange(1,10,2)
2
----> 3 range(indices)
TypeError: only integer scalar arrays can be converted to a scalar index