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

Major improvements to loops, misc other fixes #789

Merged
merged 167 commits into from
Jan 31, 2020
Merged

Conversation

drroe
Copy link
Contributor

@drroe drroe commented Jan 10, 2020

This is a pretty big PR that provides major improvements to the utility of loops, as well as other changes under the hood:

  • for loops have been fixed so that nested loops can make use of variables, including outer loop variables. For example, the following will now work:
set maxval = 4
set maxval1 = 3
set val = 0
for i=1;i<$maxval;i++ myval=0;myval+=10
  startj = $i + 1
  for j=$startj;j<=$maxval1;j++
    distance d$\$j @$i @$j out nested.agr
  done
done

This will result in 3 distance commands calculating d12, d13, and d23.

  • Integer for loops now increment their final value, consistent with how for loops work everywhere else. Non-integer for loops retain previous behavior (final value of variable is last value of the loop).
  • A new for loop, datasetblocks is introduced that allows looping over subsets (blocks) of fixed size of a data set, or subsets of increasing size (cumulative).
[help for datasetblocks]
	<var> datasetblocks <set> blocksize <#> [blockoffset <#>]
	[cumulative [firstblock <#>]]

For example, given a data set containing distances named EndToEndAll, one can loop over subsets of the data set in blocks of size 10 via:

for DS datasetblocks EndToEndAll blocksize 10 i=1;i++

The created subsets are regular data sets and each iteration can be referred to via the loop variable ($DS in this example). This will enable improved error analysis for users.

  • for loop variables are stored in the master data set list as "string" variables. This makes the code involving "control blocks" like for loops easier and will facilitate adding new block types in the future (like if). I was able to remove several classes and consolidate functionality because of this. For loop subtypes have their own classes now, which makes things easier to read.
  • Address RPN calculator mistakes variables as functions if variable starts with function name #744.
  • Direct copies of certain sets are now allowed via = (e.g. set2 = set1). If copy is not supported, the old behavior (renaming) is used.
  • Online help on data set math now available via help Math.
  • Vector data sets have now been split into "with origins" and "without origins". This makes a lot of the code under the hood simpler. What this means for output is that vectors with no origins (e.g. center of mass vectors from the vector command, etc) Will no longer have a "blank" origin (i.e. 0, 0, 0) printed. Internally this makes things like resizing and copying easier. This should probably be done for other data sets down the road (like covariance matrices etc). This was reverted to make sure pytraj does not break.
  • Manual updated and tests added.

Daniel R. Roe and others added 30 commits December 17, 2019 13:26
@drroe drroe changed the title Major improvements to loops, changes to vector data sets, misc other fixes Major improvements to loops, misc other fixes Jan 31, 2020
@drroe
Copy link
Contributor Author

drroe commented Jan 31, 2020

I'm giving up on the vector data set stuff for now. I'll revisit it in the future I guess.

@lgtm-com
Copy link

lgtm-com bot commented Jan 31, 2020

This pull request fixes 1 alert when merging 6c7b929 into b836078 - view on LGTM.com

fixed alerts:

  • 1 for FIXME comment

@drroe
Copy link
Contributor Author

drroe commented Jan 31, 2020

Appveyor failure is because ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.3.zip is no longer valid. Will update in a future PR.

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.

3 participants