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

"please report a bug" -> CompileError with `const fused_t[:, :]` argument #3222

Open
jbrockmendel opened this issue Oct 31, 2019 · 1 comment

Comments

@jbrockmendel
Copy link
Contributor

@jbrockmendel jbrockmendel commented Oct 31, 2019

Looking at pandas._libs.algos.diff_2d (https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/algos_common_helper.pxi.in#L22), the current declaration is:

def diff_2d(ndarray[diff_t, ndim=2] arr, [out_t, ndim=2] out, Py_ssize_t periods, int axis):

where diff_t and out_t are fused types (all numeric, defined just above the function in the link above). To avoid build warnings, I want to change the ndarray[diff_t, ndim=2] arr to const diff_t[:, :] arr. Doing this without the const works fine, but with the const, I get compile-time error:

def diff_2d(const diff_t[:, :] arr,
                        ^
------------------------------------------------------------

pandas/_libs/algos_common_helper.pxi:22:25: Compiler crash in AnalyseDeclarationsTransform

File 'ModuleNode.py', line 124, in analyse_declarations: ModuleNode(algos.pyx:1:0,
    full_module_name = 'pandas._libs.algos')
File 'Nodes.py', line 431, in analyse_declarations: StatListNode(algos.pyx:1:0)
File 'Nodes.py', line 431, in analyse_declarations: StatListNode(algos_common_helper.pxi:1:0)
File 'Nodes.py', line 375, in analyse_declarations: CompilerDirectivesNode(algos_common_helper.pxi:22:0)
File 'Nodes.py', line 431, in analyse_declarations: StatListNode(algos_common_helper.pxi:22:0)
File 'Nodes.py', line 2887, in analyse_declarations: DefNode(algos_common_helper.pxi:22:0,
    modifiers = [...]/0,
    name = 'diff_2d',
    num_required_args = 4,
    outer_attrs = [...]/2,
    py_wrapper_required = True,
    reqd_kw_flags_cname = '0')
File 'Nodes.py', line 2925, in analyse_argument_types: DefNode(algos_common_helper.pxi:22:0,
    modifiers = [...]/0,
    name = 'diff_2d',
    num_required_args = 4,
    outer_attrs = [...]/2,
    py_wrapper_required = True,
    reqd_kw_flags_cname = '0')
File 'Nodes.py', line 1093, in analyse: MemoryViewSliceTypeNode(algos_common_helper.pxi:22:25,
    name = 'memoryview')

Compiler crash traceback from this point on:
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/Nodes.py", line 1093, in analyse
    self.type = PyrexTypes.MemoryViewSliceType(base_type, axes_specs)
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/PyrexTypes.py", line 625, in __init__
    self.dtype_name = Buffer.mangle_dtype_name(self.dtype)
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/Buffer.py", line 631, in mangle_dtype_name
    return prefix + dtype.specialization_name()
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/PyrexTypes.py", line 57, in specialization_name
    common_subs = (self.empty_declaration_code()
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/PyrexTypes.py", line 51, in empty_declaration_code
    self._empty_declaration = self.declaration_code('')
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/PyrexTypes.py", line 1582, in declaration_code
    return self.const_base_type.declaration_code("const %s" % entity_code, for_display, dll_linkage, pyrex)
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/PyrexTypes.py", line 1649, in declaration_code
    raise Exception("This may never happen, please report a bug")
Exception: This may never happen, please report a bug
Traceback (most recent call last):
  File "setup.py", line 809, in <module>
    ext_modules=maybe_cythonize(extensions, compiler_directives=directives),
  File "setup.py", line 538, in maybe_cythonize
    return cythonize(extensions, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1096, in cythonize
    cythonize_one(*args)
  File "/usr/local/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1219, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pandas/_libs/algos.pyx
@da-woods

This comment has been minimized.

Copy link
Contributor

@da-woods da-woods commented Oct 31, 2019

For what it's worth my pull request #3205 appears to fix this too, although I haven't investigated why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.