Skip to content

transition analysis docs to numpy style#1240

Merged
kain88-de merged 9 commits intodevelopfrom
doc-fixes-2
Apr 2, 2017
Merged

transition analysis docs to numpy style#1240
kain88-de merged 9 commits intodevelopfrom
doc-fixes-2

Conversation

@orbeckst
Copy link
Copy Markdown
Member

@orbeckst orbeckst commented Mar 10, 2017

Use this WIP PR to accumulate doc fixes for analysis. When we have enough we can merge or squash-merge. I didn't want to do a proper PR for a single simple reST fix...

Changes made in this Pull Request:

  • doc fixes in analysis (eg SeeAlso, Example sections, ...)
  • transition analysis docs to numpy style

Note that @jbarnoud has been tackling all other docs in PR #1247.

PR Checklist

  • n/a Tests?
  • Docs?
  • n/a CHANGELOG updated?
  • n/a Issue raised/referenced?

@orbeckst orbeckst changed the title [WIP] various doc fixes [WIP] transition analysis docs to numpy style Mar 23, 2017
@orbeckst
Copy link
Copy Markdown
Member Author

I cleaned up some code in analysis.gnm and apparently broke things. Will need to look into this.

@orbeckst
Copy link
Copy Markdown
Member Author

fixed gnm issue, rebased and force-pushed

@orbeckst
Copy link
Copy Markdown
Member Author

orbeckst commented Mar 24, 2017

