hexrd icon indicating copy to clipboard operation
hexrd copied to clipboard

Remove code that runs if numba is missing

Open psavery opened this issue 2 years ago • 2 comments

Numba is a requirement, and has been for some time. We should stop maintaining code is supposed to run if numba is missing, and just remove it.

Here is an example where the presence of numba is checked. We should remove everything in the else: block.

This will help us reduce the amount of code we need to maintain.

psavery avatar Jul 13 '23 17:07 psavery

Here is a piece of code from hexrd/indexer.py. It is a bit confusing since the comment says it is numba friendly, but the later FIXME comment says it only works outside the numba implementation.

def _check_dilated(eta, ome, dpix_eta, dpix_ome, etaOmeMap, threshold):
    """Part of paintGridThis.

    check if there exists a sample over the given threshold in the etaOmeMap
    at (eta, ome), with a tolerance of (dpix_eta, dpix_ome) samples.

    Note this function is "numba friendly" and will be jitted when using numba.

    TODO: currently behaves like "np.any" call for values above threshold.
    There is some ambigutiy if there are NaNs in the dilation range, but it
    hits a value above threshold first.  Is that ok???

    FIXME: works in non-numba implementation of paintGridThis only
    <JVB 2017-04-27>
    """

donald-e-boyce avatar Jul 17 '23 20:07 donald-e-boyce

@donald-e-boyce I think you can safely ignore this comment.

In the indexer.py script, this function is dynamically wrapped with a JIT decorator, and so if you add @numba.jit() as a decorator on that function it fails. I suspect someone tested adding the extra decorator, Python threw an exception due to there already being an equivalent decorator defined for that function, and it was assumed not to work with numba.

https://github.com/HEXRD/hexrd/blob/master/hexrd/indexer.py#L667

_check_dilated = numba.njit(nogil=True, cache=True)(_check_dilated)

ZackAttack614 avatar Jul 17 '23 20:07 ZackAttack614