Skip to content

Commit

Permalink
Added functionality to keep track of deprecated actions in syntax file
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Aneurin Tribello authored and Gareth Aneurin Tribello committed Nov 26, 2024
1 parent 6c46bb3 commit 3be870e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/cltools/GenJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ int GenJson::main(FILE* in, FILE*out,Communicator& pc) {
// Now output keyword information
Keywords keys; actionRegister().getKeywords( action_names[i], keys );
std::cout<<" \"displayname\" : \""<<keys.getDisplayName()<<"\",\n";
// This is used for noting actions that have been deprecated
std::string replacement = keys.getReplacementAction();
if( replacement!="none" ) {
bool found=false;

Check notice

Code scanning / CodeQL

Declaration hides variable Note

Variable found hides another variable of the same name (on
line 117
).
for(unsigned j=0; j<action_names.size(); ++j) {
if( action_names[j]==replacement ) { found=true; break; }
}
if( !found ) error("could not find action named " + replacement + " that is supposed to be used to replace " + action_names[i] );
}
std::cout<<" \"replacement\" : \""<<replacement<<"\",\n";
std::cout<<" \"syntax\" : {"<<std::endl;
for(unsigned j=0; j<keys.size(); ++j) {
std::string defa = "", desc = keys.getKeywordDescription( keys.getKeyword(j) );
Expand Down
7 changes: 4 additions & 3 deletions src/core/ActionRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ std::unique_ptr<Action> ActionRegister::create(const std::vector<void*> & images

auto content=get(images,ao.line[0]);
Keywords keys; keys.thisactname = ao.line[0];
content.keys(keys);
keys.replaceaction = "none"; content.keys(keys);
ActionOptions nao( ao,keys );
auto fullPath=getFullPath(images,ao.line[0]);
nao.setFullPath(fullPath);
Expand Down Expand Up @@ -79,7 +79,7 @@ bool ActionRegister::printTemplate(const std::string& action, bool include_optio
//no need to insert the try/catch block: check will ensure that action is known
if( check(action) ) {
Keywords keys; keys.thisactname = action;
get(action).keys(keys);
keys.replaceaction = "none"; get(action).keys(keys);
keys.print_template(action, include_optional);
return true;
} else {
Expand All @@ -101,14 +101,15 @@ bool ActionRegister::getKeywords(const std::string& action, Keywords& keys) {
//no need to insert the try/catch block: check will ensure that action is known
if(check(action)) {
keys.thisactname = action;
keys.replaceaction = "none";
get(action).keys(keys);
return true;
}
return false;
}

void ActionRegister::getKeywords(const std::vector<void*> & images, const std::string& action, Keywords& keys) {
auto content=get(images,action); keys.thisactname = action; content.keys(keys);
auto content=get(images,action); keys.thisactname = action; keys.replaceaction = "none"; content.keys(keys);
}

}
1 change: 1 addition & 0 deletions src/multicolvar/DumpMultiColvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(DumpMultiColvar,"DUMPMULTICOLVAR")

void DumpMultiColvar::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.setDeprecated("DUMPATOMS");
keys.add("compulsory","DATA","the vector you wish to transform");
keys.add("compulsory","FILE","the file that you would like to output the data to");
keys.remove("HAS_VALUES"); keys.needsAction("DUMPATOMS");
Expand Down
1 change: 1 addition & 0 deletions src/multicolvar/MFilterLess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(MFilterLess,"MFILTER_LESS")

void MFilterLess::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.setDeprecated("LESS_THAN");
keys.add("compulsory","DATA","the vector you wish to transform");
keys.add("compulsory","SWITCH","the switching function that transform");
keys.setValueDescription("vector","a vector that has the same dimension as the input vector with elements equal to one if the corresponding component of the vector is less than a tolerance and zero otherwise");
Expand Down
1 change: 1 addition & 0 deletions src/multicolvar/MFilterMore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(MFilterMore,"MFILTER_MORE")

void MFilterMore::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.setDeprecated("MORE_THAN");
keys.add("compulsory","DATA","the vector you wish to transform");
keys.add("compulsory","SWITCH","the switching function that transform");
keys.addFlag("LOWMEM",false,"this flag does nothing and is present only to ensure back-compatibility");
Expand Down
1 change: 1 addition & 0 deletions src/multicolvar/UWalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ PLUMED_REGISTER_ACTION(UWalls,"UWALLS")

void UWalls::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.setDeprecated("UPPER_WALLS");
keys.add("compulsory","DATA","the values you want to restrain");
keys.add("compulsory","AT","the radius of the sphere");
keys.add("compulsory","KAPPA","the force constant for the wall. The k_i in the expression for a wall.");
Expand Down
9 changes: 9 additions & 0 deletions src/tools/Keywords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,13 @@ std::string Keywords::getDisplayName() const {
return thisactname;
}

void Keywords::setDeprecated( const std::string& name ) {
replaceaction = name;
}

std::string Keywords::getReplacementAction() const {
return replaceaction;
}


}
6 changes: 6 additions & 0 deletions src/tools/Keywords.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Keywords {
bool isatoms;
/// The name of the action that has this set of keywords
std::string thisactname;
/// The action to use in place of this deprecated action
std::string replaceaction;
/// The names of the allowed keywords
std::vector<std::string> keys;
/// The names of the reserved keywords
Expand Down Expand Up @@ -217,6 +219,10 @@ class Keywords {
std::string getDisplayName() const ;
/// Set the display name
void setDisplayName( const std::string& name );
/// Get the action that should be used to replace this one if action has been deprecated
std::string getReplacementAction() const ;
/// Note that this action has been deprecated
void setDeprecated( const std::string& name );
};

}
Expand Down

1 comment on commit 3be870e

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

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

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/CONVERT_TO_FES.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/DUMPCUBE.tmp
Found broken examples in automatic/DUMPGRID.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/HISTOGRAM.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/METATENSOR.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/REWEIGHT_BIAS.tmp
Found broken examples in automatic/REWEIGHT_METAD.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_LINEAR_PROJ.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_MAHA_DIST.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_HISTOGRAM.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.