I could take a look at this problem but probably won't get to it for a day or two. My understanding was that ccodegen supported piecewise though. Can anyone identify what the issue is? Looking at Ondrej's error printout my guess is that it's a simple issue.
I more actively maintain the SymPy->Theano conversion which can provide efficient Theano functions that run at C speed but don't give nice code to use in external applications (so this may or may not be of use to you). In general I respond to errors on that system within a day or so. Some documentation on this is here https://github.com/mrocklin/sympy/blob/e610a6898b67d43eb7adc5b014007225aeb1eb90/doc/src/modules/numeric-computation.rst https://github.com/sympy/sympy/pull/2400 Halfway through writing this I see that Ondrej is working on it. Great! On Tue, Oct 8, 2013 at 12:47 PM, Nathan Woods <[email protected]>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 <https://www.dropbox.com/mailbox> for iPhone > > > On Tue, Oct 8, 2013 at 12:54 AM, F. B. <[email protected]> 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 <[email protected]> >>> 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 [email protected]. >> To post to this group, send email to [email protected]. >> 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 [email protected]. > To post to this group, send email to [email protected]. > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
