Skip to content
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

Implement == for cdef class LBNode and LBSlice #4204 #4268

Merged
merged 10 commits into from
Jun 3, 2021
Merged

Implement == for cdef class LBNode and LBSlice #4204 #4268

merged 10 commits into from
Jun 3, 2021

Conversation

stekajack
Copy link
Contributor

@stekajack stekajack commented May 28, 2021

Resolves #4204

Description of changes:

  • implemented eq() for LBFluidRoutines() . Now logical lbf[index, index, index] == lbf[index, index, index] give expected results.

  • modified default hash() so that the comparisons are done based on node indices rather than the name attribute. This is done because hash will give different names to pointers so 2 different handles to the same node would be considered not equal. Now they are considered equal so that set(list_of_nodes, also_list_of_nodes) is possible and cannot have duplicate entries now.

  • implemented iter() for LBSlice class. now given a slice object, one can directly access nodes in any iteration context (using generator functionality for this). Therefore LBSlice object can now be transformed in to for example a list of nodes. This enables smth like set(list(LBSlice), list_of_nodes) to work correctly.

  • However set(LBSice, list_of_nodes) will NOT work! This is deliberate because LBSlice as implemented, cannot in general be used as a node and as such it made more sense to first ask for an explicit conversion to a iterable_of_nodes before doing logical comparisons.

@RudolfWeeber
Copy link
Contributor

Thanks. The code looks good. Could you please also add test functions in testsuite/python/lb.py testing the new methosd:
For the iteration, you could, e.g., compare the index attribute from the slice directly and from the loop variable of an iteration

@stekajack
Copy link
Contributor Author

Thanks. The code looks good. Could you please also add test functions in testsuite/python/lb.py testing the new methosd:
For the iteration, you could, e.g., compare the index attribute from the slice directly and from the loop variable of an iteration

I hope this encompasses well what you had in mind. In lb_slice.py test I moved the lb_fluid handle outside of the method, so now test methods access the fluid as a class attribute, so I don't have to teardown.

@RudolfWeeber RudolfWeeber added the automerge Merge with kodiak label Jun 3, 2021
@RudolfWeeber
Copy link
Contributor

Yes, that's what I had in mind. Thanks.

@kodiakhq kodiakhq bot merged commit 6369253 into espressomd:python Jun 3, 2021
@jngrad jngrad added the Python label Jun 3, 2021
@jngrad jngrad added this to the Espresso 4.2 milestone Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge with kodiak Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement == for cdef class LBNode and LBSlice
3 participants