Random test failure of `test_plotting.py::test_paga`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
Description
Running the scanpy tests locally (see system information and package versions below), I noticed the test scanpy/tests/test_plotting.py::test_paga sometimes failing due to AssertionError: Error: Image files did not match but passing on a consecutive run.
Did anyone encounter similar problems or does anyone know why this is happening?
Failure message
>>> pytest scanpy/tests/test_plotting.py
scanpy/tests/test_plotting.py .............................................x............F.... [100%]
=========================================================================================================== FAILURES ============================================================================================================
___________________________________________________________________________________________________________ test_paga ___________________________________________________________________________________________________________
image_comparer = <function make_comparer at 0x7fbce4ade8c0>
def test_paga(image_comparer):
# Sometimes things shift a pixel or so, resulting in diffs up to ~27
# The 1px-edges aren’t that good actually as they’re ignored at this tol …
save_and_compare_images = image_comparer(ROOT, FIGS, tol=30)
pbmc = sc.datasets.pbmc68k_reduced()
sc.tl.paga(pbmc, groups='bulk_labels')
common = dict(threshold=0.5, max_edge_width=1.0, random_state=0, show=False)
# delete bulk_labels_colors to test the creation of color list by paga
del pbmc.uns['bulk_labels_colors']
sc.pl.paga(pbmc, **common)
save_and_compare_images('master_paga')
sc.pl.paga(pbmc, color='CST3', **common)
save_and_compare_images('master_paga_continuous')
pbmc.obs['cool_feature'] = pbmc[:, 'CST3'].X.squeeze()
sc.pl.paga(pbmc, color='cool_feature', **common)
save_and_compare_images('master_paga_continuous_obs')
sc.pl.paga(pbmc, color=['CST3', 'GATA2'], **common)
save_and_compare_images('master_paga_continuous_multiple')
sc.pl.paga_compare(pbmc, legend_fontoutline=2, **common)
save_and_compare_images('master_paga_compare')
sc.pl.paga_compare(pbmc, color='CST3', legend_fontsize=5, **common)
save_and_compare_images('master_paga_compare_continuous')
sc.pl.paga_compare(pbmc, basis='X_pca', legend_fontweight='normal', **common)
save_and_compare_images('master_paga_compare_pca')
colors = {
c: {cm.Set1(_): 0.33 for _ in range(3)}
for c in pbmc.obs["bulk_labels"].cat.categories
}
colors["Dendritic"] = {cm.Set2(_): 0.25 for _ in range(4)}
sc.pl.paga(pbmc, color=colors, colorbar=False)
> save_and_compare_images('master_paga_pie')
scanpy/tests/test_plotting.py:917:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
basename = 'master_paga_pie', tolerance = 30
def save_and_compare(basename, tolerance=None):
path_actual.mkdir(parents=True, exist_ok=True)
out_path = path_actual / f'{basename}.png'
pyplot.savefig(out_path, dpi=40)
pyplot.close()
if tolerance is None:
tolerance = tol
res = compare_images(
str(path_expected / f'{basename}.png'), str(out_path), tolerance
)
> assert res is None, res
E AssertionError: Error: Image files did not match.
E RMS Value: 36.26034272194439
E Expected:
E /Users/philipp/Documents/python/scanpy/scanpy/tests/_images/master_paga_pie.png
E Actual:
E /Users/philipp/Documents/python/scanpy/scanpy/tests/figures/master_paga_pie.png
E Difference:
E /Users/philipp/Documents/python/scanpy/scanpy/tests/figures/master_paga_pie-failed-diff.png
E Tolerance:
E 30
E assert 'Error: Image files did not match.\n RMS Value: 36.26034272194439\n Expected: \n /Users/philipp/Documents/python... /Users/philipp/Documents/python/scanpy/scanpy/tests/figures/master_paga_pie-failed-diff.png\n Tolerance: \n 30' is None
scanpy/tests/conftest.py:35: AssertionError
----------------------------------------------------------------------------------------------------- Captured stderr call ------------------------------------------------------------------------------------------------------
running PAGA
finished: added
'paga/connectivities', connectivities adjacency (adata.uns)
'paga/connectivities_tree', connectivities subtree (adata.uns) (0:00:00)
--> added 'pos', the PAGA positions (adata.uns['paga'])
--> added 'pos', the PAGA positions (adata.uns['paga'])
--> added 'pos', the PAGA positions (adata.uns['paga'])
--> added 'pos', the PAGA positions (adata.uns['paga'])
--> added 'pos', the PAGA positions (adata.uns['paga'])
--> added 'pos', the PAGA positions (adata.uns['paga'])
--> added 'pos', the PAGA positions (adata.uns['paga'])
--> added 'pos', the PAGA positions (adata.uns['paga'])
Versions
[Paste the output of scanpy.logging.print_versions() leaving a blank line after the details tag]
-----
anndata 0.7.4
scanpy 1.6.1.dev25+g74ac4d37
sinfo 0.3.1
-----
PIL 7.2.0
anndata 0.7.4
asciitree NA
cycler 0.10.0
cython_runtime NA
dask 2.26.0
dateutil 2.8.1
fasteners NA
get_version 2.1
h5py 2.10.0
igraph 0.8.2
importlib_metadata 1.7.0
joblib 0.16.0
kiwisolver 1.2.0
legacy_api_wrap 1.2
leidenalg 0.8.1
llvmlite 0.34.0
louvain 0.7.0
matplotlib 3.3.2
monotonic NA
mpl_toolkits NA
natsort 7.0.1
numba 0.51.2
numcodecs 0.7.2
numexpr 2.7.1
numpy 1.19.2
packaging 20.4
pandas 1.1.2
pkg_resources NA
pyparsing 2.4.7
pytz 2020.1
scanpy 1.6.1.dev25+g74ac4d37
scipy 1.5.2
sinfo 0.3.1
six 1.15.0
sklearn 0.23.2
tables 3.6.1
texttable 1.6.3
tlz 0.10.0
toolz 0.10.0
yaml 5.3.1
zappy NA
zarr 2.4.0
zipp NA
-----
Python 3.7.9 (default, Aug 31 2020, 07:22:35) [Clang 10.0.0 ]
Darwin-19.6.0-x86_64-i386-64bit
12 logical CPU cores, i386
-----
Session information updated at 2020-09-16 13:37
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing scanpy/tests/test_plotting.py::test_paga repeatedly and inspect the image comparison in scanpy/tests/conftest.py. Compare the generated master_paga_pie image and failure diff across runs, along with the listed Python and matplotlib versions. Done means the cause of the nondeterministic mismatch is identified and the test passes reliably.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, python
- Domain
- data-visualization, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100