Mesnage-Org / pgfinder

Peptidoglycan MS1 Analysis Tool
https://mesnage-org.github.io/pgfinder
GNU Lesser General Public License v3.0
4 stars 2 forks source link

Fix pytest failures in PR #260

Closed ns-rse closed 3 months ago

ns-rse commented 3 months ago

Currently #249 fails the pytest tests with the following error

Run pytest --cov=pgfinder
7
============================= test session starts ==============================
8
platform linux -- Python 3.9.18, pytest-7.4.4, pluggy-1.3.0
9
Matplotlib: 3.8.2
10
Freetype: 2.6.1
11
rootdir: /home/runner/work/pgfinder/pgfinder/lib
12
configfile: pyproject.toml
13
testpaths: tests
14
plugins: regtest-1.5.1, xdist-3.5.0, mpl-0.16.1, cov-4.1.0
15
collected 17 items
16

17
tests/test_matching.py ...F                                              [ 23%]
18
tests/test_pgio.py ......                                                [ 58%]
19
tests/test_regression.py ...                                             [ 76%]
20
tests/test_utils.py ...                                                  [ 94%]
21
tests/test_validation.py .                                               [100%]
22

23
=================================== FAILURES ===================================
24
_______________________ test_pick_most_likely_structures _______________________
25

26
    def test_pick_most_likely_structures() -> None:
27
        """Test picking the most likely structure based on ppm"""
28
        long_df = pd.read_csv(RESOURCES / "long_results.csv")
29
        wide_df = pd.read_csv(RESOURCES / "wide_results.csv")
30

31
        reshaped_long_df = pick_most_likely_structures(long_df, 1)
32

33
>       pd.testing.assert_frame_equal(reshaped_long_df, wide_df, check_dtype=False)
34

35
tests/test_matching.py:41: 
36
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
37
testing.pyx:55: in pandas._libs.testing.assert_almost_equal
38
    ???
39
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
40

41
>   ???
42
E   AssertionError: DataFrame.iloc[:, 8] (column name="Inferred structure (consolidated)") are different
43
E   
44
E   DataFrame.iloc[:, 8] (column name="Inferred structure (consolidated)") values are different (50.0 %)
45
E   [index]: [0, 1, 2, 3, 4, 5]
46
E   [left]:  [gm|0, gm-AEJN|1,   gm-AEJGG|1,   gm-AEJX|1, nan, nan, gm-AEJR|1, nan]
47
E   [right]: [gm|0, gm-AEJN|1,   gm-AEJGG|1,   gm-AEJX|1, nan, nan, gm-AEJR|1, nan]
48
E   At positional index 2, first diff: nan != nan
49

50
testing.pyx:173: AssertionError
51

52
---------- coverage: platform linux, python 3.9.18-final-0 -----------
53
Name                        Stmts   Miss  Cover
54
-----------------------------------------------
55
pgfinder/__init__.py           13      0   100%
56
pgfinder/errors.py              1      0   100%
57
pgfinder/find_pg.py            70     70     0%
58
pgfinder/gui/__init__.py        0      0   100%
59
pgfinder/gui/internal.py       22      1    95%
60
pgfinder/gui/shim.py           14     14     0%
61
pgfinder/io.py                 14     14     0%
62
pgfinder/logs/__init__.py       0      0   100%
63
pgfinder/logs/logs.py          22     12    45%
64
pgfinder/matching.py          164      2    99%
65
pgfinder/pgio.py              102     23    77%
66
pgfinder/utils.py              30      0   100%
67
pgfinder/validation.py         43     16    63%
68
-----------------------------------------------
69
TOTAL                         495    152    69%
70

71
=========================== short test summary info ============================
72
FAILED tests/test_matching.py::test_pick_most_likely_structures - AssertionError: DataFrame.iloc[:, 8] (column name="Inferred structure (consolidated)") are different
73

74
DataFrame.iloc[:, 8] (column name="Inferred structure (consolidated)") values are different (50.0 %)
75
[index]: [0, 1, 2, 3, 4, 5]
76
[left]:  [gm|0, gm-AEJN|1,   gm-AEJGG|1,   gm-AEJX|1, nan, nan, gm-AEJR|1, nan]
77
[right]: [gm|0, gm-AEJN|1,   gm-AEJGG|1,   gm-AEJX|1, nan, nan, gm-AEJR|1, nan]
78
At positional index 2, first diff: nan != nan
79
======================== 1 failed, 16 passed in 35.98s =========================
80
Error: Process completed with exit code 1.

This needs fixing and the PR merging (presumably) before progressing with work.

ns-rse commented 3 months ago

This has magically resolved itself and the tests pass both locally (tested first) and in CI. Approved and merged #249.