-
Notifications
You must be signed in to change notification settings - Fork 188
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
Refactoring the PidObservable
and ProfileObservable
framework
#3599
Comments
Concerning the last point, I tried returning the histogram edges from the core observables, but I can't get the @fweik how do I: |
You can not get a |
So is the discussion about the overall observables design finished? Otherwise I would avoid thinking about implementation details. |
@jngrad, if the @KaiSzuttor lets' have that discussion separately, but I agree we should have it now. I think the earlier designs are discussed, the better. Ideally before implementation starts. |
@fweik I finally managed to get the core to send a vector of vectors back to Python using the recursive Variant. Let's see if I can figure out how to pass a list of lists from Python to the core... The frustration with the The @KaiSzuttor the particle type-based observable is causing more trouble than it is worth, let's drop it. |
Fixes partially #3599 Description of changes: - convert `CylindricalProfile` to `CylindricalProfileObservable` to make the observables framework homogeneous - for all four `*ProfileObservable` classes, add a method `edges()` to calculate the coordinates of the bins, producing the same output as `numpy.histogramdd()` - fix broken LB sample
Folllow-up to #3599 Description of changes: - replaced the RDF analysis tool by an RDF observable - removed the particle position storage mechanism from `statistics.cpp` - documented observable `TimeSeries`
Description of changes: - remove code duplication in profile observables - unify `ProfileObservable` and `CylindricalProfileObservable` classes (partial fix for #3599)
We currently have the following observable framework:
The cartesian and cylindrical observables have a completely different inheritance diagram despite doing the same thing with different names (attributes
x, y, z
becomer, phi, z
). There is also un-necessary code duplication in the script interface, where each core class must be re-declared withAutoParameters
. Finally, adding another coordinate system (e.g.SphericalProfile
for RDF) or another particle trait (e.g. particletype
instead ofid
for RDF) leads to a combinatorial growth of the number of core classes and script interface classes.We could refactor these classes to take a template argument that selects the coordinate system (Cartesian, Cylindrical, Spherical) and add a
PtypeObservable
:This was attempted in branch jngrad/espresso:refactor-analysis-rdf4. This new observable framework is now more easily extensible, however the introduction of
PtypeObservable
lead to a lot of code duplication in the script interface (PtypeObservable
is essentially a copy-paste ofPidObservable
). I don't think it's the right solution. This un-necessary code duplication could probably be avoided by making coordinate system observable classes completely independent from theObservable
class, but the constraints of theAutoParameters
framework makes script interface class design a little bit unpredictable. For example, the cylindrical coordinate system requires an extra axis argument compared to spherical and cartesian coordinates, and I couldn't figure out a working solution for a variadic template ctor in anAutoParameters
class. It also doesn't seem possible to haveAutoParameters
classes forward an incomplete list of arguments to a ctor containing only optional parameters.Perhaps the solution here is to provide a unified
PtraitObservable
that replacesPidObservable
andPtypeObservable
, with ctorPtraitObservable(std::vector<int> ids={}, std::vector<int> types={}, ...)
such that we can instantiate it with either particle ids or particle types (the ctor would convert the types to ids). In that case, any future plan for a particle selection feature based on other criteria would need to be implemented at the Python level (except for filtering out virtual particles, see #3154).Another issue that is blocking the conversion of RDF to an observable is that RDF takes two lists of particle ids as argument. I don't see an easy way to extend our current framework to take two lists instead of one. One could write a Python ctor that automatically flattens the two arrays into a single one with a sentinel value as separator, and have the core observable un-flatten the array. This would probably work, despite being inelegant. We cannot write an RDF class directly and have it work in the script interface, because we can only register classes that inherit from a base class where all attributes are already bound via
AutoParameters
. This means that to write an RDF class, one has to write a dummy parent class (e.g.TypesObservable
in jngrad/espresso:refactor-rdf-4) in both the core and script interface, which causes too much code duplication in the script interface.Almost orthogonal to that is the question of returning the range of values on the axes of a
ProfileObservable
. At the moment it is the user's responsibility to come up with the correct Python code for each observable. This should be done at the core level.The text was updated successfully, but these errors were encountered: