Skip to content

Commit 7327eae

Browse files
authored
Update test_plot.py
1 parent f6fc6f0 commit 7327eae

1 file changed

Lines changed: 18 additions & 21 deletions

File tree

tests/test_plot.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@
8080

8181

8282
# Decorator for visual regression test using pytest-mpl
83-
# tolerance=15 is often needed due to slight differences in rendering/aliasing
84-
# between runs or systems, or slight differences from R's base graphics. Adjust as needed.
83+
# tolerance=15 is often needed due to slight differences in rendering
8584
@pytest.mark.mpl_image_compare(baseline_dir='baseline_images/test_plot',
8685
filename='simple_spline_plot.png',
8786
tolerance=15)
@@ -129,7 +128,7 @@ def test_simple_spline_plot():
129128
bg_col="white" # Default solid is often white
130129
)
131130

132-
# Assertions after plotting (optional)
131+
# Assertions after plotting
133132
assert fig is not None
134133
assert ax is not None
135134
assert ax.get_ylim() == (0, 100)
@@ -146,7 +145,7 @@ def test_simple_plot_with_legend():
146145
"""
147146
Tests creating the simple plot and adding a legend below it.
148147
"""
149-
# --- Setup fish data and layout (same as previous test) ---
148+
# --- Setup fish data and layout ---
150149
fish_data = FishPlotData(
151150
frac_table=FRAC_TABLE,
152151
parents=PARENTS,
@@ -176,14 +175,12 @@ def test_simple_plot_with_legend():
176175
bbox_to_anchor=(0.5, 0.1), # Anchor legend at x=0.5, y=0.1 in figure coords
177176
ncol=4) # Try 4 columns for 4 clones
178177

179-
# Adjust layout to prevent legend overlap (may need tweaking)
178+
# Adjust layout to prevent legend overlap
180179
fig.tight_layout(rect=[0, 0.1, 1, 1]) # Leave space at bottom (y=0.1)
181180

182181
return fig
183182

184-
# --- Add more tests here for other shapes, options, annotations, edge cases ---
185183

186-
# Example test for polygon shape
187184
@pytest.mark.mpl_image_compare(baseline_dir='baseline_images/test_plot',
188185
filename='simple_polygon_plot.png',
189186
tolerance=15)
@@ -198,7 +195,7 @@ def test_simple_polygon_plot():
198195

199196
# --- Test for Annotations ---
200197
@pytest.mark.mpl_image_compare(baseline_dir='baseline_images/test_plot',
201-
filename='simple_plot_with_annotations_outline.png', # New filename
198+
filename='simple_plot_with_annotations_outline.png',
202199
tolerance=15)
203200
def test_simple_plot_with_annotations_outline():
204201
"""
@@ -226,7 +223,7 @@ def test_simple_plot_with_annotations_outline():
226223
cex_vlab=0.7,
227224
bg_type="solid",
228225
bg_col="white",
229-
use_annot_outline=True # <<< Enable outline
226+
use_annot_outline=True
230227
)
231228
return fig
232229

@@ -248,14 +245,14 @@ def test_custom_annotation_style():
248245
timepoints=TIMEPOINTS,
249246
clone_labels=CLONE_LABELS,
250247
clone_annots=custom_annots,
251-
clone_annots_angle=30, # Rotate labels
252-
clone_annots_col='darkgreen', # Change color
248+
clone_annots_angle=30,
249+
clone_annots_col='darkgreen',
253250
clone_annots_pos=4, # Position to the right
254251
clone_annots_cex=0.9, # Increase size slightly
255252
clone_annots_offset=0.5 # Increase offset
256253
)
257254
fish_data.layout_clones()
258-
fig, ax = plt.subplots(figsize=(5.5, 5)) # Adjust size if needed
255+
fig, ax = plt.subplots(figsize=(5.5, 5))
259256

260257
fig, ax = fishplot(
261258
fish_data,
@@ -285,19 +282,19 @@ def test_panel_b_polygon_shape():
285282
)
286283
fish_data.layout_clones() # Default: separate_independent_clones=False
287284

288-
fig, ax = plt.subplots(figsize=(5, 4)) # Adjust size
285+
fig, ax = plt.subplots(figsize=(5, 4))
289286

290287
fig, ax = fishplot(
291288
fish_data,
292289
ax=ax,
293290
shape="polygon",
294-
vlines=TIMEPOINTS_B, # Match R example
291+
vlines=TIMEPOINTS_B,
295292
vlab=VLAB_B,
296293
title_btm="BRC32",
297-
ramp_angle=1.0, # R uses 1 for this panel
298-
pad_left_frac=0.3, # R uses 0.3 for this panel
299-
cex_vlab=0.8, # Match R
300-
cex_title=0.7, # Match R
294+
ramp_angle=1.0,
295+
pad_left_frac=0.3,
296+
cex_vlab=0.8,
297+
cex_title=0.7,
301298
# Using default background gradient
302299
)
303300
return fig
@@ -465,7 +462,7 @@ def test_fig2b_annotation_style():
465462
# Using default pos=2, cex=0.7, offset=0.2 from R example
466463
)
467464
fish_data.layout_clones()
468-
fig, ax = plt.subplots(figsize=(6, 5)) # Adjust size
465+
fig, ax = plt.subplots(figsize=(6, 5))
469466

470467
# Plot settings from R test
471468
fig, ax = fishplot(
@@ -474,11 +471,11 @@ def test_fig2b_annotation_style():
474471
shape="spline",
475472
vlines=VLINES_F2B,
476473
vlab=VLAB_F2B,
477-
title="Sample 150288", # Add title from R test
474+
title="Sample 150288",
478475
cex_title=0.9,
479476
cex_vlab=0.8,
480477
# Default background gradient
481-
use_annot_outline=True # Add outline for green text maybe? Optional.
478+
use_annot_outline=True # optional
482479
)
483480

484481
return fig

0 commit comments

Comments
 (0)