Fused types error

40 views
Skip to first unread message

Eric Larson

unread,
Nov 17, 2015, 2:58:30 PM11/17/15
to cython-users
Hello,

I'm getting started with fused types, and I've hit a "assert not pyrex" error on latest `master` and 0.23 when Cythonizing my code. Here is the error:

larsoner@bunk:~/custombuilds/scipy/scipy/signal$ cython _upfirdn_apply.pyx 
Compiler crash in AnalyseExpressionsTransform

ModuleNode.body = StatListNode(_upfirdn_apply.pyx:36:0)
StatListNode.stats[4] = StatListNode(_upfirdn_apply.pyx:61:0)
StatListNode.stats[0] = PyClassDefNode(_upfirdn_apply.pyx:61:0,
    name = u'_UpFIRDown')
PyClassDefNode.body = StatListNode(_upfirdn_apply.pyx:62:4)
StatListNode.stats[4] = DefNode(_upfirdn_apply.pyx:82:4,
    doc = u'Apply the prepared filter to a 1D signal x',
    is_cyfunction = True,
    modifiers = [...]/0,
    name = u'apply_',
    num_required_args = 2,
    py_wrapper_required = True,
    reqd_kw_flags_cname = '0',
    used = True)
File 'Nodes.py', line 430, in analyse_expressions: StatListNode(_upfirdn_apply.pyx:83:8,
    is_terminator = True)
File 'Nodes.py', line 4789, in analyse_expressions: SingleAssignmentNode(_upfirdn_apply.pyx:85:21)
File 'Nodes.py', line 4936, in analyse_types: SingleAssignmentNode(_upfirdn_apply.pyx:85:21)
File 'ExprNodes.py', line 873, in coerce_to: IndexNode(_upfirdn_apply.pyx:85:21,
    is_fused_index = True,
    is_subscript = True,
    result_is_used = True,
    use_managed_ref = True)
File 'ExprNodes.py', line 12161, in __init__: CoerceToPyTypeNode(is_temp = 1,
    result_is_used = True,
    use_managed_ref = True)

Compiler crash traceback from this point on:
  File "/home/larsoner/.local/lib/python2.7/site-packages/Cython-0.24.0a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py", line 12161, in __init__
    if not arg.type.create_to_py_utility_code(env):
  File "/home/larsoner/.local/lib/python2.7/site-packages/Cython-0.24.0a0-py2.7-linux-x86_64.egg/Cython/Compiler/PyrexTypes.py", line 2987, in create_to_py_utility_code
    safe_typename = re.sub('[^a-zA-Z0-9]', '__', self.declaration_code("", pyrex=1))
  File "/home/larsoner/.local/lib/python2.7/site-packages/Cython-0.24.0a0-py2.7-linux-x86_64.egg/Cython/Compiler/PyrexTypes.py", line 2828, in declaration_code
    arg.type.declaration_code("", for_display, pyrex = pyrex))
  File "/home/larsoner/.local/lib/python2.7/site-packages/Cython-0.24.0a0-py2.7-linux-x86_64.egg/Cython/Compiler/PyrexTypes.py", line 585, in declaration_code
    assert not pyrex
AssertionError:

Cython file attached. Right now my fused dtype is simply a wrapper to `double`, but eventually I want it to wrap to `double` or `double complex`. If I remove the fused types and just use `double` for my types, the code runs fine. Any idea what's going on here?

Also, with multiple fused dtypes being passed to a single function, it would be good if there were some way to specify the matrix of possible entries, as opposed to always doing all combinations. For example, a simple function that just does "c[i] = a[i] + b[i]" will only work for certain combinations of types for a, b, and c e.g. if they are complex or real. Has anyone considered adding this possibility of specifying a combination matrix, or is it overkill/too complex for the fused datatypes implementation?

Cheers,
Eric

_upfirdn_apply.pyx

Eric Larson

unread,
Nov 18, 2015, 8:58:47 AM11/18/15
to cython-users
Evgeni Burovski pointed out that moving the call to the fused-types function out of a method and into a separate function seems to fix the issue, so we suspect the problem has something to do with the call being inside a method.

Eric
Reply all
Reply to author
Forward
0 new messages