-
Notifications
You must be signed in to change notification settings - Fork 189
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
Rewrite non-bonded interactions as script interface objects #4558
Rewrite non-bonded interactions as script interface objects #4558
Conversation
c4b2640
to
29ef411
Compare
29ef411
to
a9f5a24
Compare
e4abb5a
to
302ffc4
Compare
302ffc4
to
53368cc
Compare
Interactions can now be reset. Skip inactive interactions when reloading from a checkpoint file to avoid triggering range checks. Re-introduce the original cutoff range checks.
3a3c2ff
to
83a4c98
Compare
83a4c98
to
8078029
Compare
std::swap(::old_nonbonded_ia_params, new_params_); | ||
std::swap(::nonbonded_ia_params, new_params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need a swap here? Probably a move-assignment would be more expressive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked it up and apparently, a swap was the only way to do a cheap move for std::vector
back in C++03. I'll change it to a std::move
.
@@ -205,6 +205,85 @@ cdef class NonBondedInteraction: | |||
raise Exception( | |||
"Subclasses of NonBondedInteraction must define the required_keys() method.") | |||
|
|||
|
|||
class NewNonBondedInteraction(ScriptInterfaceHelper): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we ever tested the python abstract base class to work together with the ScriptInterface? Probably a lot of the methods would be perfect candidates for @abc.abstractmethod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it wasn't used before because everything was in Cython, and abstract classes don't work out-of-the-box in Cython:
Error compiling Cython file:
------------------------------------------------------------
...
import abc
cdef class HydrodynamicInteraction(FluidActor, metaclass=abc.ABCMeta):
^
------------------------------------------------------------
/work/jgrad/es/src/python/espressomd/lb.pyx:172:69: C classes cannot take keyword bases.
or
Error compiling Cython file:
------------------------------------------------------------
...
import abc
cdef class FluidActor(abc.ABC):
^
------------------------------------------------------------
/work/jgrad/es/src/python/espressomd/lb.pyx:34:25: First base of 'FluidActor' is not an extension type
The usual workaround was to declare a python abstract class and use it to register the cdef class to make it abstract, which is less elegant and error-prone. Now that the module is in Python, we can use ABC metaclasses.
Co-authored-by: Alexander Reinauer <areinauer@icp.uni-stuttgart.de>
Fixes #4555 and fixes #4569
Description of changes:
interaction.pyx
to Python fileinteraction.py
set_params()
method now raises an error if required arguments are not providedset_params()
is broken #4569