mala-project / mala

Materials Learning Algorithms. A framework for machine learning materials properties from first-principles data.
https://mala-project.github.io/mala/
BSD 3-Clause "New" or "Revised" License
81 stars 25 forks source link

Code duplications in `predictor.py` #508

Open elcorto opened 5 months ago

elcorto commented 5 months ago

https://github.com/mala-project/mala/blob/9b0c4fc45dc93c9e7165302d9cb0d56eb1e5fb32/mala/network/predictor.py#L37-L40 in __init__ is the same as https://github.com/mala-project/mala/blob/9b0c4fc45dc93c9e7165302d9cb0d56eb1e5fb32/mala/network/predictor.py#L65-L68 in predict_from_qeout(). Since the former is in the constructor, I think the latter can be skipped.

Also here https://github.com/mala-project/mala/blob/9b0c4fc45dc93c9e7165302d9cb0d56eb1e5fb32/mala/network/predictor.py#L105-L110 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 commented 5 months ago

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