Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCA tutorial projection example fails with ValueError #183

Closed
orbeckst opened this issue Jan 21, 2022 · 6 comments · Fixed by #184
Closed

PCA tutorial projection example fails with ValueError #183

orbeckst opened this issue Jan 21, 2022 · 6 comments · Fixed by #184
Labels
defect bug notebook Has notebooks associated

Comments

@orbeckst
Copy link
Member

Describe the bug
Example in PCA https://userguide.mdanalysis.org/dev/examples/analysis/reduced_dimensions/pca.html#Visualising-projections-into-a-reduced-dimensional-space fails.

Reporter: https://groups.google.com/g/mdnalysis-discussion/c/hM_p0JDY2hQ/m/CPlxf2MZCgAJ

To Reproduce
Steps to reproduce the behavior: Follow tutorial until

pc1 = pc.p_components[:, 0]
trans1 = transformed[:, 0]
projected = np.outer(trans1, pc1) + pc.mean

Expected behavior
projected is computed

Actual behavior
Fails with

Input In [22], in <module>
----> 1 projected = np.outer(trans1, pc1) + pc.mean

ValueError: operands could not be broadcast together with shapes (98,2565) (855,3)

Fix

projected = np.outer(trans1, pc1) + pc.mean.flatten()
@orbeckst orbeckst added notebook Has notebooks associated defect bug labels Jan 21, 2022
@orbeckst
Copy link
Member Author

orbeckst commented Jan 21, 2022

I am trying to load this notebook directly with jupyter-lab (Jupyter Server 1.13.3) and get an error

File Load Error for pca.ipynb
Unreadable Notebook: ~/MDAnalysis/UserGuide/doc/source/examples/analysis/reduced_dimensions/pca.ipynb NotJSONError('Notebook does not appear to be JSON: \'{\\n "cells": [\\n {\\n "cell_type": "m...')

(The diffusion notebook in the same directory loads fine.)

@orbeckst
Copy link
Member Author

Loading also fails with Jupyter Notebook 6.4.7

Error loading notebook

Unreadable Notebook: ~/MDAnalysis/UserGuide/doc/source/examples/analysis/reduced_dimensions/pca.ipynb NotJSONError('Notebook does not appear to be JSON: \'{\\n "cells": [\\n {\\n "cell_type": "m...')

@orbeckst
Copy link
Member Author

I'd like to actually fix this issue but don't know how to proceed if I cannot even load it. I pulled the master branch or should I use develop?

@orbeckst
Copy link
Member Author

Working from develop works...

@orbeckst orbeckst linked a pull request Jan 21, 2022 that will close this issue
@lilyminium
Copy link
Member

lilyminium commented Jan 22, 2022

Sorry, I missed this. I have no idea how or why but a closing brace was missing. You can see it here: https://github.com/MDAnalysis/UserGuide/pull/185/files#diff-1834d90511e206f517d291636dc4e135a63d87a7d2ca9d8cd5979df102defe02R8168

Edit: line 8168 in pca.ipynb, or where it should be in master is line 8239.

@lilyminium
Copy link
Member

Closed in #184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect bug notebook Has notebooks associated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants