Skip to content

Commit f685a3e

Browse files
authored
Fix pytest warnings in graphics tests (#824)
1 parent 78d1d85 commit f685a3e

5 files changed

Lines changed: 32 additions & 10 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ artifacts = [
124124
addopts = "-v --cov=jcvi --cov-branch --cov-report=xml --cov-report=term"
125125
testpaths = ["tests"]
126126
python_files = ["test_*.py"]
127+
filterwarnings = [
128+
"ignore:invalid escape sequence.*:SyntaxWarning:ete3\\..*",
129+
]
127130

128131
[tool.isort]
129132
profile = "black"

src/jcvi/graphics/grabseeds.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,18 @@ def __init__(
8484
self.x, self.y = int(round(x)), int(round(y))
8585
self.location = f"{self.x}|{self.y}"
8686
self.area = int(round(props.area))
87-
self.length = int(round(props.major_axis_length))
88-
self.width = int(round(props.minor_axis_length))
87+
major_axis_length = (
88+
props.axis_major_length
89+
if hasattr(props, "axis_major_length")
90+
else props.major_axis_length
91+
)
92+
minor_axis_length = (
93+
props.axis_minor_length
94+
if hasattr(props, "axis_minor_length")
95+
else props.minor_axis_length
96+
)
97+
self.length = int(round(major_axis_length))
98+
self.width = int(round(minor_axis_length))
8999
self.props = props
90100
self.efds = efds
91101
self.circularity = 4 * pi * props.area / props.perimeter**2
@@ -798,7 +808,16 @@ def seeds(args):
798808
efds = efd_feature(contour)
799809
y0, x0 = props.centroid
800810
orientation = props.orientation
801-
major, minor = props.major_axis_length, props.minor_axis_length
811+
major = (
812+
props.axis_major_length
813+
if hasattr(props, "axis_major_length")
814+
else props.major_axis_length
815+
)
816+
minor = (
817+
props.axis_minor_length
818+
if hasattr(props, "axis_minor_length")
819+
else props.minor_axis_length
820+
)
802821
major_dx = sin(orientation) * major / 2
803822
major_dy = cos(orientation) * major / 2
804823
minor_dx = cos(orientation) * minor / 2

src/jcvi/graphics/karyotype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def main(args: List[str]):
455455

456456
seqidsfile, layoutfile = args
457457

458-
fig = plt.figure(1, (iopts.w, iopts.h))
458+
fig = plt.figure(figsize=(iopts.w, iopts.h))
459459
root = fig.add_axes((0, 0, 1, 1))
460460

461461
Karyotype(

src/jcvi/graphics/landscape.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def mosdepth(args):
220220
logscale = opts.logscale
221221

222222
# Construct a composite figure with N tracks indicated in the groups
223-
fig = plt.figure(1, (iopts.w, iopts.h))
223+
fig = plt.figure(figsize=(iopts.w, iopts.h))
224224
root = fig.add_axes((0, 0, 1, 1))
225225

226226
rows = len(groups)
@@ -608,7 +608,7 @@ def depth(args):
608608

609609
bedfiles = args
610610

611-
fig = plt.figure(1, (iopts.w, iopts.h))
611+
fig = plt.figure(figsize=(iopts.w, iopts.h))
612612
root = fig.add_axes((0, 0, 1, 1))
613613

614614
npanels = len(bedfiles)
@@ -788,7 +788,7 @@ def composite(args):
788788
plt.rcParams["xtick.major.size"] = 0
789789
plt.rcParams["ytick.major.size"] = 0
790790

791-
fig = plt.figure(1, (iopts.w, iopts.h))
791+
fig = plt.figure(figsize=(iopts.w, iopts.h))
792792
root = fig.add_axes((0, 0, 1, 1))
793793

794794
root.text(0.5, 0.95, chr, ha="center", color="darkslategray")
@@ -1072,7 +1072,7 @@ def heatmap(args):
10721072
stacks = opts.stacks.split(",")
10731073
heatmaps = opts.heatmaps.split(",")
10741074

1075-
fig = plt.figure(1, (iopts.w, iopts.h))
1075+
fig = plt.figure(figsize=(iopts.w, iopts.h))
10761076
root_extent = (0, 0, 1, 1)
10771077
root = fig.add_axes(root_extent)
10781078

@@ -1301,7 +1301,7 @@ def stack(args):
13011301

13021302
stacks = opts.stacks.split(",")
13031303

1304-
fig = plt.figure(1, (iopts.w, iopts.h))
1304+
fig = plt.figure(figsize=(iopts.w, iopts.h))
13051305
root_extent = (0, 0, 1, 1)
13061306
root = fig.add_axes(root_extent)
13071307

src/jcvi/graphics/synteny.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ def main(args: List[str]):
693693
prune_features = not opts.noprune
694694

695695
pf = datafile.rsplit(".", 1)[0]
696-
fig = plt.figure(1, (iopts.w, iopts.h))
696+
fig = plt.figure(figsize=(iopts.w, iopts.h))
697697
root = fig.add_axes((0, 0, 1, 1))
698698
Synteny(
699699
fig,

0 commit comments

Comments
 (0)