-
Notifications
You must be signed in to change notification settings - Fork 663
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
Parameters not saved in Analysis classes #2206
Comments
Yeah we used to save them on |
Yes. I would just add a simple test in |
I don't think we should save them. That's a left over when we set them in init. When providing parameters to run I would expect that they only apply to this invocation. |
On the one hand I could imagine that sometimes its useful to access this information i.e. at what frame the analysis started. On the other the user already put the information in so maybe its superfluous. |
I agree. Since the
IMHO it is. |
@zemanj I'm also fine with not storing them if this consistent with what is in the documentation. The total number of analysed frames is saved in any case. But this means to drop the old code completly, right? |
Yes, any old code that stores this information should go away. EDIT: 2020-02-05: |
I see. I quickly checked the usage of |
@PicoCentauri I think verbose is deprecated, it just needs finally removing (eventually). It's frustrating, but the idea is that old scripts (which use verbose) shouldn't break overnight because people have updated. I think we're planning on ripping out most of the tagged deprecations for the 1.0 release. WRT start/stop/step, these parameters should be saved in the |
Under which circumstances is it useful to safe start/stop/step? I don't think that there's an expectation that As long as the result contains e.g. the times or the frame numbers for a time series calculation, this should be fine. Or am I missing something? |
@orbeckst I run some analysis on frames 1-10, pickle the Analysis class object (containing the results), unpickle it a month later and don't know what frames it was ran on? Or more generally, it'd be nice if the object had full provenance of the results? |
I don't like pickling analysis class objects as a form of data storage – that's just abuse of the pickle format. I wouldn't want to encourage this approach. For timeseries it is eas(ier) to see what data you used. For anything that averages or does statistics this is harder and their I can see a valid reason for storing a metadata dict with, e.g., number of frames analyzed etc. because you would need to report this in a paper. But then this can be up to the individual class to do it. Thinking about it, you summarized it succinctly
|
Ok, then I think this issue is solved by recommending in the |
Okay I’m fine with storing the information in the results attribute. Unfortunately, only changing the docs this will not resolve the issue I think. We still have to change the code in such a way that only the current parameters of the .run method are used. I also don’t see an „easy“ and clear way for an individual class to get acces to the information for saving start/stop/step in the results section if its not stored in object itself... |
I think you ever only need to store anything if the class does not store the frames or times. In my opinion, the default should be that start/stop/step are not stored. If a class has a special need to store this information then it has to store it |
In pre- or postprocessing, that will only be possible with an awful introspection hack using Anyway, I don't see the value of gathering frame information during executions of
|
Maybe we do need to change something because @PicoCentauri's
|
Ok, so an update on this. In part because we've removed setting Currently the way it seems to behave is that So in version 0.21.1 you'd get: import MDAnalysis as mda
from MDAnalysis.analysis.lineardensity import LinearDensity
from MDAnalysisTests.datafiles import PSF_TRICLINIC, DCD_TRICLINIC
u = mda.Universe(PSF_TRICLINIC, DCD_TRICLINIC)
ldens = LinearDensity(u.atoms, verbose=True)
ldens.run(start=0, stop=10) # pm on
print(ldens.start, ldens.stop) # 0 10
ldens.run(start=0, stop=5, verbose=False) # pm on
print(ldens.start, ldens.stop) # 0 10
ldens2 = LinearDensity(u.atoms, verbose=True)
ldens2.run(start=0, stop=5, verbose=False) # pm on
print(ldens2.start, ldens2.stop) # 0 5
ldens.run(start=0, stop=10) # pm on
print(ldens2.start, ldens2.stop) # 0 5 And in the current develop version you get: import MDAnalysis as mda
from MDAnalysis.analysis.lineardensity import LinearDensity
from MDAnalysisTests.datafiles import PSF_TRICLINIC, DCD_TRICLINIC
u = mda.Universe(PSF_TRICLINIC, DCD_TRICLINIC)
ldens = LinearDensity(u.atoms, verbose=True)
ldens.run(start=0, stop=10) # pm on
print(ldens.start, ldens.stop) # 0 10
ldens.run(start=0, stop=5, verbose=False) # pm off
print(ldens.start, ldens.stop) # 0 5
ldens2 = LinearDensity(u.atoms, verbose=True)
ldens2.run(start=0, stop=5, verbose=False) # pm off
print(ldens2.start, ldens2.stop) # 0 5
ldens.run(start=0, stop=10) # pm on
print(ldens2.start, ldens2.stop) # 0 10 Based on these changes, I'm not sure where everyone's opinions on this issue stand. We could switch to @zemanj's proposal: #2206 (comment), making "private" variables, but I'm not sure if it's still necessary. We'd probably want a decision here prior to v1.0, so pinging @MDAnalysis/coredevs here. |
The current (develop, second example) behavior looks sensible to me. That's exactly what it should be doing, shouldn't it? The With the current AnalysisBase, we store start/stop/step mdanalysis/package/MDAnalysis/analysis/base.py Lines 141 to 144 in 8d7d77f
results can access self in _conclude() .
I think we can just close this issue as fixed by #2505 and the changes to verbose... but I am feeling that I am overlooking something obvious. Additional 👀 are welcome! (I kind of like #2206 (comment) to make |
Nobody seems to think that anything else needs doing here, so I am closing. |
In all analysis classes the parameters
start
,stop
,step
andverbose
are not saved if they are changed after the object was run once.After looking into the code I found that for the
start
,stop
andstep
parameters this is an issue due to the fix of the old deprecated syntax. For theverbose
one just have to save this in the_verbose
attribute of the object. All these things are easy to fix and I could provide a patch.Code to reproduce the behavior
Currently version of MDAnalysis
Python 3.6, mda 0.19.3, MacOS
The text was updated successfully, but these errors were encountered: