Skip to content

Commit 5cff0de

Browse files
committed
draft unittest
1 parent 6d3dcf2 commit 5cff0de

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

ultraplot/tests/test_1dplots.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ def test_scatter_sizes():
378378
from matplotlib import tri
379379

380380

381-
@pytest.mark.mpl_image_compare
382381
@pytest.mark.mpl_image_compare
383382
@pytest.mark.parametrize(
384383
"x, y, z, triangles, use_triangulation, use_datadict",
@@ -427,3 +426,32 @@ def test_triplot_variants(x, y, z, triangles, use_triangulation, use_datadict):
427426
ax.triplot(x, y, "ko-") # Without specific triangles
428427

429428
return fig
429+
430+
@pytest.mark.mpl_image_compare
431+
@pytest.mark.parametrize("share", ["limits", "labels"])
432+
def test_axis_sharing(share):
433+
fig, ax = uplt.subplots(ncols = 2, nrows = 2, share = share)
434+
labels = ["A", "B", "C", "D"]
435+
for idx, axi in enumerate(ax):
436+
axi.scatter(idx, idx)
437+
axi.set_xlabel(labels[idx])
438+
axi.set_ylabel(labels[idx])
439+
440+
# TODO: the labels are handled in a funky way. The plot looks fine but the label are not "shared" that is the labels still exist but they are not visible and instead there are new labels created. Need to figure this out
441+
# test left hand side
442+
if share != "labels":
443+
assert all([i == j for i, j in zip(ax[0].get_xlim(), ax[2].get_xlim())])
444+
assert all([i == j for i, j in zip(ax[0].get_ylim(), ax[1].get_ylim())])
445+
assert all([i == j for i, j in zip(ax[1].get_xlim(), ax[3].get_xlim())])
446+
#elif share == "labels":
447+
# print("--" * 32)
448+
# print(repr(ax.get_xlabel()))
449+
# print(repr(ax.get_ylabel()))
450+
# print("--" * 32)
451+
# # columns shares x label
452+
# assert ax[0].get_xlabel() == ax[2].get_xlabel().strip()
453+
# assert ax[1].get_xlabel() == ax[3].get_xlabel().strip()
454+
# # rows share ylabel
455+
# assert ax[0].get_ylabel() == ax[1].get_ylabel().strip()
456+
# assert ax[2].get_ylabel().strip() == ax[3].get_ylabel().strip()
457+
return fig

0 commit comments

Comments
 (0)