8000 add tests for annotation and pass the tests, without changing Text an… · matplotlib/matplotlib@bb51437 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb51437

Browse files
stevezhangstevezhang
authored andcommitted
add tests for annotation and pass the tests, without changing Text and Annotation class
1 parent 268edae commit bb51437

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/matplotlib/tests/test_text.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import matplotlib.transforms as mtransforms
1515
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1616
from matplotlib.testing._markers import needs_usetex
17-
from matplotlib.text import Text
17+
from matplotlib.text import Text, Annotation
1818

1919

2020
@image_comparison(['font_styles'])
@@ -906,3 +906,18 @@ def test_get_antialiased():
906906
txt3 = Text(.5, .5, "foo\nbar", antialiased=False)
907907
assert txt3._antialiased == False
908908
assert txt3.get_antialiased() == txt3._antialiased
909+
910+
def test_annotation_antialiased():
911+
annot = Annotation("foo\nbar", (.5, .5), antialiased=True)
912+
assert annot._antialiased == True
913+
assert annot.get_antialiased() == annot._antialiased
914+
915+
annot2 = Annotation("foo\nbar", (.5, .5), antialiased=False)
916+
assert annot2._antialiased == False
917+
assert annot2.get_antialiased() == annot2._antialiased
918+
919+
920+
annot3 = Annotation("foo\nbar", (.5, .5), antialiased=False)
921+
annot3.set_antialiased(True)
922+
assert annot3.get_antialiased() == True
923+
assert annot3._antialiased == True

lib/matplotlib/text.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ def draw(self, renderer):
757757
gc.set_foreground(self.get_color())
758758
gc.set_alpha(self.get_alpha())
759759
gc.set_url(self._url)
760+
gc.set_antialiased(self._antialiased)
760761
self._set_gc_clip(gc)
761762

762763
angle = self.get_rotation()

0 commit comments

Comments
 (0)
0