Bad error reporting for unimplemented function value reference
quasilyte opened this issue · 0 comments
quasilyte commented
Given this code:
import hpat
import pandas as pd
import numpy as np
@hpat.jit
def weird():
df = pd.DataFrame({'A': np.ones(10), 'B': np.arange(10)})
return df.columns
print(weird())
Execution leads to this error:
Traceback (most recent call last):
File "examples/hello2.py", line 10, in <module>
print(weird())
File "~/miniconda3/envs/HPAT/lib/python3.6/site-packages/numba/dispatcher.py", line 348, in _compile_for_args
error_rewrite(e, 'typing')
File "~/miniconda3/envs/HPAT/lib/python3.6/site-packages/numba/dispatcher.py", line 315, in error_rewrite
reraise(type(e), e, None)
File "~/miniconda3/envs/HPAT/lib/python3.6/site-packages/numba/six.py", line 658, in reraise
raise value.with_traceback(tb)
numba.errors.TypingError: Failed in hpat mode pipeline (step: nopython frontend)
Undefined variable 'df', operation: $0.15, location: examples/hello2.py (7)
File "examples/hello2.py", line 7:
def weird():
df = pd.DataFrame({'A': np.ones(10), 'B': np.arange(10)})
^
But this is misleading. df
is defined, the problem is that df.count
method is unimplemented and when it's not called but the method value is referenced instead, such error is produced.
If df.count
is changed to df.count()
we get better error message:
NotImplementedError: Failed in hpat mode pipeline (step: convert DataFrames)
data frame function columns not implemented yet
HPAT could probably give a better error message in the first case.