-
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
Implement == for cdef class LBNode and LBSlice #4204 #4268
Conversation
Thanks. The code looks good. Could you please also add test functions in testsuite/python/lb.py testing the new methosd: |
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. |
Yes, that's what I had in mind. Thanks. |
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.