Skip to content
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

Adding a conversion function for other packages #139

Closed
wants to merge 2 commits into from

Conversation

rosecers
Copy link
Collaborator

@rosecers rosecers commented Dec 1, 2022

Just because I was writing it for myself and figured others would fine it useful. Added all of the necessary tests and included a shout-out in docs where I thought it was appropriate.

@rosecers rosecers requested a review from Luthaf December 1, 2022 15:26
@github-actions
Copy link

github-actions bot commented Dec 1, 2022

The documentation for this PR is (or will soon be) available on readthedocs: https://rascaline--139.org.readthedocs.build/en/139/

@github-actions
Copy link

github-actions bot commented Dec 1, 2022

Here is a pre-built version of the code in this pull request: wheels.zip, you can install it locally by unzipping wheels.zip and using pip to install the file matching your system

Copy link
Member

@Luthaf Luthaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very useful, thanks a lot!

However I'm not sure if putting this function inside rascaline is the best thing to do from a marketing/future of the library point of view. I think this would be better as a semi-external tool (maybe a small website?) in which users can copy/paste hypers, forcing them to update there code. Right now I could see people keep the other packages syntax in their code, and use these function to dynamically translate to rascaline, while it would be better if they directly learn to work with rascaline hypers.

Alternatively, have this function print "your rascaline hypers are ..." as a string would work for me.

python/rascaline/utils.py Outdated Show resolved Hide resolved
)

not_supported = [
"coefficient_subselection",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coefficient_subselection could point people to the selected_properties argument of the compute function

"global_species",
"expansion_by_species_method",
"soap_type",
"compute_gradients",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compute_gradients could point people to the gradients argument of the compute function

not_supported = [
"coefficient_subselection",
"covariant_lambda",
"gaussian_sigma_type",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gaussian_sigma_type="Constant" (which is the only one implemented by librascal) is also what rascaline is doing by default

Comment on lines +172 to +173
"optimization_args",
"optimization",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these could be translated to "Gto" radial basis options in rascaline

if new_hypers["radial_basis"] != "Gto":
warnings.warn("WARNING: rascaline currently only supports a Gto basis.")

deprecated_params = ["average", "sparse", "dtype"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

average="outer" could point to equistore.operations.mean_over_samples, and average="off" is the default

"crossover",
"average",
"sparse",
"dtype",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is also weighting which can be translated to either radial_scaling (weighting/function/pow in dscribe) or central_atom_weight (weighting/w0 in dscribe)


not_supported = [
"periodic",
"crossover",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crossover=True is what rascaline does, crossover=False could be achieved once #134 is merged with a selected_keys parameter to the compute function

Comment on lines +31 to +32
with self.assertRaises(ValueError):
convert_old_hyperparameter_names({}, mode="BadMode")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also check the error message when checking that exceptions are raised, otherwise it is really easy to get the tests to pass with a different error than the expected one beening raised.

Suggested change
with self.assertRaises(ValueError):
convert_old_hyperparameter_names({}, mode="BadMode")
with self.assertRaises(ValueError) as cm:
convert_old_hyperparameter_names({}, mode="BadMode")
self.assertEqual(str(cm.exception), "some error message")

convert_old_hyperparameter_names({"bad_param": 0}, mode="dscribe")

def test_not_gto(self):
with warnings.catch_warnings(record=True) as w:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that works, but I've been using self.assertWarns everywhere else, so it might be better to use it here as well for consistency

@Luthaf
Copy link
Member

Luthaf commented Dec 1, 2022

linter is not happy, you can run tox -e format to reformat the code, and tox -e lint to run the flake8 checks locally

Co-authored-by: Guillaume Fraux <[email protected]>
@Luthaf
Copy link
Member

Luthaf commented Dec 14, 2023

I think this is worth having and tracked in #264, but in the mean I'll close this PR for inactivity. We can re-open something later!

@Luthaf Luthaf closed this Dec 14, 2023
@Luthaf Luthaf deleted the feat/hyper_conversion branch December 14, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants