Skip to content

Commit

Permalink
Improved the detection of whether an interval can be used
Browse files Browse the repository at this point in the history
  • Loading branch information
fjwillemsen committed Jan 16, 2025
1 parent 160a81f commit 5b6a0be
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel_tuner/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ def get_instance_string(params):

def get_interval(a: list):
"""Checks if an array can be an interval. Returns (start, end, step) if interval, otherwise None."""
if len(a) < 3:
return None
if not all(isinstance(e, (int, float)) for e in a):
return None
a_min = min(a)
Expand All @@ -456,7 +458,10 @@ def get_interval(a: list):
for i, e in enumerate(a):
if e-a[i-1] != step:
return None
return (a_min, a_max, step)
result = (a_min, a_max, step)
if not all(isinstance(e, (int, float)) for e in result):
return None
return result


def get_kernel_string(kernel_source, params=None):
Expand Down

0 comments on commit 5b6a0be

Please sign in to comment.