【发布时间】:2023-02-01 01:45:43
【问题描述】:
我正在尝试编写我的第一个并行化函数
但问题是,我收到以下错误:
possible_EVENTS = np.array([""])
@njit(parallel=True,nopython=True)
def add_History(events,EVENTS):
index=events.where(events=="Repair")
add=np.array("")
pre_events=events[index:]
if ("LOMT" in pre_events) & ("DIMT" in pre_events):
for i in pre_events:
if "FU" not in i:
add.append(i)
else:
break
if len(add)>=5:
possible_EVENTS .append(add)
for i in tqdm(packages):
events=np.array(df_["Event"].loc[df_["Packages"]==i].values)
add_History(events,possible_EVENTS )
但我得到这个错误。
TypingError Traceback (most recent call last)
C:\Users\local_PIETAPA\Temp\ipykernel_16492\3239905456.py in <module>
16 for container in tqdm(container_search):
17 events=np.array(df_["EVENT_CODE"].loc[df_["UNIT"]==container].values)
---> 18 add_EPOS_History(events,EPOS_EVENTS)
C:\ProgramData\Anaconda3\lib\site-packages\numba\core\dispatcher.py in _compile_for_args(self, *args, **kws)
466 e.patch_message(msg)
467
--> 468 error_rewrite(e, 'typing')
469 except errors.UnsupportedError as e:
470 # Something unsupported is present in the user code, add help info
C:\ProgramData\Anaconda3\lib\site-packages\numba\core\dispatcher.py in error_rewrite(e, issue_type)
407 raise e
408 else:
--> 409 raise e.with_traceback(None)
410
411 argtypes = []
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
non-precise type array(pyobject, 1d, C)
During: typing of argument at C:\Users\local_PIETAPA\Temp\ipykernel_16492\3239905456.py (4)
File "..\..\..\local_PIETAPA\Temp\ipykernel_16492\3239905456.py", line 4:
<source missing, REPL/exec in use?>
而且我不知道如何解决它。你能帮助我吗?
【问题讨论】:
标签: python parallel-processing numba