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

Analysis progmeter #892

Merged
merged 10 commits into from
Jul 14, 2016
Merged

Conversation

kain88-de
Copy link
Member

@kain88-de kain88-de commented Jul 7, 2016

Changes made in this Pull Request:

  • Adds progressmeter to AnalysisBase
  • less typying for an analysis

This command will print a progressbar and immediately run the alignment.

trj = AlignTrj(..., quiet=False).run()

Notice that the quiet parameter isn't explicitly added to the AlignTrj init function. Instead I catch it in the kwargs parameter that is passed to the AnalysisBase constructor. This is one of the few cases where I think it's OK to use a kwargs parameter instead of explicit typed parameters. As this allows us to add options to analysisbase that will be automatically picked up by any child-class.

PR Checklist

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

@kain88-de
Copy link
Member Author

@richardjgowers any reason the progmeter wasn't in the base class already?

@richardjgowers
Copy link
Member

No real reason, it would make a good addition for UI

On Thu, 7 Jul 2016, 14:27 Max Linke, notifications@github.com wrote:

@richardjgowers https://github.com/richardjgowers any reason the
progmeter wasn't in the base class already?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#892 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AI0jB83IozzqRwthestCvkjQyqeMfCe7ks5qTP6ugaJpZM4JHE0w
.

@kain88-de kain88-de force-pushed the analysis-progmeter branch 2 times, most recently from a711eaf to 1fe8352 Compare July 8, 2016 07:21
@kain88-de kain88-de changed the title WIP: Analysis progmeter Analysis progmeter Jul 8, 2016
@kain88-de
Copy link
Member Author

This should be done now. The docs could use an example of how to correctly derive from AnalysisBase.

One other thing this breaks user code who have written their own analysis based on AnalysisBase. The new setup requires that the init function is called to generate the _pm Progressmeter variable. I can check if I want a way to write this without breaking user-code, not sure how yet.

@jbarnoud
Copy link
Contributor

jbarnoud commented Jul 8, 2016

I can check if I want a way to write this without breaking user-code, not sure how yet.

self.run could test for self._pm and self._quiet before calling _prepare, therefore knowing if a progress meter is available. It could then, set a dummy self._pm.echo if there is no progress meter.

An other solution would be to test for self._pm at each iteration, or to catch the call failure.

@richardjgowers
Copy link
Member

Or setup the pm in _setup_frames which I think? Everyone uses

On Fri, 8 Jul 2016, 09:03 Jonathan Barnoud, notifications@github.com
wrote:

I can check if I want a way to write this without breaking user-code, not
sure how yet.

self.run could test for self._pm and self._quiet before calling _prepare,
therefore knowing if a progress meter is available. It could then, set a
dummy self._pm.echo if there is no progress meter.

An other solution would be to test for self._pm at each iteration, or to
catch the call failure.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#892 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AI0jBwzoFIJdl4LILJy4alv_jaB3QB5hks5qTgRBgaJpZM4JHE0w
.

@kain88-de
Copy link
Member Author

The old API works and is unit-tested as well.

@kain88-de
Copy link
Member Author

The docs need to be updated about that though.

@kain88-de kain88-de force-pushed the analysis-progmeter branch 3 times, most recently from 7ad1911 to 3c5f09b Compare July 8, 2016 08:36
@richardjgowers
Copy link
Member

LGTM

@kain88-de kain88-de added this to the 0.16.0 milestone Jul 8, 2016
@kain88-de
Copy link
Member Author

kain88-de commented Jul 8, 2016

@richardjgowers also not that it is now required to redefine _single_frame in a childclass to avoid triggering the NotImplementedError

I'll change the docs in the evening and then this can be merged.

@coveralls
Copy link

coveralls commented Jul 8, 2016

Coverage Status

Coverage increased (+0.02%) to 80.403% when pulling 3c5f09b on kain88-de:analysis-progmeter into 5d78f03 on MDAnalysis:develop.

@coveralls
Copy link

coveralls commented Jul 8, 2016

Coverage Status

Coverage increased (+0.008%) to 80.387% when pulling 3c5f09b on kain88-de:analysis-progmeter into 5d78f03 on MDAnalysis:develop.

@coveralls
Copy link

coveralls commented Jul 8, 2016

