-
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
discussion: remove id exposure from interface #3992
Comments
from the user perspective the system state should not change if two particles are exchanged. the particle id is an implementation detail. this would also remove the odd slice index to id coupling which does not make sense to me |
import numpy as np
import espressomd
system = espressomd.System(box_l=3*[10])
for i in range(3):
system.part.add(pos=np.random.random(3) * system.box_l)
system.part[1].remove()
system.part[:].pos # returns 2 elements
system.part[1].pos # RuntimeError: Particle node for id 1 not found |
if somebody knows python, this is a very surprising behavior since there is no slice with gaps in the python world. i'd really prefer not to hold onto this slicing syntax. |
While I agree with you in principal, I think from a practical point of view I think this is unwise: It will break most user scripts, without there being an obvious reason for the break. What is your cost/benefit analysis for this? I also think that there are more (This think this also smells of the Potemkin Pattern) |
I obviouly did not do a complete analysis, that's why I wanted to have a lively discussion in this issue. Generally I think that chamging this slicing interface could lead to more readable simulation scripts. I'm thinking of giving groups of filtered particles a name for further reuse, e.g.. |
First step is to change the text and examples in `doc/sphinx/part.rst` to make it clear that ids don’t hve to be specified and that the references returned by `system.part.add()` should be used
|
On a general note, I have come to think that the Potemkin Pattern is a much bigger design issue than we used to think. The problem with emulating a different API in the interface than in the core is that this always encodes semantic information into the python interface (as opposed to merely syntactic information), and as such is always problematic. If you think about this, the purpose of such a construction is actually coupling... |
As already mentioned in PR #4058, there are for now still some places, especially in the |
of course we would need to have typebased observables instead of id based |
After #4402, bond lists and particle-based observables are the last consumers of the particle ids in the python interface. |
By now, to my understanding, only the particle observables are left. This can be addressed on the Python level. |
No description provided.
The text was updated successfully, but these errors were encountered: