-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
WIP: improved Geometry.sort, for #191 #197
Conversation
species/groups to come |
Codecov Report
@@ Coverage Diff @@
## master #197 +/- ##
==========================================
+ Coverage 85.23% 85.24% +<.01%
==========================================
Files 120 120
Lines 19130 19338 +208
==========================================
+ Hits 16306 16484 +178
- Misses 2824 2854 +30
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I have only some minor comments on the documentation.
sisl/geometry.py
Outdated
A too high `atol` may have unexpected side-effects. This is because of the way | ||
the sorting algorithm splits the sections for nested sorting. | ||
So for coordinates with a continuous displacement the sorting may break and group | ||
a large range into 1 group. | ||
|
||
>>> a = np.arange(5) * 0.1 | ||
>>> (np.diff(a) > 0.05).nonzero()[0] | ||
[0, 1, 2, 3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I do not follow this example with the a
array. Can you be more explicit how it relates to the atol
discussion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to add a more reasonable explanation...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tfrederiksen does it make sense now?
Note that in your opening comment this line
has a clash of the repeated argument |
Could you have a look again, the For coordinates |
Why is Also, with |
This is because I always append an integer to keywords (so users can do what you do ;))
Yes, this is by design. Any keyword has precedence until changed. The updated documentation should reflect this. So one have to disable it again, if one does not want this. |
Very cool! Now I notice that indeed you write "sorting for all subsequent sorting methods" in the documentation. So the user can also do this in a script |
Yes :) |
@tfrederiksen I have now added the remaining sortings, currently you cannot do the complicated groupings on the CLI, then one have to parse to a tuple... You can however do the simple stuff, like doing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful!
This change allows very complicated sort calls. All sorts are now chained (much like lexsort). One can now do geom.sort(axis=0, lattice=0, axis1=1) to first sort Cartesian x, then for each subgroup in this sort according to first lattice vector, then for each subgroup sort according to Cartesian y. Note how axis1 allows numeric flags to allow multiple same sorting algorithms for the same (to achieve different order of sort). One can also add ascending/descending geom.sort(axis=0, ascend=False, lattice=1, ascend=True, axis=1) to ascend-sort x, descend-sort fa, ascend-sort y. Also added preliminary support for sort in sgeom. Signed-off-by: Nick Papior <nickpapior@gmail.com>
Now users can sort along a projection vector. This will generally not be equivalent to lattice sorting for vectors equal to lattice vectors. Only when a lattice vector is orthogonal to the others will this be true. Signed-off-by: Nick Papior <nickpapior@gmail.com>
Mainly for clarity for users Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
…geometry A user defined atom argument did not preserve all atoms in the geometry. It now ensures that user requested atoms are sorting between them selves. All others are left untouched. I.e. sorting atom=[0, 10] will either swap 0 and 10, or do nothing. Enabled user defined functions for sorting the geometry. Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
Sorting now allows grouping of atoms. There are 4 different groupings, Z, tag, species, symbol. This is controlled by group=str or group=(str, ...) where str is one of the "groupings" and ... is a list or list of lists with items that may be grouped together. Optionally may one of these items be None in which case it will be filled with the *rest* of the allowable searchable items. For instance geom.sort(group=('symbol', None, 'C')) first groups all non C atoms, then all C atoms. Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
It is in ;) |
This change allows very complicated sort calls.
**kwargs
, sosort
should change interface to**kwargs
All sorts are now chained (much like lexsort).
One can now do
to first sort Cartesian x, then for each subgroup in this
sort according to first lattice vector, then for each subgroup
sort according to Cartesian y.
Note how axis1 allows numeric flags to allow multiple same
sorting algorithms for the same (to achieve different order
of sort).
One can also add ascending/descending
to ascend-sort x, descend-sort fa, ascend-sort y.
Also added preliminary support for sort in sgeom.
@tfrederiksen could you please have a look