Skip to content

Commit 561ea84

Browse files
authored
Migrate Figure.text tests to dvc (#1167)
1 parent bdd58e1 commit 561ea84

34 files changed

+87
-33
lines changed
-5.39 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: ecd7b400f7421d0f9d65879f798be3aa
3+
size: 5485
4+
path: test_text_angle_30.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 67773d5e56bd3d8a9afda23551f24793
3+
size: 14146
4+
path: test_text_angle_font_justify_from_textfile.png
-1.87 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 81c49d2f653288ac23937a8a91802ff3
3+
size: 1918
4+
path: test_text_fill.png
-1.31 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 55875debfe049cc8b9fed9012ab0cde7
3+
size: 1346
4+
path: test_text_font_bold.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: ad2ebff32ed5559c165767427ad974cb
3+
size: 32675
4+
path: test_text_input_multiple_filenames.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 3dcfb0403ab740ea59b6633af1d466d3
3+
size: 48909
4+
path: test_text_input_remote_filename.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 0d4bb86bb215dc668954cd0f797b0112
3+
size: 30750
4+
path: test_text_input_single_filename.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: de441a55342a02fd9a72dfb4e26b1e4f
3+
size: 4665
4+
path: test_text_justify_bottom_right_and_top_left.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 5933108dbec4e66903180fec744128fb
3+
size: 11229
4+
path: test_text_justify_parsed_from_textfile.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 680b7683044d4a4dced2fa7ef6b224f3
3+
size: 6016
4+
path: test_text_multiple_lines_of_text.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 33281f8b69dabad053c3031e17b0680b
3+
size: 17998
4+
path: test_text_nonstr_text.png
-2.45 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 0fa24792c277718f44e6468a699921a0
3+
size: 2469
4+
path: test_text_pen.png
-10.3 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 3463b1217b0d1aca2913cbcb9b0ca438
3+
size: 10583
4+
path: test_text_position.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: e5645d25873e31c750e6642a63a6d47d
3+
size: 11577
4+
path: test_text_position_offset_with_line.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: ad64e7cba2c3f776a8786fd551063489
3+
size: 3558
4+
path: test_text_round_clearance.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 3f3874c252ee2cefc3f9a2c29f46b8e3
3+
size: 1839
4+
path: test_text_single_line_of_text.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: c2fd156325a40e9d875edfd6d236002e
3+
size: 24535
4+
path: test_text_transparency.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 5e867b4473cd9d1063ad5a08253e031c
3+
size: 24775
4+
path: test_text_varying_transparency.png

pygmt/tests/test_text.py

+15-33
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pygmt import Figure
1010
from pygmt.exceptions import GMTCLibError, GMTInvalidInput
1111
from pygmt.helpers import GMTTempFile
12-
from pygmt.helpers.testing import check_figures_equal
1312

1413
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
1514
POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")
@@ -21,7 +20,7 @@ def projection():
2120
"""
2221
The projection system.
2322
"""
24-
return "x4i"
23+
return "x10c"
2524

2625

2726
@pytest.fixture(scope="module")
@@ -304,7 +303,7 @@ def test_text_angle_font_justify_from_textfile():
304303
return fig
305304

306305

307-
@check_figures_equal()
306+
@pytest.mark.mpl_image_compare
308307
def test_text_transparency():
309308
"""
310309
Add texts with a constant transparency.
@@ -313,20 +312,15 @@ def test_text_transparency():
313312
y = np.arange(11, 20)
314313
text = [f"TEXT-{i}-{j}" for i, j in zip(x, y)]
315314

316-
fig_ref, fig_test = Figure(), Figure()
317-
# Use single-character arguments for the reference image
318-
with GMTTempFile() as tmpfile:
319-
np.savetxt(tmpfile.name, np.c_[x, y, text], fmt="%s")
320-
fig_ref.basemap(R="0/10/10/20", J="X10c", B="")
321-
fig_ref.text(textfiles=tmpfile.name, t=50)
315+
fig = Figure()
322316

323-
fig_test.basemap(region=[0, 10, 10, 20], projection="X10c", frame=True)
324-
fig_test.text(x=x, y=y, text=text, transparency=50)
317+
fig.basemap(region=[0, 10, 10, 20], projection="X10c", frame=True)
318+
fig.text(x=x, y=y, text=text, transparency=50)
325319

326-
return fig_ref, fig_test
320+
return fig
327321

328322

329-
@check_figures_equal()
323+
@pytest.mark.mpl_image_compare
330324
def test_text_varying_transparency():
331325
"""
332326
Add texts with varying transparency.
@@ -336,33 +330,21 @@ def test_text_varying_transparency():
336330
text = [f"TEXT-{i}-{j}" for i, j in zip(x, y)]
337331
transparency = np.arange(10, 100, 10)
338332

339-
fig_ref, fig_test = Figure(), Figure()
340-
# Use single-character arguments for the reference image
341-
with GMTTempFile() as tmpfile:
342-
np.savetxt(tmpfile.name, np.c_[x, y, transparency, text], fmt="%s")
343-
fig_ref.basemap(R="0/10/10/20", J="X10c", B="")
344-
fig_ref.text(textfiles=tmpfile.name, t="")
345-
346-
fig_test.basemap(region=[0, 10, 10, 20], projection="X10c", frame=True)
347-
fig_test.text(x=x, y=y, text=text, transparency=transparency)
333+
fig = Figure()
334+
fig.basemap(region=[0, 10, 10, 20], projection="X10c", frame=True)
335+
fig.text(x=x, y=y, text=text, transparency=transparency)
348336

349-
return fig_ref, fig_test
337+
return fig
350338

351339

352-
@check_figures_equal()
340+
@pytest.mark.mpl_image_compare
353341
def test_text_nonstr_text():
354342
"""
355343
Input text is in non-string type (e.g., int, float)
356344
"""
357-
fig_ref, fig_test = Figure(), Figure()
358-
359-
# Use single-character arguments and input files for the reference image
360-
with GMTTempFile(suffix=".txt") as tempfile:
361-
with open(tempfile.name, "w") as tmpfile:
362-
tmpfile.write("1 1 1.0\n2 2 2.0\n3 3 3.0\n4 4 4.0\n")
363-
fig_ref.text(R="0/10/0/10", J="X10c", B="", textfiles=tempfile.name)
345+
fig = Figure()
364346

365-
fig_test.text(
347+
fig.text(
366348
region=[0, 10, 0, 10],
367349
projection="X10c",
368350
frame=True,
@@ -371,4 +353,4 @@ def test_text_nonstr_text():
371353
text=[1, 2, 3.0, 4.0],
372354
)
373355

374-
return fig_ref, fig_test
356+
return fig

0 commit comments

Comments
 (0)