The sympy function (the output of printing the expression) is:
"t*x*y + x**2 + y**2 + Piecewise((0, x < 0.5), (1, x >= 0.5)) + cos(t) - 1"

The error message is:

TypeError: unsupported operand type(s) for |=: 'set' and 'Piecewise'


The whole error output is:

Traceback (most recent call last):
  File "integration.py", line 201, in <module>
    print IntegrableFunction(integrands[0],**test).integrate()
  File "integration.py", line 52, in __init__
    sympy_function,self.sympy_variables,args=self.args)
  File "integration.py", line 167, in __init__
    argument_sequence=self.sympy_variables,to_files=True)
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/utilities/codegen.py",
line 958, in codegen
    return code_gen.write(routines, prefix, to_files, header, empty)
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/utilities/codegen.py",
line 445, in write
    dump_fn(self, routines, f, prefix, header, empty)
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/utilities/codegen.py",
line 615, in dump_c
    self.dump_code(routines, f, prefix, header, empty)
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/utilities/codegen.py",
line 489, in dump_code
    code_lines.extend(self._call_printer(routine))
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/utilities/codegen.py",
line 593, in _call_printer
    constants, not_c, c_expr = ccode(result.expr, assign_to=assign_to,
human=False)
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/printing/ccode.py",
line 262, in ccode
    return CCodePrinter(settings).doprint(expr, assign_to)
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/printing/ccode.py",
line 87, in doprint
    code0 = self._doprint_a_piece(expr, assign_to)
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/printing/codeprinter.py",
line 30, in _doprint_a_piece
    d = get_contraction_structure(expr)
  File
"/Users/woodscn/SCIPYTEST/lib/python2.7/site-packages/sympy/tensor/index_methods.py",
line 401, in get_contraction_structure
    result[key] |= d[key]
TypeError: unsupported operand type(s) for |=: 'set' and 'Piecewise'


Thanks for the quick response.


On Mon, Oct 7, 2013 at 10:44 PM, Ondřej Čertík <ondrej.cer...@gmail.com>wrote:

> Hi Nathan,
>
> On Mon, Oct 7, 2013 at 8:47 PM, Nathan Woods <charlesnwo...@gmail.com>
> wrote:
> >  Hi.
> >
> > I want to generate some C code that evaluates a discontinuous, symbolic,
> > function for a given set of arguments. codegen works great, except for
> the
>
> Can you post the function that you are trying to convert to a C code?
>
> > discontinuous bit. I tried defining the function as a Piecewise, but no
>
> That seems like the most natural way to do it. Can you post the error
> message?
> Let's fix it.
>
> > luck. Is there a better way to do this? Is this an easy fix? The best
> idea
> > I've had so far is to use Heaviside functions for the discontinuities and
> > write my own Heaviside implementation for inclusion by codegen.
> >
> > Thanks for any help.
> >
> > Nathan Woods
> >
> > P.S. Thanks for a great product!
>
> I am glad it's useful!
>
> Ondrej
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to