Skip to content

pca.ipynb tests fail #466

Done
Done

Description

@orbeckst

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 differ

Input:
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

  1. jpkrowe commented on Dec 1, 2026

    @jpkrowe
    Contributor

    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.

  2. orbeckst commented on Dec 1, 2026

    @orbeckst
    MemberAuthor

    I like your idea! If you open an issue, we can start figuring out where it would apply – probably just git greo 'eig[h]\('.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions