Repository navigation
Description
Describe the bug
with latest MDA version the pca.ipynb tests fail with a flipped sign; this is likely due to the change from eig to eigh in PR MDAnalysis/mdanalysis#5563, which can lead to flipped signs in the returned eigenvectors
To Reproduce
python -m pytest
See https://github.com/MDAnalysis/UserGuide/actions/runs/46191647253/job/141123552168?pr=430
Snippet of the error output from the GH action log when running python -m pytest
=========================== short test summary info ============================ FAILED pca.ipynb::Cell 9 - Notebook cell execution failed Cell 9: Cell outputs differInput:
df = pd.DataFrame(transformed,
columns=['PC{}'.format(i+1) for i in range(3)])
df['Time (ps)'] = df.index * u.trajectory.dt
df.head()Traceback:
mismatch 'text/html'assert reference_output == test_output failed:
'
\n<styl...able>\n' == '\n<styl...able>\n'Skipping 473 identical leading characters in diff, use -v to show
-
<td>-118.408413</td>
? -
-
<td>118.408413</td>
-
<td>-29.088241</td>
? -
-
<td>29.088241</td> <td>15.746624</td> <td>0.0</td> </tr> <tr> <th>1</th>
-
<td>-115.561879</td>
? -
-
<td>115.561879</td>
-
<td>-26.786797</td>
? -
-
<td>26.786797</td> <td>14.652498</td> <td>1.0</td> </tr> <tr> <th>2</th>
-
<td>-112.675616</td>
? -
-
<td>112.675616</td>
-
<td>-25.038766</td>
? -
-
<td>25.038766</td> <td>12.920274</td> <td>2.0</td> </tr> <tr> <th>3</th>
-
<td>-110.341467</td>
? -
-
<td>110.341467</td>
-
<td>-24.306984</td>
? -
-
<td>24.306984</td> <td>11.427098</td> <td>3.0</td> </tr> <tr> <th>4</th>
-
<td>-107.584302</td>
? -
-
<td>107.584302</td>
-
<td>-23.464154</td>
? -
-
<td>23.464154</td> <td>11.612104</td> <td>4.0</td> </tr>
====== 1 failed, 604 passed, 1 skipped, 774 warnings in 298.78s (0:04:58) ======
Error: Process completed with exit code 1.
Expected behavior
test pass with latest MDA version for the pca.ipynb
Actual behavior
test fails and the diff looks as if just the signs flipped; this would be still correct
Activity
jpkrowe commentedon Dec 1, 2026
I have opened a PR where I have swapped the signs in the notebook, but I wonder whether we should have some convention for eigenvector output in the main library so that it is deterministic. For example, we could set it so that the component with largest manitude is positive.
orbeckst commentedon Dec 1, 2026
I like your idea! If you open an issue, we can start figuring out where it would apply – probably just
git greo 'eig[h]\('.