@@ -2455,19 +2455,22 @@ def test_draw(self, triangle_coords):
24552455
24562456 def test_constraint_function_triangle (self , triangle_coords ):
24572457 """Test the constraint_function with a triangle."""
2458- triangle = Polygon (
2458+ triangle_in = Polygon (
24592459 xy_coords = triangle_coords ,
24602460 loc = "in" ,
24612461 data = pd .DataFrame (),
24622462 X_axis = "x" ,
24632463 Y_axis = "y" ,
24642464 Field = "f" ,
24652465 )
2466- assert triangle .constraint_function ([2 , 1 ]) is False
2467- assert triangle .constraint_function ([- 1 , 0 ]) is True
2468- assert triangle .constraint_function ([5 , 0 ]) is True
2469- assert triangle .constraint_function ([2 , 5 ]) is True
2470- assert triangle .constraint_function ([0 , 0 ]) is True
2466+ assert triangle_in .constraint_function ([2 , 1 ]) is False
2467+ assert triangle_in .constraint_function ([1 , 1 ]) is False
2468+ assert triangle_in .constraint_function ([3 , 1 ]) is False
2469+ assert triangle_in .constraint_function ([2 , 2 ]) is False
2470+ assert triangle_in .constraint_function ([- 1 , 0 ]) is True
2471+ assert triangle_in .constraint_function ([5 , 0 ]) is True
2472+ assert triangle_in .constraint_function ([2 , 5 ]) is True
2473+ assert triangle_in .constraint_function ([0 , - 1 ]) is True
24712474 triangle_out = Polygon (
24722475 xy_coords = triangle_coords ,
24732476 loc = "out" ,
@@ -2477,7 +2480,11 @@ def test_constraint_function_triangle(self, triangle_coords):
24772480 Field = "f" ,
24782481 )
24792482 assert triangle_out .constraint_function ([2 , 1 ]) is True
2483+ assert triangle_out .constraint_function ([1 , 1 ]) is True
2484+ assert triangle_out .constraint_function ([3 , 1 ]) is True
24802485 assert triangle_out .constraint_function ([- 1 , 0 ]) is False
2486+ assert triangle_out .constraint_function ([5 , 0 ]) is False
2487+ assert triangle_out .constraint_function ([2 , 5 ]) is False
24812488
24822489 def test_constraint_function_square (self , square_coords ):
24832490 """Test the constraint_function with a square."""
@@ -2496,7 +2503,23 @@ def test_constraint_function_square(self, square_coords):
24962503 assert square .constraint_function ([5 , 2 ]) is True
24972504 assert square .constraint_function ([2 , - 1 ]) is True
24982505 assert square .constraint_function ([2 , 5 ]) is True
2499- assert square .constraint_function ([0 , 0 ]) is True
2506+ assert square .constraint_function ([0 , 0 ]) is False
2507+ square_out = Polygon (
2508+ xy_coords = square_coords ,
2509+ loc = "out" ,
2510+ data = pd .DataFrame (),
2511+ X_axis = "x" ,
2512+ Y_axis = "y" ,
2513+ Field = "f" ,
2514+ )
2515+ assert square_out .constraint_function ([2 , 2 ]) is True
2516+ assert square_out .constraint_function ([1 , 1 ]) is True
2517+ assert square_out .constraint_function ([3 , 3 ]) is True
2518+ assert square_out .constraint_function ([- 1 , 2 ]) is False
2519+ assert square_out .constraint_function ([5 , 2 ]) is False
2520+ assert square_out .constraint_function ([2 , - 1 ]) is False
2521+ assert square_out .constraint_function ([2 , 5 ]) is False
2522+ assert square_out .constraint_function ([0 , 0 ]) is True
25002523
25012524 def test_constraint_function_concave_polygon (self , pentagon_coords ):
25022525 """Test the constraint_function with a concave polygon."""
@@ -2511,11 +2534,30 @@ def test_constraint_function_concave_polygon(self, pentagon_coords):
25112534 assert pentagon .constraint_function ([2 , 2 ]) is False
25122535 assert pentagon .constraint_function ([1 , 1 ]) is False
25132536 assert pentagon .constraint_function ([3 , 3 ]) is False
2537+
25142538 assert pentagon .constraint_function ([- 2 , 2 ]) is True
25152539 assert pentagon .constraint_function ([6 , 2 ]) is True
25162540 assert pentagon .constraint_function ([2 , - 1 ]) is True
25172541 assert pentagon .constraint_function ([2 , 6 ]) is True
2518- assert pentagon .constraint_function ([0 , 0 ]) is True
2542+ result_00 = pentagon .constraint_function ([0 , 0 ])
2543+ print (f"Point [0, 0] returns: { result_00 } " )
2544+ assert pentagon .constraint_function ([0 , 0 ]) is False
2545+ pentagon_out = Polygon (
2546+ xy_coords = pentagon_coords ,
2547+ loc = "out" ,
2548+ data = pd .DataFrame (),
2549+ X_axis = "x" ,
2550+ Y_axis = "y" ,
2551+ Field = "f" ,
2552+ )
2553+ assert pentagon_out .constraint_function ([2 , 2 ]) is True
2554+ assert pentagon_out .constraint_function ([1 , 1 ]) is True
2555+ assert pentagon_out .constraint_function ([3 , 3 ]) is True
2556+ assert pentagon_out .constraint_function ([- 2 , 2 ]) is False
2557+ assert pentagon_out .constraint_function ([6 , 2 ]) is False
2558+ assert pentagon_out .constraint_function ([2 , - 1 ]) is False
2559+ assert pentagon_out .constraint_function ([2 , 6 ]) is False
2560+ assert pentagon_out .constraint_function ([0 , 0 ]) is True
25192561
25202562 def test_complex_polygons (self ):
25212563 """Test the constraint function with more complex polygons."""
@@ -2543,11 +2585,26 @@ def test_complex_polygons(self):
25432585 )
25442586 assert star .constraint_function ([3 , 3 ]) is False
25452587 assert star .constraint_function ([3 , 1 ]) is False
2546- assert star .constraint_function ([5 , 3 ]) is False
2588+ assert star .constraint_function ([5 , 3 ]) is True
25472589 assert star .constraint_function ([- 2 , 3 ]) is True
25482590 assert star .constraint_function ([8 , 3 ]) is True
25492591 assert star .constraint_function ([3 , - 2 ]) is True
25502592 assert star .constraint_function ([3 , 7 ]) is True
2593+ star_out = Polygon (
2594+ xy_coords = star_coords ,
2595+ loc = "out" ,
2596+ data = pd .DataFrame (),
2597+ X_axis = "x" ,
2598+ Y_axis = "y" ,
2599+ Field = "f" ,
2600+ )
2601+ assert star_out .constraint_function ([3 , 3 ]) is True
2602+ assert star_out .constraint_function ([3 , 1 ]) is True
2603+ assert star_out .constraint_function ([5 , 3 ]) is False
2604+ assert star_out .constraint_function ([- 2 , 3 ]) is False
2605+ assert star_out .constraint_function ([8 , 3 ]) is False
2606+ assert star_out .constraint_function ([3 , - 2 ]) is False
2607+ assert star_out .constraint_function ([3 , 7 ]) is False
25512608
25522609 def test_integration_with_base_constraint (self , sample_dataframe , triangle_coords ):
25532610 """Test that Polygon inherits and works with BaseConstraint methods."""
0 commit comments