nebius/SWE-bench-extra huggingface dataset:
Repository: lapix-ufsc/lapixdl

Issue:
Division by zero at calculate_bbox_iou
I can't reproduce the error with tests, but, some moments at https://github.com/lapix-ufsc/lapixdl/blob/ee3faf20b2beab7bbb794328f724b7b8044ac1b1/lapixdl/evaluation/evaluate.py#L211

The union it's equals zero and raise the error. To solve just need:
```python
if union_area == 0:
    return 0
```

I don't PR this because I can't reproduce this when i try 

Comments:

Patch:
diff --git a/lapixdl/formats/annotation.py b/lapixdl/formats/annotation.py
index 919f70a..a0e2eb1 100644
--- a/lapixdl/formats/annotation.py
+++ b/lapixdl/formats/annotation.py
@@ -26,6 +26,16 @@ class BBox:
     cls: int
     score: float | None = None
 
+    def __post_init__(self):
+        if self.upper_left_x < 0 or self.upper_left_y < 0:
+            raise ValueError(f'The upper left (x, y) should be positive values. Got ({self.upper_left_x}, {self.upper_left_y})')
+
+        if self.width <= 0:
+            raise ValueError(f'The width should be bigger than zero. Got {self.width}')
+
+        if self.height <= 0:
+            raise ValueError(f'The height should be bigger than zero. Got {self.height}')
+
     @property
     def upper_left_point(self) -> tuple[int, int]:
         """Tuple[int, int]: (X,Y) of the upper left point of the Bounding Box."""


Test patch:
diff --git a/tests/formats/annotation_test.py b/tests/formats/annotation_test.py
index aa25429..202ba3a 100644
--- a/tests/formats/annotation_test.py
+++ b/tests/formats/annotation_test.py
@@ -28,6 +28,20 @@ def test_bbox():
     assert bbox.slice_y == slice(0, 14)
 
 
+def test_invalid_bbox():
+    with pytest.raises(ValueError):
+        BBox(0, -1, 1, 1, 0)
+
+    with pytest.raises(ValueError):
+        BBox(-1, 0, 1, 1, 0)
+
+    with pytest.raises(ValueError):
+        BBox(0, 0, 0, 1, 0)
+
+    with pytest.raises(ValueError):
+        BBox(0, 0, 1, 0, 0)
+
+
 def test_bbox_intersection_and_union_area_with():
     bbox_A = BBox(0, 0, 10, 15, 0)
     bbox_B = BBox(5, 5, 20, 25, 0)
Repository: lark-parser/lark

Issue:
Transformer_NonRecursive fails on Discard
**Describe the bug**

As documented, `Transformer` catches any `Discard` exceptions and removes the node from the tree. 

I expected `Transformer_NonRecursive` to behave the same way - instead it lets the exception propagate eventually crashing the program.

**To Reproduce**

```
tree = Tree('start', [
	Tree('add', [Token('N', '1'), Token('N', '2'), Token('token_ignore', '4')]),
	Tree('add', [Token('N', '3'), Token('N', '4')]),
	Tree('ignore_tree', [Token('DO', 'NOT PANIC')]),
])

for base in (Transformer, Transformer_InPlace, Transformer_NonRecursive, Transformer_InPlaceRecursive):
	class T(base):
		def add(self, children):
			return sum(children)

		def N(self, token):
			return int(token)

		def ignore_tree(self, children):
			raise Discard

		def token_ignore(self, token):
                    raise Discard
```

Comments:

Patch:
diff --git a/lark/visitors.py b/lark/visitors.py
index 03dc740..ae7930c 100644
--- a/lark/visitors.py
+++ b/lark/visitors.py
@@ -277,9 +277,15 @@ class Transformer_NonRecursive(Transformer):
                     del stack[-size:]
                 else:
                     args = []
-                stack.append(self._call_userfunc(x, args))
+                try:
+                    stack.append(self._call_userfunc(x, args))
+                except Discard:
+                    pass
             elif self.__visit_tokens__ and isinstance(x, Token):
-                stack.append(self._call_userfunc_token(x))
+                try:
+                    stack.append(self._call_userfunc_token(x))
+                except Discard:
+                    pass
             else:
                 stack.append(x)
 


Test patch:
diff --git a/tests/test_trees.py b/tests/test_trees.py
index 36be73f..7d2cc7f 100644
--- a/tests/test_trees.py
+++ b/tests/test_trees.py
@@ -375,7 +375,11 @@ class TestTrees(TestCase):
         self.assertEqual(x, t2)
 
     def test_transformer_variants(self):
-        tree = Tree('start', [Tree('add', [Token('N', '1'), Token('N', '2')]), Tree('add', [Token('N', '3'), Token('N', '4')])])
+        tree = Tree('start', [
+            Tree('add', [Token('N', '1'), Token('N', '2'), Token('IGNORE_TOKEN', '4')]),
+            Tree('add', [Token('N', '3'), Token('N', '4')]),
+            Tree('ignore_tree', [Token('DO', 'NOT PANIC')]),
+            ])
         for base in (Transformer, Transformer_InPlace, Transformer_NonRecursive, Transformer_InPlaceRecursive):
             class T(base):
                 def add(self, children):
@@ -384,6 +388,12 @@ class TestTrees(TestCase):
                 def N(self, token):
                     return int(token)
 
+                def ignore_tree(self, children):
+                    raise Discard
+
+                def IGNORE_TOKEN(self, token):
+                    raise Discard
+
             copied = copy.deepcopy(tree)
             result = T().transform(copied)
             self.assertEqual(result, Tree('start', [3, 7]))