{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/9389","labels_url":"https://api.github.com/repos/sympy/sympy/issues/9389/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/9389/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/9389/events","html_url":"https://github.com/sympy/sympy/issues/9389","id":74393458,"number":9389,"title":"theano printing of numbers","user":{"login":"penenkel","id":7736404,"avatar_url":"https://avatars.githubusercontent.com/u/7736404?v=3","gravatar_id":"","url":"https://api.github.com/users/penenkel","html_url":"https://github.com/penenkel","followers_url":"https://api.github.com/users/penenkel/followers","following_url":"https://api.github.com/users/penenkel/following{/other_user}","gists_url":"https://api.github.com/users/penenkel/gists{/gist_id}","starred_url":"https://api.github.com/users/penenkel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/penenkel/subscriptions","organizations_url":"https://api.github.com/users/penenkel/orgs","repos_url":"https://api.github.com/users/penenkel/repos","events_url":"https://api.github.com/users/penenkel/events{/privacy}","received_events_url":"https://api.github.com/users/penenkel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-08T15:06:43Z","updated_at":"2015-08-20T17:20:59Z","closed_at":null,"body":"ATM, TheanoPrinter converts sympy Number into python numbers via `eval(str(n))` which will fail for stuff like NAN etc. Also `theano.function` expects a valid theano expression as output-expression. Should the sympy expression boil down to a simple number, the printer will convert it into a python number, which in turn will crash theano. My suggestion is to use `theano.scalar.constant` or `theano.tensor.constant` for all numeric types, this would also work with NAN."},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/133081388","html_url":"https://github.com/sympy/sympy/issues/9389#issuecomment-133081388","issue_url":"https://api.github.com/repos/sympy/sympy/issues/9389","id":133081388,"user":{"login":"richardotis","id":6405510,"avatar_url":"https://avatars.githubusercontent.com/u/6405510?v=3","gravatar_id":"","url":"https://api.github.com/users/richardotis","html_url":"https://github.com/richardotis","followers_url":"https://api.github.com/users/richardotis/followers","following_url":"https://api.github.com/users/richardotis/following{/other_user}","gists_url":"https://api.github.com/users/richardotis/gists{/gist_id}","starred_url":"https://api.github.com/users/richardotis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardotis/subscriptions","organizations_url":"https://api.github.com/users/richardotis/orgs","repos_url":"https://api.github.com/users/richardotis/repos","events_url":"https://api.github.com/users/richardotis/events{/privacy}","received_events_url":"https://api.github.com/users/richardotis/received_events","type":"User","site_admin":false},"created_at":"2015-08-20T17:20:58Z","updated_at":"2015-08-20T17:20:58Z","body":"What about a patch for `TheanoPrinter` like this? Something like this would need to be done for the code printer in `autowrap` too. CC @moorepants @jcrist  @mrocklin \r\n\r\n```python\r\ndef _print_Number(self, n, **kwargs):\r\n    try:\r\n        return eval(str(n))\r\n    except NameError:\r\n        return float(n)\r\n```"}}