-
Notifications
You must be signed in to change notification settings - Fork 12
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
Refactored PeriodicTable #42
base: main
Are you sure you want to change the base?
Conversation
…h avoids rewriting the function
It is nice that you can just go straight to the foreign symbols! Very clean. My main concern is the non-rusty capitalization. I take it there's no serde renaming equivalent of |
I am not aware of such conversion but it is true that if it is "only" that, I would like to argue that we are better just keeping the camel case in order to avoid all those boilerplate. Also, if we go in this direction, I think that the use cxx::{let_cxx_string, CxxVector};
pub struct PeriodicTable {}
impl PeriodicTable {
pub fn get_valence_list(atomic_number: u32) -> &'static CxxVector<i32> {
rdkit_sys::periodic_table_ffi::get_valence_list(atomic_number)
}
pub fn get_most_common_isotope_mass(atom: &str) -> f64 {
let_cxx_string!(atom_cxx_string = atom);
rdkit_sys::periodic_table_ffi::get_most_common_isotope_mass(&atom_cxx_string)
}
} becomes redundant because we can directly call : let_cxx_string!(atom = "C");
let periodic_table = rdkit_sys::periodic_table_ffi::get_periodic_table();
let mass = periodic_table.getMostCommonIsotopeMass(&atom); from the |
Agreed, avoiding boilerplate is worthy of the effort. It means that in the future it'll be easier to add and modify bindings (suitable for mere mortals!). I want to keep
|
I see ! That makes sense. I will finish pushing stuff to this pull request and if it is ok with you, we can start refactoring a little bit. I just checked there should only be minor changes in the |
…sts and docstrins. Docstrings are a copy-paste of RDKit documentation
Ok now checks fail because I have added some functions that are not available in your version of rdkit in GitHub actions. Should we update the version ? Or should I just comment the functions ? |
@mvisani I've updated the GitHub workflows to use the latest RDKit release. If you merge main into your branch, it should work now. |
@JJ-Pineda Indeed all tests pass now. Thank you ! |
@xrl All tests pass, should we proceed to merge ? |
Solves #39.
As you can see, there is no need to write the C++ function anymore. This still compiles. We would then need to write in the wrapper the constructors for our different objects and the function that cause problems in the conversion.