AOtools / aotools

A useful set of tools for Adaptive Optics in Python
GNU Lesser General Public License v3.0
109 stars 42 forks source link

infinitephasescreen unecessary handling of missing numba #67

Closed carandraug closed 2 years ago

carandraug commented 3 years ago

The aotools.turbulence.infinitephasescreen module has the following to handle the case of missing numba:

try:
    import numba
except:
    numba = None  
[...]
        if numba:
            calc_seperations_fast(positions, self.seperations)
        else:
[...]

However, it later has:

@numba.jit(nopython=True, parallel=True)
def calc_seperations_fast(positions, seperations):

Which defeats the whole point of handling the missing numba in the first place.

Either the handling of missing numba could be removed and keep things cleaner, or the numba.jit decorator needs to be done in some other way. I can propose a fix, no problem, but I'm not sure which way you'd rather go (I would guess remove the handling of missing numba since numba is now a "hard" requirement of aotools).

andrewpaulreeves commented 3 years ago

Hallo - yes you're completely right. In the "early days" of Numba it was quite tricky to install on some platforms. To be honest, I think it still might be but it comes with Anaconda so I never notice. Looking at the recent install docs, perhaps its ok now?

@matthewtownson what do you think? Are you happy with AOtools going "Full-Numba"?

carandraug commented 3 years ago

[...] In the "early days" of Numba it was quite tricky to install on some platforms. To be honest, I think it still might be but it comes with Anaconda so I never notice. [...]

The whole reason why I end up in this situation is because the latest numba does not actually work on my platform. The thing is, "pip install numba" succeeds but after installation importing numba fails (I guess this is a numba bug. It is definitely not an AOtools issue). What matters to AOtools is that "pip install aotools" then also succeeds, but then actually importing numba fails (because of the handling for missing numba not actually working, I get the weird "AttributeError: 'NoneType' object has no attribute 'jit'`).

matthewtownson commented 3 years ago

What platform are you on @carandraug that numba isn't working on?

I am happy adding numba as a full requirement which should solve some of this issue, depending on how niche the issue with numba is.

carandraug commented 3 years ago

What platform are you on @carandraug that numba isn't working on?

That was a Windows 7 machine running Python 3.8 from python.org. I don't think there was anything particular about the system (this was at my previous job so I can't go there and check more details). I ended up working around this installing an older version of some packages but I have no notes left from that work.

Removing the try/except block would mean getting an error that would immediately point to a failure to import numba. One then knows that the issue is the numba installation. As it is now, one gets the cryptic AttributeError: 'NoneType' object has no attribute 'jit'.