From 3578884c42e7bcc1b18eb8f0f25a3fb220cec839 Mon Sep 17 00:00:00 2001 From: Schmeitzke Date: Fri, 31 Jan 2025 14:20:55 +0100 Subject: [PATCH] Bug fix for absent method in sympy --- reasoning_gym/geometry/advanced_geometry.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/reasoning_gym/geometry/advanced_geometry.py b/reasoning_gym/geometry/advanced_geometry.py index ca098b55..3beae559 100644 --- a/reasoning_gym/geometry/advanced_geometry.py +++ b/reasoning_gym/geometry/advanced_geometry.py @@ -118,30 +118,24 @@ class AdvancedGeometryDataset(ProceduralDataset): """ Build a question about finding the orthocenter of triangle ABC. """ - # Create line segments for the sides - AB = Segment(A, B) - BC = Segment(B, C) - CA = Segment(C, A) + # Convert segments to lines + BC_line = sympy.Line(B, C) + CA_line = sympy.Line(C, A) - # Calculate altitudes - # Get perpendicular lines from each vertex to the opposite side - alt_A = A.perpendicular_line(BC) - alt_B = B.perpendicular_line(CA) - alt_C = C.perpendicular_line(AB) + # Calculate altitudes by creating lines perpendicular from each vertex + alt_A = BC_line.perpendicular_line(A) + alt_B = CA_line.perpendicular_line(B) - # Find orthocenter (intersection of any two altitudes) + # Find orthocenter (intersection of any two altitudes, e.g. alt_A and alt_B) ortho = alt_A.intersection(alt_B)[0] - # Format coordinates x_ortho_approx = float(ortho.x.evalf()) y_ortho_approx = float(ortho.y.evalf()) - # Choose a prompt question_template = rng.choice(self._prompt_templates["orthocenter"]) question = question_template.format( A=(A.x, A.y), B=(B.x, B.y), C=(C.x, C.y) ) - # Round to e.g. 3 decimals or keep a string representation answer_str = f"({x_ortho_approx:.3f}, {y_ortho_approx:.3f})" metadata = { @@ -153,6 +147,7 @@ class AdvancedGeometryDataset(ProceduralDataset): } return question, answer_str, metadata + def _build_incircle_radius_task(self, rng: random.Random, A: Point, B: Point, C: Point): """ Build a question about finding the incircle radius of triangle ABC.