Python division

You’re using Python 2.x, where integer divisions will truncate instead of becoming a floating point number. You should make one of them a float: or from __future__ import division, which the forces / to adopt Python 3.x’s behavior that always returns a float.

numpy max vs amax vs maximum

np.max is just an alias for np.amax. This function only works on a single input array and finds the value of maximum element in that entire array (returning a scalar). Alternatively, it takes an axis argument and will find the maximum value along an axis of the input array (returning a new array). The default behaviour of np.maximum is to take two arrays and compute … Read more

Python Math – TypeError: ‘NoneType’ object is not subscriptable

This should be The .sort() method is in-place, and returns None. If you want something not in-place, which returns a value, you could use Aside #1: please don’t call your lists list. That clobbers the builtin list type. Aside #2: I’m not sure what this line is meant to do: is it simply ? In other words, I … Read more

Converting 3D polar coordinates to cartesian coordinates

Your formula is correct for all angles. But the names that you’ve given the angles are probably not quite right. What you’ve called “horizontal angle” is the inclination angle – the angle between the vector and the z-axis. So if “horizontal angle” is 0, then the point lies on the z-axis, which means that it … Read more