Coverage Status

Coverage increased (+0.02%) to 80.403% when pulling 3c5f09b on kain88-de:analysis-progmeter into 5d78f03 on MDAnalysis:develop.

@coveralls
Copy link

coveralls commented Jul 8, 2016

Coverage Status

Coverage increased (+0.008%) to 80.387% when pulling 3c5f09b on kain88-de:analysis-progmeter into 5d78f03 on MDAnalysis:develop.

@kain88-de kain88-de force-pushed the analysis-progmeter branch from 3c5f09b to f2d8d36 Compare July 11, 2016 14:16
@kain88-de
Copy link
Member Author

Doc strings updated. Please have a look if I misspelled anything.

Enhancements

* All classes derived from 'AnalysisBase' now display a ProgressMeter
with 'quiet=False'
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be when quiet=True?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is correct. You are thinking of verbose=True which is the normal way people turn on logging and output. For some reason MDAnalysis has decided in the past to rather go with the word quiet and there False would say the function can print and log stuff for me,

Copy link
Member

Choose a reason for hiding this comment

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

Ah right yeah, it's backwards to what I expect, ok cool

This also adds an initialization function to AnalysisBase. This is done
now because we need to do more then just to setup the iteration.
Returning an axis object is considered to be better since the user is
able to adjust the plot by himself if he wishes to do so.
@kain88-de kain88-de force-pushed the analysis-progmeter branch from f2d8d36 to b08dcac Compare July 11, 2016 14:25
Since user code might already exist we keep make sure the old API still
works as well.
@kain88-de kain88-de force-pushed the analysis-progmeter branch from b08dcac to ffdf479 Compare July 11, 2016 14:28
@coveralls
Copy link

coveralls commented Jul 11, 2016

Coverage Status

Coverage increased (+0.02%) to 80.995% when pulling ffdf479 on kain88-de:analysis-progmeter into 4dcf071 on MDAnalysis:develop.

@coveralls
Copy link

coveralls commented Jul 11, 2016

Coverage Status

Coverage increased (+0.02%) to 80.995% when pulling ffdf479 on kain88-de:analysis-progmeter into 4dcf071 on MDAnalysis:develop.

@coveralls
Copy link

coveralls commented Jul 11, 2016

Coverage Status

Coverage increased (+0.02%) to 80.995% when pulling ffdf479 on kain88-de:analysis-progmeter into 4dcf071 on MDAnalysis:develop.

Afterwards the new analysis can be run like this.

.. code-block:: python
na = NewAnalysis(u.select_atoms('name CA'), 35).run()
Copy link
Member

Choose a reason for hiding this comment

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

I like this.

@orbeckst orbeckst mentioned this pull request Jul 12, 2016
2 tasks
@richardjgowers richardjgowers merged commit 054a9de into MDAnalysis:develop Jul 14, 2016
jdetle pushed a commit to jdetle/mdanalysis that referenced this pull request Aug 14, 2016
* PEP8 Changes

* Add progressmeter to AnalysisBase

This also adds an initialization function to AnalysisBase. This is done
now because we need to do more then just to setup the iteration.

* Adopt Contacts

* Follow best practices for matplotlib

Returning an axis object is considered to be better since the user is
able to adjust the plot by himself if he wishes to do so.

* Addopt Persistencelength

* Adopt InterRDF

* Adopt LinearDensity

* Adopt AlignTrj

* update changelog

* Ensure old API still works

Since user code might already exist we keep make sure the old API still
works as well.
@kain88-de kain88-de deleted the analysis-progmeter branch August 16, 2016 14:46
abiedermann pushed a commit to abiedermann/mdanalysis that referenced this pull request Oct 26, 2016
* PEP8 Changes

* Add progressmeter to AnalysisBase

This also adds an initialization function to AnalysisBase. This is done
now because we need to do more then just to setup the iteration.

* Adopt Contacts

* Follow best practices for matplotlib

Returning an axis object is considered to be better since the user is
able to adjust the plot by himself if he wishes to do so.

* Addopt Persistencelength

* Adopt InterRDF

* Adopt LinearDensity

* Adopt AlignTrj

* update changelog

* Ensure old API still works

Since user code might already exist we keep make sure the old API still
works as well.
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.

5 participants