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

Avoid deprecated generated_jit #784

Merged
merged 1 commit into from Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 19 additions & 24 deletions strax/processing/general.py
@@ -1,4 +1,3 @@
import os
import warnings

warnings.simplefilter("always", UserWarning)
Expand Down Expand Up @@ -58,29 +57,25 @@ def _sort_by_time_and_channel(x, channel, max_channel_plus_one, sort_kind="merge
return x[sort_i]


# Getting endtime jitted is a bit awkward, especially since it has to
# keep working with NUMBA_DISABLE_JIT, which we use for coverage tests.
# See https://github.com/numba/numba/issues/4759
if os.environ.get("NUMBA_DISABLE_JIT"):

@export
def endtime(x):
"""Return endtime of intervals x."""
if "endtime" in x.dtype.fields:
return x["endtime"]
else:
return x["time"] + x["length"] * x["dt"]

else:

@export
@numba.generated_jit(nopython=True, nogil=True)
def endtime(x):
"""Return endtime of intervals x."""
if "endtime" in x.dtype.fields:
return lambda x: x["endtime"]
else:
return lambda x: x["time"] + x["length"] * x["dt"]
@export
def endtime(x):
"""Return endtime of intervals x."""
if "endtime" in x.dtype.fields:
return x["endtime"]
else:
return x["time"] + x["length"] * x["dt"]


# Jitting endtime needs special attention, since inspecting the dtype
# has to happen in the python layer.
# (Used to work through numba.generated_jit, now numba.extending.overload)
@numba.extending.overload(endtime)
def _overload_endtime(x):
"""Return endtime of intervals x."""
if "endtime" in x.dtype.fields:
return lambda x: x["endtime"]
else:
return lambda x: x["time"] + x["length"] * x["dt"]


@export
Expand Down