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

Code duplications in predictor.py #508

Open
elcorto opened this issue Mar 26, 2024 · 1 comment
Open

Code duplications in predictor.py #508

elcorto opened this issue Mar 26, 2024 · 1 comment

Comments

@elcorto
Copy link
Member

elcorto commented Mar 26, 2024

self.data.grid_dimension = self.parameters.inference_data_grid
self.data.grid_size = self.data.grid_dimension[0] * \
self.data.grid_dimension[1] * \
self.data.grid_dimension[2]
in __init__ is the same as
self.data.grid_dimension = self.parameters.inference_data_grid
self.data.grid_size = self.data.grid_dimension[0] * \
self.data.grid_dimension[1] * \
self.data.grid_dimension[2]
in predict_from_qeout(). Since the former is in the constructor, I think the latter can be skipped.

Also here

if np.prod(self.parameters.inference_data_grid) > 0:
self.data.grid_dimension = self.parameters.inference_data_grid
else:
# We need to check if we're in size transfer mode.
old_cell = self.data.target_calculator.atoms.get_cell()
new_cell = atoms.get_cell()
self.data.grid_dimension = self.parameters.inference_data_grid is already performed in __init__ so the check could be changed to something like

if np.prod(self.parameters.inference_data_grid) == 0:
    ... code from else clause here ...

Note: <= 0 would be correct but I gess np.prod(self.parameters.inference_data_grid) is never < 0.

@RandomDefaultUser
Copy link
Member

Hi @elcorto thanks for bringing this to my attention, I will have a look! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants