Repository: brightway-lca/brightway2-analyzer

Issue:
Invalid sorting for Contribution results when top contributors are negative (Absolute values)
When getting the contribution results, if the top contributions have a negative value BW analyzer ignore these. The issue is in the limit calculation, as it doesnt take negatives into account. 

I have tried the following fix and it works:
[contribution.py > ContributionAnalysis > sort_array() method > line 44](https://github.com/brightway-lca/brightway2-analyzer/blob/master/bw2analyzer/contribution.py#L44)
Currently: `limit = (data >= (total * limit)).sum()`
Fix: `limit = (np.abs(data) >= (total * limit)).sum()`

Does this issue have any horizontal impacts? (Other places where negatives may not have been considered?)

Discussion:

Patch:
diff --git a/bw2analyzer/contribution.py b/bw2analyzer/contribution.py
index 91b2ced..37a1503 100644
--- a/bw2analyzer/contribution.py
+++ b/bw2analyzer/contribution.py
@@ -41,7 +41,7 @@ class ContributionAnalysis:
         if limit_type == "percent":
             if not 0 < limit <= 1:
                 raise ValueError("Percentage limits > 0 and <= 1.")
-            limit = (data >= (total * limit)).sum()
+            limit = (np.abs(data) >= (total * limit)).sum()
 
         results = np.hstack(
             (data.reshape((-1, 1)), np.arange(data.shape[0]).reshape((-1, 1)))


Test patch:
diff --git a/tests/contribution.py b/tests/contribution.py
index 3b168d4..fca270e 100644
--- a/tests/contribution.py
+++ b/tests/contribution.py
@@ -35,6 +35,21 @@ class ContributionTestCase(unittest.TestCase):
                 answer, ca.sort_array(test_data, limit=0.3, limit_type="percent")
             )
         )
+        
+    def test_sort_array_percentage_negative(self):
+        test_data = np.array((1.0, 2.0, -4.0, 3.0))
+        answer = np.array(
+            (
+                (-4, 2),
+                (3, 3),
+            )
+        )
+        ca = CA()
+        self.assertTrue(
+            np.allclose(
+                answer, ca.sort_array(test_data, limit=0.3, limit_type="percent")
+            )
+        )
 
     def test_sort_array_errors(self):
         ca = CA()