-
Notifications
You must be signed in to change notification settings - Fork 10
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
Rework-API #50
Rework-API #50
Conversation
Yeah this is a bit too large for me to review with the limited time I have right now. I am not sure the enum to type approach is necessary. It forces a lot more specialization and constant propagation should help make it more type stable. I do think including the expected element type on the signature is a good move (like we had for gather) |
Yeah I figured as much. If you want me to, I can prepare you a more focused PR without the unecessary extras. Type stabilityCurrently, there a 4 structs:
With most of them carrying type information:
The only enum not carrying type information is From what I've gathered, the only way we can guarantee type stability is if we dispatch on the values of the enums. In fact, that's the only reason to have I also Investigated a tiny bit using I'd suggest we switch |
Closing this in favor of #51. |
I got a bit carried away and reworked almost the entire API . There are a lot of breaking changes but I hope that these will be worthwile.
Changes
LAMMPS.API.LMP_TYPE_VECTOR
reduces toTYPE_VECTOR
extract
methods should now be typestable!extracts
now have the kwargcopy
which is true by default. I've done this because the pointers we recieve from LAMMPS are not persistent. I don't think it's a good idea to hand the user an Array that can suddenly cause a Segfault - at least not by default.extracts
now return Vectors withlength=1
instead of Scalar values, when settingcopy=false
, this allows the user to modify the underlying data. (This is partly because of type stability as well)Float64
. With this assumption,gather
/scatter!
should now always detect incorrect types.gather
also uses the newly defined Singletons instead ofFloat64/Int32
for the type parametergather_bonds
,gather_angles
,gather_dihedrals
,gather_impropers
,decode_image_flags
,encode_image_flags
,extract_setting
, andcreate_atoms
,is_running
are now implementedTodo
It probably would have been better to split this up into multiple PR's 😅