Nathan, I am working on a fix.
Can you provide the exact C expression that you want Piecewise((0, x < 0.5), (1, x >= 0.5)) to generate? I.e. can you fill in the right hand side here: assert ccode(Piecewise((0, x < 0.5), (1, x >= 0.5))) == "piecewise(...)" Ondrej On Tue, Oct 8, 2013 at 1:47 PM, Nathan Woods <charlesnwo...@gmail.com> wrote: > I was wondering if there were some kind of estimated time horizon on this. > Is it just a bug fix with a few hours if work, or is it a new feature that > would have to be added, potentially taking a few weeks? I'll need to work > around the problem, if that's the case. > > N > — > Sent from Mailbox for iPhone > > > On Tue, Oct 8, 2013 at 12:54 AM, F. B. <franz.bona...@gmail.com> wrote: >> >> /sympy/tensor/index_methods.pyc >> >> I have never worked on this file. The real tensor module is >> /sympy/tensor/tensor.py, the other files in that directory are tools for >> code generation (I think), which are able to handle indexed data, but I >> never used them. >> >> On Tuesday, October 8, 2013 8:20:31 AM UTC+2, Ondřej Čertík wrote: >>> >>> Nathan, >>> >>> On Mon, Oct 7, 2013 at 10:52 PM, Nathan Woods <charle...@gmail.com> >>> wrote: >>> > 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' >>> >>> >>> I see, here is how to reproduce it: >>> https://gist.github.com/certik/6880300 >>> >>> This is definitely a bug. Franz, any idea why it would call the tensor >>> module? >>> >>> 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. -- 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.