Repository: hgrecco/pint

Issue:
Comparing Quantity to list yields unhandled IndexError: list index out of range
To replicate run

```
import pint
ureg = pint.UnitRegistry()
ureg('g') == []
```
results in
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alexbhandari-young/miniconda3/envs/django/lib/python3.7/site-packages/pint/quantity.py", line 73, in wrapped
    elif isinstance(other, list) and isinstance(other[0], type(self)):
IndexError: list index out of range

```

This is the case for comparing any Quantity with a list. Seems to be caused by the other[0] access in the check_implemented method used by Quantity.

Discussion:

Patch:
diff --git a/pint/quantity.py b/pint/quantity.py
index a5b40d7..3373552 100644
--- a/pint/quantity.py
+++ b/pint/quantity.py
@@ -71,7 +71,7 @@ def check_implemented(f):
             return NotImplemented
         # pandas often gets to arrays of quantities [ Q_(1,"m"), Q_(2,"m")]
         # and expects Quantity * array[Quantity] should return NotImplemented
-        elif isinstance(other, list) and isinstance(other[0], type(self)):
+        elif isinstance(other, list) and other and isinstance(other[0], type(self)):
             return NotImplemented
         result = f(self, *args, **kwargs)
         return result


Test patch:
diff --git a/pint/testsuite/test_issues.py b/pint/testsuite/test_issues.py
index efbaec4..df97228 100644
--- a/pint/testsuite/test_issues.py
+++ b/pint/testsuite/test_issues.py
@@ -653,6 +653,10 @@ class TestIssuesNP(QuantityTestCase):
         self.assertEqual(velocity.check('[length] / [time]'), True)
         self.assertEqual(velocity.check('1 / [time] * [length]'), True)
 
+    def test_issue783(self):
+        ureg = UnitRegistry()
+        assert not ureg('g') == []
+
     def test_issue(self):
         import math
         try: