-
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
ParticleSlice lacks support for particle properties #958
Comments
I was going to implement this. However, as we now moved to sphix documentation, there is a catch. If this is implemented as suggested above, the individual properties of
This would allow for docstrings, but there would still be a lot of nearly identical code. It would also not be automatically synced with the properties of ParticleHandle My personal preference is 1. |
I'm in favor of 1 |
Can docstrings be set programmatically? I seem to recall that @fweik ran into an issue there, but since this is Python, there must be a way to do it. |
No, they can not. The reason is that they are typically read on module load. |
Are you sure? A (simplified) test works: docstr.py:
test_docstr.py:
|
@mkuron Does this also work in Sphinx? |
Doesn't Sphinx just import all modules and use introspection to read the docstrings? I'll test it if you tell me how I can run Sphinx on a single Python file. |
One can probably popoulate the docstrings at module load. class C: def gen_method(name): for mname in "a","b","c": c=C() |
Your indentation got broken by GitHub, I've cleaned it up:
Actually, since properties are just special kinds of methods, you can add them just as easily:
|
So that means, we can populate the ParticleSlice class at module load time
with auto-generated properties, and sphinx will probably scan it.
|
This should be resolved by a generic implementation of setattr and getattr in the ParticleSlice class
If ParticleSlice does not have an implementation for the given property,
The getter and seetter should call the property with the given attribute name of the ParticleHandle class for all particles in the slice.
The getter additionally has to determine the number of values for the particle property by obtaining the result for the first particle in the slice and then creating the approprate numpy array.
Those properties of ParticleSlice already there, which only call properties of ParticleHandle should be removed, because it's lots of copied code.
The properties of ParticleSlice directly calling core methods should probably stay, because they might offer better performance.
The text was updated successfully, but these errors were encountered: