Repository: rigetticomputing/pyquil (python)

Issue:
Unequal length PauliSums raise a warning rather than warn
If two `PauliTerms` are compared with unequal lengths they raise a warning which breaks the control flow- it should just warn the user.

Pull request description:
raise -> warn in PauliTerm
Fixes #114 

Patch:
diff --git a/pyquil/paulis.py b/pyquil/paulis.py
index 0f79f9c..f94a4e8 100644
--- a/pyquil/paulis.py
+++ b/pyquil/paulis.py
@@ -27,6 +27,7 @@ from .gates import H, RZ, RX, CNOT, X, PHASE
 from . import quilbase as pqb
 from numbers import Number
 from collections import Sequence
+import warnings
 from six import integer_types
 from six.moves import range
 
@@ -346,7 +347,7 @@ class PauliSum(object):
         elif isinstance(other, PauliTerm):
             return self == PauliSum(other)
         elif len(self.terms) != len(other.terms):
-            raise UnequalLengthWarning("These PauliSums have a different number of terms.")
+            warnings.warn(UnequalLengthWarning("These PauliSums have a different number of terms."))
             return False
         return all([term == other.terms[i] for i, term in enumerate(self.terms)])
 


Test patch:
diff --git a/pyquil/tests/test_paulis.py b/pyquil/tests/test_paulis.py
index feea509..8e8c443 100644
--- a/pyquil/tests/test_paulis.py
+++ b/pyquil/tests/test_paulis.py
@@ -538,12 +538,12 @@ def test_term_with_coeff():
 def test_sum_equality():
     pauli_sum = sY(0) - sX(0)
     assert pauli_sum != 2 * pauli_sum
-    with pytest.raises(UnequalLengthWarning):
+    with pytest.warns(UnequalLengthWarning):
         assert pauli_sum != pauli_sum + sZ(0)
-    with pytest.raises(UnequalLengthWarning):
+    with pytest.warns(UnequalLengthWarning):
         assert pauli_sum + sZ(0) != pauli_sum
     assert pauli_sum != sY(1) - sX(1)
     assert pauli_sum == -1.0 * sX(0) + sY(0)
     assert pauli_sum == pauli_sum * 1.0
     with pytest.raises(TypeError):
-        assert pauli_sum != 0
\ No newline at end of file
+        assert pauli_sum != 0