Skip to content

Commit

Permalink
Merge branch 'v2.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovanniBussi committed Oct 14, 2024
2 parents 93e45ce + b0ffcb5 commit 9f0d731
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGES/v2.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ Before switching to version 2.10, users are invited to carefully read the follow
- You can use ActionShortcut to create complex inputs from a simpler initial input. The nest will then allow users to explore these more complex inputs.
- You can use \ref show_graph to create diagrams showing how values and forces are passed between the various actions in your input files.
- Complete refactor of SwitchingFunction.cpp and SwitchingFunction.h, now adding new switching function is more straightforward and all the "book-keeping" can be done within a single class
- Python (cython) wrappers now use `nogil`. This should facilitate integration with Python. See https://github.com/plumed/plumed2/pull/1129#issuecomment-2410867829 (thanks to Guillaume Fraux).
22 changes: 12 additions & 10 deletions python/cplumed.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cdef extern from "Plumed.h":
size_t nelem
size_t* shape
size_t flags
# ignore other
# ignore other
ctypedef struct plumed_nothrow_handler:
void* ptr
void (*handler)(void*,int,const char*,const void*)
Expand All @@ -46,12 +46,14 @@ cdef extern from "Plumed.h":
plumed_error_filesystem_path path1
plumed_error_filesystem_path path2
# ignore other members
void plumed_cmd_safe_nothrow(plumed p,const char*key,plumed_safeptr safe,plumed_nothrow_handler nothrow)
void plumed_error_set(void*ptr,int code,const char*what,const void* opt)
void plumed_error_init(plumed_error* error)
void plumed_error_finalize(plumed_error error)
plumed plumed_create()
plumed plumed_create_dlopen(const char*path)
plumed plumed_create_invalid()
void plumed_finalize(plumed p)
int plumed_valid(plumed p)
# C functions declared as nogil
# see https://github.com/plumed/plumed2/pull/1129#issuecomment-2410867829
void plumed_cmd_safe_nothrow(plumed p,const char*key,plumed_safeptr safe,plumed_nothrow_handler nothrow) nogil
void plumed_error_set(void*ptr,int code,const char*what,const void* opt) nogil
void plumed_error_init(plumed_error* error) nogil
void plumed_error_finalize(plumed_error error) nogil
plumed plumed_create() nogil
plumed plumed_create_dlopen(const char*path) nogil
plumed plumed_create_invalid() nogil
void plumed_finalize(plumed p) nogil
int plumed_valid(plumed p) nogil
20 changes: 10 additions & 10 deletions python/plumed.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import sys
import warnings
import types

import cython
from cython.operator import dereference

if sys.version_info < (3,):
Expand Down Expand Up @@ -185,7 +186,9 @@ cdef class Plumed:
cplumed.plumed_error_init(&error)
nothrow.ptr=&error
nothrow.handler=cplumed.plumed_error_set
cplumed.plumed_cmd_safe_nothrow(self.c_plumed,ckey,safe,nothrow)
# see https://github.com/plumed/plumed2/pull/1129#issuecomment-2410867829
with cython.nogil():
cplumed.plumed_cmd_safe_nothrow(self.c_plumed,ckey,safe,nothrow)
if(error.code):
try:
self.raise_exception(error)
Expand Down Expand Up @@ -507,7 +510,7 @@ def read_as_pandas(file_or_path,enable_constants=True,enable_conversion=True,ker
convert=_build_convert_function(kernel)
# if necessary, set convert_all
if enable_conversion=='all': convert_all=convert

# handle file
file_or_path=_fix_file(file_or_path,'rt')

Expand Down Expand Up @@ -588,7 +591,7 @@ def write_pandas(df,file_or_path=None):
colvar=plumed.read_as_colvar("COLVAR")
colvar["distance"]=colvar["distance"]*2
plumed.write_pandas(colvar)
"""
# importing pandas is pretty slow, so we only do it when needed
import pandas as pd
Expand Down Expand Up @@ -787,7 +790,7 @@ def _readvimdict(plumedroot=None,kernel=None):
# read dictionary
for opt in plumedDictionary[action]:
# skip label (it is added automatically)
if opt["menu"] != "(label)":
if opt["menu"] != "(label)":
ret[action][re.sub("=$","",opt["word"])]=opt["menu"]
return ret,doc

Expand Down Expand Up @@ -916,15 +919,15 @@ def _format_at_one_residue(builder,name,residue,chain):
return "@" + name + "-" + chain + str(residue)
else:
assert False

def _format_at_one_chain(builder,name,residue,chain):
res=""
if hasattr(residue,'__iter__') and not isinstance(residue,str):
for x in residue:
res+=builder._separator + _format_at_one_residue(builder,name,x,chain)
else:
res+=builder._separator + _format_at_one_residue(builder,name,residue,chain)

return res

def _format_at(builder,name,residue,chain=""):
Expand Down Expand Up @@ -1074,7 +1077,7 @@ def _format_anything(builder,name,arg):
ret=""
if name == "verbatim":
ret+=_format_verbatim(builder,arg)
elif isinstance(arg,bool) :
elif isinstance(arg,bool) :
ret+=_format_flag(builder,name,arg)
elif isinstance(arg,_numbered):
ret+=_format_numbered(builder,name,arg)
Expand Down Expand Up @@ -1236,6 +1239,3 @@ class InputBuilder:
Accepts a list/tuple.
"""
return _replicas(arg)



1 comment on commit 9f0d731

@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.