Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 30f7897

Browse filesBrowse files
committed
cleaned up duplicate code in test_image
1 parent 1a23a5a commit 30f7897
Copy full SHA for 30f7897

File tree

Expand file treeCollapse file tree

1 file changed

+18
-24
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-24
lines changed

‎lib/matplotlib/tests/test_image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_image.py
+18-24Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,41 +72,35 @@ def test_interp_nearest_vs_none():
7272
ax2.set_title('interpolation nearest')
7373

7474

75+
def do_figimage(suppressComposite):
76+
""" Helper for the next two tests """
77+
fig = plt.figure(figsize=(2,2), dpi=100)
78+
fig.suppressComposite = suppressComposite
79+
x,y = np.ix_(np.arange(100.0)/100.0, np.arange(100.0)/100.0)
80+
z = np.sin(x**2 + y**2 - x*y)
81+
c = np.sin(20*x**2 + 50*y**2)
82+
img = z + c/5
83+
84+
fig.figimage(img, xo=0, yo=0, origin='lower')
85+
fig.figimage(img[::-1,:], xo=0, yo=100, origin='lower')
86+
fig.figimage(img[:,::-1], xo=100, yo=0, origin='lower')
87+
fig.figimage(img[::-1,::-1], xo=100, yo=100, origin='lower')
88+
7589
@image_comparison(baseline_images=['figimage-0'],
7690
extensions=['png','pdf'])
7791
def test_figimage0():
7892
'test the figimage method'
7993

80-
for suppressComposite in [False]:
81-
fig = plt.figure(figsize=(2,2), dpi=100)
82-
fig.suppressComposite = suppressComposite
83-
x,y = np.ix_(np.arange(100.0)/100.0, np.arange(100.0)/100.0)
84-
z = np.sin(x**2 + y**2 - x*y)
85-
c = np.sin(20*x**2 + 50*y**2)
86-
img = z + c/5
94+
suppressComposite = False
95+
do_figimage(suppressComposite)
8796

88-
fig.figimage(img, xo=0, yo=0, origin='lower')
89-
fig.figimage(img[::-1,:], xo=0, yo=100, origin='lower')
90-
fig.figimage(img[:,::-1], xo=100, yo=0, origin='lower')
91-
fig.figimage(img[::-1,::-1], xo=100, yo=100, origin='lower')
9297

9398
@image_comparison(baseline_images=['figimage-1'],
9499
extensions=['png','pdf'])
95100
def test_figimage1():
96101
'test the figimage method'
97-
98-
for suppressComposite in [True]:
99-
fig = plt.figure(figsize=(2,2), dpi=100)
100-
fig.suppressComposite = suppressComposite
101-
x,y = np.ix_(np.arange(100.0)/100.0, np.arange(100.0)/100.0)
102-
z = np.sin(x**2 + y**2 - x*y)
103-
c = np.sin(20*x**2 + 50*y**2)
104-
img = z + c/5
105-
106-
fig.figimage(img, xo=0, yo=0, origin='lower')
107-
fig.figimage(img[::-1,:], xo=0, yo=100, origin='lower')
108-
fig.figimage(img[:,::-1], xo=100, yo=0, origin='lower')
109-
fig.figimage(img[::-1,::-1], xo=100, yo=100, origin='lower')
102+
suppressComposite = True
103+
do_figimage(suppressComposite)
110104

111105

112106
def test_image_python_io():

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.