Corrected numerical comparison to ==.

The comparisons previously used 'is' which is used to check identities.
== can work for small numbers because their values are cached. See:
http://stackoverflow.com/questions/4473673/python-comparing-long-integer-values-with-and-is