PyAutoFit icon indicating copy to clipboard operation
PyAutoFit copied to clipboard

Make PyAutoGalaxy / PyAutoLens Result refer to correct object

Open Jammy2211 opened this issue 3 years ago • 2 comments

The following line:

result = search.fit(model=model, analysis=analysis)

Does not know that the output result is a PyAutoLens result (e.g. https://github.com/Jammy2211/PyAutoLens/blob/master/autolens/imaging/model/result.py).

This is a pain for PyCharm predictive variables, as it means it does not show me attributes like max_log_likelihood_fit.

Jammy2211 avatar Oct 26 '22 09:10 Jammy2211

I don't think Python generics are sufficient to solve this.

One way to do it is to use 'cast'

from typing import cast

result = cast(MyResultType, result)

rhayes777 avatar Nov 04 '22 08:11 rhayes777

Is there any way to do this in the source code?

the fit method is in the search of autofit, so I guess not without importing autolens / galaxy objects.

Bit of a nightmare as we dont really want users to have to cast the result themselves.

Jammy2211 avatar Nov 25 '22 18:11 Jammy2211