### Update line numbers in normalize_rectangle (#732)

```* Update error messages to show new line numbers

* Update line numbers in episode text

The reference to line 14 right after the last example for this
function is correct (that is, it should not be 17) as it was fixed
in #704.```
parent fdf5ef2f
 ... ... @@ -143,7 +143,7 @@ def normalize_rectangle(rect): ~~~ {: .language-python} The preconditions on lines 3, 5, and 6 catch invalid inputs: The preconditions on lines 6, 8, and 9 catch invalid inputs: ~~~ print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate ... ... @@ -153,10 +153,10 @@ print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate ~~~ --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) in () in ----> 1 print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate in normalize_rectangle(rect) in normalize_rectangle(rect) 4 (x0, y0) and (x1, y1) define the lower left and upper right corners 5 of the rectangle, respectively.''' ----> 6 assert len(rect) == 4, 'Rectangles must contain 4 coordinates' ... ... @@ -175,21 +175,21 @@ print(normalize_rectangle( (4.0, 2.0, 1.0, 5.0) )) # X axis inverted ~~~ --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) in () in ----> 1 print(normalize_rectangle( (4.0, 2.0, 1.0, 5.0) )) # X axis inverted in normalize_rectangle(rect) 3 assert len(rect) == 4, 'Rectangles must contain 4 coordinates' 4 x0, y0, x1, y1 = rect ----> 5 assert x0 < x1, 'Invalid X coordinates' 6 assert y0 < y1, 'Invalid Y coordinates' 7 in normalize_rectangle(rect) 6 assert len(rect) == 4, 'Rectangles must contain 4 coordinates' 7 x0, y0, x1, y1 = rect ----> 8 assert x0 < x1, 'Invalid X coordinates' 9 assert y0 < y1, 'Invalid Y coordinates' 10 AssertionError: Invalid X coordinates ~~~ {: .error} The post-conditions on lines 17 and 18 help us catch bugs by telling us when our The post-conditions on lines 20 and 21 help us catch bugs by telling us when our calculations might have been incorrect. For example, if we normalize a rectangle that is taller than it is wide everything seems OK: ... ... @@ -215,15 +215,15 @@ print(normalize_rectangle( (0.0, 0.0, 5.0, 1.0) )) ~~~ --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) in () in ----> 1 print(normalize_rectangle( (0.0, 0.0, 5.0, 1.0) )) in normalize_rectangle(rect) 16 17 assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid' ---> 18 assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid' in normalize_rectangle(rect) 19 20 return (0, 0, upper_x, upper_y) 20 assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid' ---> 21 assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid' 22 23 return (0, 0, upper_x, upper_y) AssertionError: Calculated upper Y coordinate invalid ~~~ ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!