Skip to content

Commit 844f9aa

Browse files
committed
Check types in parallel dispatch arg parsing
1 parent 58fe485 commit 844f9aa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pykokkos/interface/parallel_dispatch.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ def handle_args(is_for: bool, *args) -> HandledArgs:
145145
if isinstance(policy, (int, np.integer)):
146146
policy = RangePolicy(ExecutionSpace.Default, 0, int(policy))
147147

148+
# check type instance for input args
149+
if name is not None:
150+
if not isinstance(name, str):
151+
raise TypeError(
152+
f"ERROR: name expected to be type 'str', got '{name}' of type '{type(name)}'"
153+
)
154+
if not isinstance(policy, ExecutionPolicy) and not isinstance(policy, int):
155+
raise TypeError(
156+
f"ERROR: policy expected to be type 'ExecutionPolicy' or 'int', got '{policy}' of type '{type(policy)}'"
157+
)
158+
if not isinstance(workunit, Callable):
159+
raise TypeError(
160+
f"ERROR: workunit expected to be type 'Callable', got '{workunit}' of type '{type(workunit)}'"
161+
)
162+
148163
return HandledArgs(name, policy, workunit, view, initial_value)
149164

150165

0 commit comments

Comments
 (0)