{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/9816","labels_url":"https://api.github.com/repos/sympy/sympy/issues/9816/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/9816/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/9816/events","html_url":"https://github.com/sympy/sympy/issues/9816","id":100532753,"number":9816,"title":"theano_function breaks after one use","user":{"login":"Bonnevie","id":5861991,"avatar_url":"https://avatars.githubusercontent.com/u/5861991?v=3","gravatar_id":"","url":"https://api.github.com/users/Bonnevie","html_url":"https://github.com/Bonnevie","followers_url":"https://api.github.com/users/Bonnevie/followers","following_url":"https://api.github.com/users/Bonnevie/following{/other_user}","gists_url":"https://api.github.com/users/Bonnevie/gists{/gist_id}","starred_url":"https://api.github.com/users/Bonnevie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bonnevie/subscriptions","organizations_url":"https://api.github.com/users/Bonnevie/orgs","repos_url":"https://api.github.com/users/Bonnevie/repos","events_url":"https://api.github.com/users/Bonnevie/events{/privacy}","received_events_url":"https://api.github.com/users/Bonnevie/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-12T12:34:13Z","updated_at":"2015-08-19T09:07:56Z","closed_at":"2015-08-19T09:07:56Z","body":"Using the sympy.printing.theanocode.theano_function code generator in 2.7 works fine every time I start up my iPython shell, but once the first function has compiled, theano_function stops working for all future calls, even when I swap out all involved functions and variables. \r\nAll involved libraries should be up-to-date (tested after using pip install --upgrade). \r\nIt works fine in Python 3.\r\n\r\n```python\r\nPython 2.7.9 (default, Apr  2 2015, 15:33:21) \r\nType \"copyright\", \"credits\" or \"license\" for more information.\r\n\r\nIPython 2.3.0 -- An enhanced Interactive Python.\r\n?         -> Introduction and overview of IPython's features.\r\n%quickref -> Quick reference.\r\nhelp      -> Python's own help system.\r\nobject?   -> Details about 'object', use 'object??' for extra details.\r\n\r\nIn [1]: import sympy as s\r\n\r\nIn [2]: from sympy.printing.theanocode import theano_function\r\n\r\nIn [3]: x = s.Symbol('x')\r\n\r\nIn [4]: powfun = x**s.S(2)+s.S(1)\r\n\r\nIn [5]: fn = theano_function([x],[powfun],dims={x:1},dtypes={x:'float64'})\r\n\r\nIn [6]: fn([2])\r\nOut[6]: array([ 5.])\r\n\r\nIn [7]: fn2 = theano_function([x],[powfun],dims={x:1},dtypes={x:'float64'})\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-7-9e000095328a> in <module>()\r\n----> 1 fn2 = theano_function([x],[powfun],dims={x:1},dtypes={x:'float64'})\r\n\r\n/usr/local/lib/python2.7/dist-packages/sympy/printing/theanocode.pyc in theano_function(inputs, outputs, dtypes, cache, **kwargs)\r\n    225                    broadcastables=broadcastables)\r\n    226     tinputs  = list(map(code, inputs))\r\n--> 227     toutputs = list(map(code, outputs))\r\n    228     toutputs = toutputs[0] if len(toutputs) == 1 else toutputs\r\n    229     return theano.function(tinputs, toutputs, **theano_kwargs)\r\n\r\n/usr/local/lib/python2.7/dist-packages/sympy/printing/theanocode.pyc in theano_code(expr, cache, **kwargs)\r\n    192 \r\n    193 def theano_code(expr, cache=global_cache, **kwargs):\r\n--> 194     return TheanoPrinter(cache=cache, settings={}).doprint(expr, **kwargs)\r\n    195 \r\n    196 \r\n\r\n/usr/local/lib/python2.7/dist-packages/sympy/printing/theanocode.pyc in doprint(self, expr, **kwargs)\r\n    187     def doprint(self, expr, **kwargs):\r\n    188         \"\"\"Returns printer's representation for expr (as a string)\"\"\"\r\n--> 189         return self._print(expr, **kwargs)\r\n    190 \r\n    191 global_cache = {}\r\n\r\n/usr/local/lib/python2.7/dist-packages/sympy/printing/printer.pyc in _print(self, expr, *args, **kwargs)\r\n    255                 printmethod = '_print_' + cls.__name__\r\n    256                 if hasattr(self, printmethod):\r\n--> 257                     return getattr(self, printmethod)(expr, *args, **kwargs)\r\n    258 \r\n    259             # Unknown object, fall back to the emptyPrinter.\r\n\r\n/usr/local/lib/python2.7/dist-packages/sympy/printing/theanocode.pyc in _print_Basic(self, expr, **kwargs)\r\n     97     def _print_Basic(self, expr, **kwargs):\r\n     98         op = mapping[type(expr)]\r\n---> 99         children = [self._print(arg, **kwargs) for arg in expr.args]\r\n    100         return op(*children)\r\n    101 \r\n\r\n/usr/local/lib/python2.7/dist-packages/sympy/printing/printer.pyc in _print(self, expr, *args, **kwargs)\r\n    255                 printmethod = '_print_' + cls.__name__\r\n    256                 if hasattr(self, printmethod):\r\n--> 257                     return getattr(self, printmethod)(expr, *args, **kwargs)\r\n    258 \r\n    259             # Unknown object, fall back to the emptyPrinter.\r\n\r\n/usr/local/lib/python2.7/dist-packages/sympy/printing/theanocode.pyc in _print_Basic(self, expr, **kwargs)\r\n     98         op = mapping[type(expr)]\r\n     99         children = [self._print(arg, **kwargs) for arg in expr.args]\r\n--> 100         return op(*children)\r\n    101 \r\n    102     def _print_Number(self, n, **kwargs):\r\n\r\n/usr/local/lib/python2.7/dist-packages/theano/gof/op.pyc in __call__(self, *inputs, **kwargs)\r\n    523                         run_perform = False\r\n    524                     elif config.compute_test_value == 'raise':\r\n--> 525                         raise ValueError('Cannot compute test value: input %i (%s) of Op %s missing default value' % (i, ins, node))\r\n    526                     elif config.compute_test_value == 'ignore':\r\n    527                         # silently skip test\r\n\r\nValueError: Cannot compute test value: input 0 (x) of Op Elemwise{pow,no_inplace}(x, DimShuffle{x}.0) missing default value\r\n\r\nIn [8]: fn2\r\n---------------------------------------------------------------------------\r\nNameError                                 Traceback (most recent call last)\r\n<ipython-input-8-3d036129a423> in <module>()\r\n----> 1 fn2\r\n\r\nNameError: name 'fn2' is not defined\r\n \r\n```"},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/132502773","html_url":"https://github.com/sympy/sympy/issues/9816#issuecomment-132502773","issue_url":"https://api.github.com/repos/sympy/sympy/issues/9816","id":132502773,"user":{"login":"debugger22","id":2821646,"avatar_url":"https://avatars.githubusercontent.com/u/2821646?v=3","gravatar_id":"","url":"https://api.github.com/users/debugger22","html_url":"https://github.com/debugger22","followers_url":"https://api.github.com/users/debugger22/followers","following_url":"https://api.github.com/users/debugger22/following{/other_user}","gists_url":"https://api.github.com/users/debugger22/gists{/gist_id}","starred_url":"https://api.github.com/users/debugger22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debugger22/subscriptions","organizations_url":"https://api.github.com/users/debugger22/orgs","repos_url":"https://api.github.com/users/debugger22/repos","events_url":"https://api.github.com/users/debugger22/events{/privacy}","received_events_url":"https://api.github.com/users/debugger22/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T09:07:56Z","updated_at":"2015-08-19T09:07:56Z","body":"> this seems to occur for ordinary theano code on my computer as well and is therefore likely not a problem with sympy.\r\n\r\nIf you feel this related to sympy, feel free to reopen it."}}