1
1
from collections .abc import Iterable
2
- from typing import Tuple
3
2
4
3
5
4
class BoundingBox :
@@ -16,56 +15,40 @@ class BoundingBox:
16
15
17
16
"""
18
17
19
- def __init__ (self , lower_left : Tuple [float ], upper_right : Tuple [float ]) -> None :
18
+ def __init__ (self , lower_left : tuple [float ], upper_right : tuple [float ]) -> None :
20
19
self ._lower_left = lower_left
21
20
self ._upper_right = upper_right
22
21
23
22
if not isinstance (self .lower_left , Iterable ) or len (self .lower_left ) != 2 :
24
23
raise ValueError (
25
- "lower left coordinate ({0}) must have two elements" .format (
26
- self .lower_left
27
- )
24
+ f"lower left coordinate ({ self .lower_left } ) must have two elements"
28
25
)
29
26
30
27
if not isinstance (self .upper_right , Iterable ) or len (self .upper_right ) != 2 :
31
28
raise ValueError (
32
- "upper right coordinate ({0}) must have two elements" .format (
33
- self .upper_right
34
- )
29
+ f"upper right coordinate ({ self .upper_right } ) must have two elements"
35
30
)
36
31
37
32
if self .south > 90 or self .south < - 90 :
38
- raise ValueError (
39
- "south coordinate ({0}) must be in [-90,90]" .format (self .south )
40
- )
33
+ raise ValueError (f"south coordinate ({ self .south } ) must be in [-90,90]" )
41
34
42
35
if self .north > 90 or self .north < - 90 :
43
- raise ValueError (
44
- "north coordinate ({0}) must be in [-90,90]" .format (self .north )
45
- )
36
+ raise ValueError (f"north coordinate ({ self .north } ) must be in [-90,90]" )
46
37
47
38
if self .south > self .north :
48
39
raise ValueError (
49
- "south coordinate ({0}) must be less than north ({1})" .format (
50
- self .south , self .north
51
- )
40
+ f"south coordinate ({ self .south } ) must be less than north ({ self .north } )"
52
41
)
53
42
54
43
if self .west > 180 or self .west < - 180 :
55
- raise ValueError (
56
- "west coordinate ({0}) must be in [-180,180]" .format (self .west )
57
- )
44
+ raise ValueError (f"west coordinate ({ self .west } ) must be in [-180,180]" )
58
45
59
46
if self .east > 180 or self .east < - 180 :
60
- raise ValueError (
61
- "east coordinate ({0}) must be in [-180,180]" .format (self .east )
62
- )
47
+ raise ValueError (f"east coordinate ({ self .east } ) must be in [-180,180]" )
63
48
64
49
if self .west > self .east :
65
50
raise ValueError (
66
- "west coordinate ({0}) must be less than east ({1})" .format (
67
- self .west , self .east
68
- )
51
+ f"west coordinate ({ self .west } ) must be less than east ({ self .east } )"
69
52
)
70
53
71
54
@property
@@ -95,5 +78,5 @@ def east(self):
95
78
return self .upper_right [1 ]
96
79
97
80
def __str__ (self ):
98
- s = "[{0}, {1}]" . format ( self .lower_left , self .upper_right )
81
+ s = f "[{ self .lower_left } , { self .upper_right } ]"
99
82
return s
0 commit comments