-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
enabled ufuncs for external classes #898
Conversation
This enables one to interact on external classes. However, only if they can be converted to a sisl object. This can be quite handy for sisl specific functions. Fixes #747. Signed-off-by: Nick Papior <[email protected]>
Signed-off-by: Nick Papior <[email protected]>
Signed-off-by: Nick Papior <[email protected]>
Cool, let's see :) |
Ah, so what I had in mind was that if it takes in an ASE |
I think we'll just keep this, but you can do weird things now: import sisl as si
lat = si.tile(2, 0, axis=2)
assert lat.equal(si.Lattice(2).tile(0, 2)) And, when you start playing with si.tile("siesta.nc", ...) might do a geometry, or a Hamiltonian, or a Lattice... |
ok! I can see why that makes sense... But that requires that any functionality must be mirrored in both |
Signed-off-by: Nick Papior <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #898 +/- ##
==========================================
+ Coverage 86.87% 86.89% +0.01%
==========================================
Files 405 405
Lines 53396 53429 +33
==========================================
+ Hits 46390 46427 +37
+ Misses 7006 7002 -4 ☔ View full report in Codecov by Sentry. |
What about adding a keyword that it can grab to return sisl objects? e.g. |
Interesting haha. But true that having to rely on the order of the registry is not a good thing 😅 sisl.Geometry.rotate("siesta.nc") and then refuse to apply any ufunc when the behavior is not well defined? For the sisl.rotate(ase_atoms) # ---> Outputs sisl geometry
sisl.rotate(ase_atoms, keep_original=True) # ---> Outputs ASE atoms I know that this doesn't look much better than |
Allowed one to forcefully return the sisl object. Will not act on built-ins, because it can lead to simple ambiguity. Signed-off-by: Nick Papior <[email protected]>
Ok, I have removed the use of built-ins. Forcing users to be explicit is ok.
Note, than for some generics, it will return something different. So when that is the case, it will not try to convert. E.g. |
Ok, I think this is ready! Thanks for comments! |
This enables one to interact on external classes.
However, only if they can be converted to a sisl object.
This can be quite handy for sisl specific functions.
Fixes #747.
docs/
changes/<pr-num>.<type>.rst