... and travis exceeded time so I restarted the job. (We really need to reduce the test time #1191 )

@orbeckst
Copy link
Copy Markdown
Member Author

Full test exceeded time again. I'll try rolling back whatever small code changes I made in analysis.gnm.

(Locally

./mda_nosetests -v ./analysis/test_gnm.py

takes 122.4 s on a single 3.1 GHz i7 core with most of the time spent on test_gnm.TestGNM.test_closeContactGNMAnalysis.)

if jcounter > icounter and _dsq(positions[icounter], positions[jcounter]) <= cutoffsq:
iresidue, jresidue = residue_index_map[icounter], residue_index_map[jcounter]
if self.MassWeight:
contact = 1.0 / (len(self.ca.residues[iresidue].atoms) * len(self.ca.residues[jresidue].atoms)) ** 0.5
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was responsible for the huge amount of time that the GNM test TestGNM.test_closeContactGNMAnalysis took.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you push your fix to a new branch separate from this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this logic appears also in the other class in this file. It would be nice if you can change it their too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix elsewhere; apparently only mattered in the instance were I fixed it because many more atoms were used.

I can try to disentangle but their were also some cleanups in gnm in an earlier commit. I will look at a local interactive rebase and see if I can merge these commits.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, actually, where did you see another instance of this problem? GNMAnalysis.generate_kirchoff() does not use custom weights. I am not sure where else this needs fixing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I misremembered. I thought both classes use the custom weights.

Copy link
Copy Markdown
Member Author

@orbeckst orbeckst Mar 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See PR #1272 – all analysis.gnm changes were removed from this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardjgowers / @dotsdl would you expect a lookup such as len(self.ca.residues[iresidue].atoms to be slow? In particular, is self.ca.residues the bottle neck?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So assuming self.ca is an AtomGroup,

So nothing too offensively slow from what I can see, but you might be able to calculate them all ahead of time (as these memberships won't change) if you're looping over these things a lot.

@orbeckst
Copy link
Copy Markdown
Member Author

Optimized a single line in analysis.gnm.closeContactGNMAnalysis.generate_kirchhoff() and locally reduced the run time of the longest test TestGNM.test_closeContactGNMAnalysis by about 4-5 fold.

(Also rebased and force pushed.)

cutoffsq = self.cutoff ** 2

# cache sqrt of residue sizes (slow) so that sr[i]*sr[j] == sqrt(r[i]*r[j])
sqrt_res_sizes = np.sqrt([r.atoms.n_atoms for r in self.ca.residues]) if self.MassWeight else None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw is that really a weights defined by the mass? It looks only like a estimate of the actual mass. Would size be a better name?

Since you are refactoring this code already. It be nice if this variable was renamed weights and then have options None or 'size'.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really weight but that's what was in the original code.

I'll rename the variable but leave the kwarg as it is but add a note.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See e335c37

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in PR #1272

@orbeckst
Copy link
Copy Markdown
Member Author

I moved the GNM improvements to separate PR #1272 and rebased and force-pushed.

@orbeckst
Copy link
Copy Markdown
Member Author

orbeckst commented Mar 30, 2017 via email

@orbeckst
Copy link
Copy Markdown
Member Author

rebased and force pushed

@orbeckst orbeckst changed the title [WIP] transition analysis docs to numpy style transition analysis docs to numpy style Mar 31, 2017
@orbeckst
Copy link
Copy Markdown
Member Author

All analysis docs are now numpy style.

@orbeckst
Copy link
Copy Markdown
Member Author

Somone has to review it, otherwise it can't be merged...

@orbeckst orbeckst added this to the 0.16.0 milestone Mar 31, 2017
.. _`10.1002/prot.340090204`: http://dx.doi.org/10.1002/prot.340090204


Example
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fyi: with numpy docs, never use Example or Examples in a normal section context. sphinx napoleon rewrites it. So you have to ne a bit creative with labelling sections in the main part of the page.

Copy link
Copy Markdown
Member

@kain88-de kain88-de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only found minor issues skimming over this. Good work!


.. NOTE:: If failure occurs be sure to check the segment identification.

.. note:: If failure occurs be sure to check the segment identification.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big letter N? Why Note use the numpy note section?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to Notes section (rebased so it now shows up in commit 056f097 )

>>> hausdorff_wavg(P,Q[::-1]) # weighted avg hausdorff dist w/ Q reversed
2.5669644353703447

Notes
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it with the trailing s?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



.. NOTE:: If failure occurs be sure to check the segment identification.
.. Note:: If failure occurs be sure to check the segment identification.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not the numpy notes section

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to Notes section (rebased so it now shows up in commit 056f097 )

orbeckst added 9 commits April 1, 2017 09:16
Do not use Examples as a heading UNLESS inside a function/class doc because the NumPy reST
parser changes it to a rubric heading. This breaks document structure.
- converted all docs to numpy style
- added additional references
- see also: @tylerjereddy 's scipy.spatial.distance.directed_hausdorff()
- analysis.align: formatting fixes
- analysis.contacts: formatting fixes
- analysis.diffusionmap: formatting fixes and section headers (cannot use
  'Examples' as a normal section header because it is rewritten by
  sphinx.ext.napoleon as a rubric)
- analysis.distances: numpyfied
- analysis.hbonds.hbond_analysis: numpyfied
- numpified docs
- removed kwargs start and end for resid selection from def helanal_main()
  and helanal_trajectory() because this can be easily done inside the
  selection string and neither start nor end are used further in the code.
  helanal_trajectory() uses the resid of the first and last residue extensively
  for reporting so we now get these resids from the selection itself.
@orbeckst
Copy link
Copy Markdown
Member Author

orbeckst commented Apr 1, 2017

Incorporated @kain88-de 's suggestions, rebased into the appropriate commit, and rewrote some of the commit messages. I think I am done.

When @jbarnoud finishes PR #1247 then we will have transitioned all our docs to numpy style.

@orbeckst orbeckst mentioned this pull request Apr 1, 2017
3 tasks
@kain88-de kain88-de merged commit 3aecf99 into develop Apr 2, 2017
@kain88-de kain88-de deleted the doc-fixes-2 branch April 2, 2017 12:27
:func:`sequence_alignment`, which does not require external
programs.

.. SeeAlso::
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea how to change those automatically to the old style? My first try find . -name '*py' -exec sed -i "s/.. SeeAlso::/See Also \n--------\n/" {} \; doesn't work. It can't deal with potential indentation of the initial see also paragraph.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a quick look and I ended up with this:

sed -re 's/^(( *).. SeeAlso::( *))/\2See Also\n\2--------\n\2/g' package/MDAnalysis/lib/util.py | less

You need the -r or you will have to escape all the parentheses, and you may not have the \2 syntax. The \2 is there to report the indentation.

orbeckst pushed a commit that referenced this pull request Apr 25, 2017
* replace .. SeeAlso:: with numpy section
* fix obvious formatting errors
* addressed comments from @jbarnoud 
* fix rendering issues
* some more usability changes
* add ExtendedPDBReader to docs
* fix last link issue

I used the following command to replace all occurrences.

       find . -name '*py' -exec sed -rie 's/^(( *).. SeeAlso::( *))/\2See Also\n\2--------\n\2/g' {} \;

Following a comment of @jbarnoud at #1240 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants