8
8
9
9
from nose .tools import assert_equal , assert_raises
10
10
import numpy .testing as np_test
11
- from numpy .testing import assert_almost_equal
11
+ from numpy .testing import assert_almost_equal , assert_array_equal
12
12
from matplotlib .transforms import Affine2D , BlendedGenericTransform
13
13
from matplotlib .path import Path
14
14
from matplotlib .scale import LogScale
@@ -450,14 +450,14 @@ def test_line_extents_for_non_affine_transData(self):
450
450
expeted_data_lim )
451
451
452
452
453
+ def assert_bbox_eq (bbox1 , bbox2 ):
454
+ assert_array_equal (bbox1 .bounds , bbox2 .bounds )
455
+
456
+
453
457
def test_bbox_intersection ():
454
458
bbox_from_ext = mtrans .Bbox .from_extents
455
459
inter = mtrans .Bbox .intersection
456
460
457
- from numpy .testing import assert_array_equal as assert_a_equal
458
- def assert_bbox_eq (bbox1 , bbox2 ):
459
- assert_a_equal (bbox1 .bounds , bbox2 .bounds )
460
-
461
461
r1 = bbox_from_ext (0 , 0 , 1 , 1 )
462
462
r2 = bbox_from_ext (0.5 , 0.5 , 1.5 , 1.5 )
463
463
r3 = bbox_from_ext (0.5 , 0 , 0.75 , 0.75 )
@@ -476,6 +476,18 @@ def assert_bbox_eq(bbox1, bbox2):
476
476
assert_bbox_eq (inter (r1 , r5 ), bbox_from_ext (1 , 1 , 1 , 1 ))
477
477
478
478
479
+ def test_bbox_as_strings ():
480
+ b = mtrans .Bbox ([[.5 , 0 ], [.75 , .75 ]])
481
+ assert_bbox_eq (b , eval (repr (b ), {'Bbox' : mtrans .Bbox }))
482
+ asdict = eval (str (b ), {'Bbox' : dict })
483
+ for k , v in asdict .items ():
484
+ assert_equal (getattr (b , k ), v )
485
+ fmt = '.1f'
486
+ asdict = eval (format (b , fmt ), {'Bbox' : dict })
487
+ for k , v in asdict .items ():
488
+ assert_equal (eval (format (getattr (b , k ), fmt )), v )
489
+
490
+
479
491
if __name__ == '__main__' :
480
492
import nose
481
493
nose .runmodule (argv = ['-s' ,'--with-doctest' ], exit = False )
0 commit comments