{"action":"created","comment":{"url":"https://api.github.com/repos/sympy/csympy/pulls/comments/28641279","id":28641279,"diff_hunk":"@@ -0,0 +1,314 @@\n+#include <algorithm>\n+\n+#include \"printer.h\"\n+\n+namespace CSymPy {\n+\n+StrPrinter::StrPrinter(bool ordered) : BaseVisitor(this), order_(ordered) {\n+\n+}\n+void StrPrinter::bvisit(const Basic &x) {\n+    std::cout << \"Basic\" <<std::endl;\n+}\n+\n+void StrPrinter::bvisit(const Symbol &x) {\n+    str_ = x.get_name();\n+}\n+\n+void StrPrinter::bvisit(const Integer &x) {\n+    std::ostringstream s;\n+    s << x.i;\n+    str_ = s.str();\n+}\n+\n+void StrPrinter::bvisit(const Rational &x) {\n+    std::ostringstream s;\n+    s << x.i;\n+    str_ = s.str();\n+}\n+\n+void StrPrinter::bvisit(const Complex &x) {\n+    std::ostringstream s;\n+    if (x.real_ != 0) {\n+        s << x.real_;\n+        // Since Complex is in canonical form, imaginary_ is not 0.\n+        if (sgn(x.imaginary_) == 1) {\n+            s << \" + \";\n+        } else {\n+            s << \" - \";\n+        }\n+        // If imaginary_ is not 1 or -1, print the absolute value\n+        if (x.imaginary_ != sgn(x.imaginary_)) {\n+            s << abs(x.imaginary_);\n+            s << \"*I\";\n+        } else {\n+            s << \"I\";\n+        }\n+    } else {\n+        if (x.imaginary_ != sgn(x.imaginary_)) {\n+            s << x.imaginary_;\n+            s << \"*I\";\n+        } else {\n+            if (sgn(x.imaginary_) == 1) {\n+                s << \"I\";\n+            } else {\n+                s << \"-I\";\n+            }\n+        }\n+    }\n+    str_ = s.str();\n+}\n+\n+template<class T>\n+void getKeysValues(vec_basic &keys, vec_basic &values, T &dict, bool order) {\n+\n+    if(order) {\n+        for(auto &p: dict) {\n+            keys.push_back(p.first);\n+        }\n+        std::sort(keys.begin(), keys.end(), RCPBasicKeyLessCmp());\n+        for(auto &p: keys) {\n+            values.push_back(dict.find(p)->second);\n+        }","path":"src/printer.cpp","position":72,"original_position":72,"commit_id":"7b587ab8cdacb680c9377eccc0bf8a70c41e8b0c","original_commit_id":"7b587ab8cdacb680c9377eccc0bf8a70c41e8b0c","user":{"login":"isuruf","id":5234427,"avatar_url":"https://avatars.githubusercontent.com/u/5234427?v=3","gravatar_id":"","url":"https://api.github.com/users/isuruf","html_url":"https://github.com/isuruf","followers_url":"https://api.github.com/users/isuruf/followers","following_url":"https://api.github.com/users/isuruf/following{/other_user}","gists_url":"https://api.github.com/users/isuruf/gists{/gist_id}","starred_url":"https://api.github.com/users/isuruf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isuruf/subscriptions","organizations_url":"https://api.github.com/users/isuruf/orgs","repos_url":"https://api.github.com/users/isuruf/repos","events_url":"https://api.github.com/users/isuruf/events{/privacy}","received_events_url":"https://api.github.com/users/isuruf/received_events","type":"User","site_admin":false},"body":"Yeah, I wanted to find a common way for both orderings. I couldn't find a better way to make it work with both orderings. \r\nBtw, do we need to keep the earlier ordering. If it's just the new order, then your suggestion can be used.","created_at":"2015-04-18T04:35:28Z","updated_at":"2015-04-18T04:35:28Z","html_url":"https://github.com/sympy/csympy/pull/423#discussion_r28641279","pull_request_url":"https://api.github.com/repos/sympy/csympy/pulls/423","_links":{"self":{"href":"https://api.github.com/repos/sympy/csympy/pulls/comments/28641279"},"html":{"href":"https://github.com/sympy/csympy/pull/423#discussion_r28641279"},"pull_request":{"href":"https://api.github.com/repos/sympy/csympy/pulls/423"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/csympy/pulls/423","id":33420372,"html_url":"https://github.com/sympy/csympy/pull/423","diff_url":"https://github.com/sympy/csympy/pull/423.diff","patch_url":"https://github.com/sympy/csympy/pull/423.patch","issue_url":"https://api.github.com/repos/sympy/csympy/issues/423","number":423,"state":"open","locked":false,"title":"StrPrinter","user":{"login":"isuruf","id":5234427,"avatar_url":"https://avatars.githubusercontent.com/u/5234427?v=3","gravatar_id":"","url":"https://api.github.com/users/isuruf","html_url":"https://github.com/isuruf","followers_url":"https://api.github.com/users/isuruf/followers","following_url":"https://api.github.com/users/isuruf/following{/other_user}","gists_url":"https://api.github.com/users/isuruf/gists{/gist_id}","starred_url":"https://api.github.com/users/isuruf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isuruf/subscriptions","organizations_url":"https://api.github.com/users/isuruf/orgs","repos_url":"https://api.github.com/users/isuruf/repos","events_url":"https://api.github.com/users/isuruf/events{/privacy}","received_events_url":"https://api.github.com/users/isuruf/received_events","type":"User","site_admin":false},"body":"@sushant-hiray, Can you check whether this PR fixes printing issues on OS X?\r\n\r\nLet me know a generic name to replace `Printer` and `print`\r\n\r\nTODO:\r\n- [ ] Add tests for printing issues that this PR fixes.","created_at":"2015-04-16T05:38:14Z","updated_at":"2015-04-18T04:35:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf688c90ec3f5314217e01669f7bc16527dd9252","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sympy/csympy/pulls/423/commits","review_comments_url":"https://api.github.com/repos/sympy/csympy/pulls/423/comments","review_comment_url":"https://api.github.com/repos/sympy/csympy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/csympy/issues/423/comments","statuses_url":"https://api.github.com/repos/sympy/csympy/statuses/7b587ab8cdacb680c9377eccc0bf8a70c41e8b0c","head":{"label":"isuruf:visitor","ref":"visitor","sha":"7b587ab8cdacb680c9377eccc0bf8a70c41e8b0c","user":{"login":"isuruf","id":5234427,"avatar_url":"https://avatars.githubusercontent.com/u/5234427?v=3","gravatar_id":"","url":"https://api.github.com/users/isuruf","html_url":"https://github.com/isuruf","followers_url":"https://api.github.com/users/isuruf/followers","following_url":"https://api.github.com/users/isuruf/following{/other_user}","gists_url":"https://api.github.com/users/isuruf/gists{/gist_id}","starred_url":"https://api.github.com/users/isuruf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isuruf/subscriptions","organizations_url":"https://api.github.com/users/isuruf/orgs","repos_url":"https://api.github.com/users/isuruf/repos","events_url":"https://api.github.com/users/isuruf/events{/privacy}","received_events_url":"https://api.github.com/users/isuruf/received_events","type":"User","site_admin":false},"repo":{"id":20401702,"name":"csympy","full_name":"isuruf/csympy","owner":{"login":"isuruf","id":5234427,"avatar_url":"https://avatars.githubusercontent.com/u/5234427?v=3","gravatar_id":"","url":"https://api.github.com/users/isuruf","html_url":"https://github.com/isuruf","followers_url":"https://api.github.com/users/isuruf/followers","following_url":"https://api.github.com/users/isuruf/following{/other_user}","gists_url":"https://api.github.com/users/isuruf/gists{/gist_id}","starred_url":"https://api.github.com/users/isuruf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isuruf/subscriptions","organizations_url":"https://api.github.com/users/isuruf/orgs","repos_url":"https://api.github.com/users/isuruf/repos","events_url":"https://api.github.com/users/isuruf/events{/privacy}","received_events_url":"https://api.github.com/users/isuruf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/isuruf/csympy","description":"Fast symbolic manipulation library, written in C++","fork":true,"url":"https://api.github.com/repos/isuruf/csympy","forks_url":"https://api.github.com/repos/isuruf/csympy/forks","keys_url":"https://api.github.com/repos/isuruf/csympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/isuruf/csympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/isuruf/csympy/teams","hooks_url":"https://api.github.com/repos/isuruf/csympy/hooks","issue_events_url":"https://api.github.com/repos/isuruf/csympy/issues/events{/number}","events_url":"https://api.github.com/repos/isuruf/csympy/events","assignees_url":"https://api.github.com/repos/isuruf/csympy/assignees{/user}","branches_url":"https://api.github.com/repos/isuruf/csympy/branches{/branch}","tags_url":"https://api.github.com/repos/isuruf/csympy/tags","blobs_url":"https://api.github.com/repos/isuruf/csympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/isuruf/csympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/isuruf/csympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/isuruf/csympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/isuruf/csympy/statuses/{sha}","languages_url":"https://api.github.com/repos/isuruf/csympy/languages","stargazers_url":"https://api.github.com/repos/isuruf/csympy/stargazers","contributors_url":"https://api.github.com/repos/isuruf/csympy/contributors","subscribers_url":"https://api.github.com/repos/isuruf/csympy/subscribers","subscription_url":"https://api.github.com/repos/isuruf/csympy/subscription","commits_url":"https://api.github.com/repos/isuruf/csympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/isuruf/csympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/isuruf/csympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/isuruf/csympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/isuruf/csympy/contents/{+path}","compare_url":"https://api.github.com/repos/isuruf/csympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/isuruf/csympy/merges","archive_url":"https://api.github.com/repos/isuruf/csympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/isuruf/csympy/downloads","issues_url":"https://api.github.com/repos/isuruf/csympy/issues{/number}","pulls_url":"https://api.github.com/repos/isuruf/csympy/pulls{/number}","milestones_url":"https://api.github.com/repos/isuruf/csympy/milestones{/number}","notifications_url":"https://api.github.com/repos/isuruf/csympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/isuruf/csympy/labels{/name}","releases_url":"https://api.github.com/repos/isuruf/csympy/releases{/id}","created_at":"2014-06-02T11:28:39Z","updated_at":"2014-12-29T14:46:07Z","pushed_at":"2015-04-16T06:04:39Z","git_url":"git://github.com/isuruf/csympy.git","ssh_url":"git@github.com:isuruf/csympy.git","clone_url":"https://github.com/isuruf/csympy.git","svn_url":"https://github.com/isuruf/csympy","homepage":"http://sympy.org","size":3101,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sympy:master","ref":"master","sha":"c7dbdd7d14fe1c0acf273bc83778ef12dde47c41","user":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"repo":{"id":42376,"name":"csympy","full_name":"sympy/csympy","owner":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sympy/csympy","description":"Fast symbolic manipulation library, written in C++","fork":false,"url":"https://api.github.com/repos/sympy/csympy","forks_url":"https://api.github.com/repos/sympy/csympy/forks","keys_url":"https://api.github.com/repos/sympy/csympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sympy/csympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sympy/csympy/teams","hooks_url":"https://api.github.com/repos/sympy/csympy/hooks","issue_events_url":"https://api.github.com/repos/sympy/csympy/issues/events{/number}","events_url":"https://api.github.com/repos/sympy/csympy/events","assignees_url":"https://api.github.com/repos/sympy/csympy/assignees{/user}","branches_url":"https://api.github.com/repos/sympy/csympy/branches{/branch}","tags_url":"https://api.github.com/repos/sympy/csympy/tags","blobs_url":"https://api.github.com/repos/sympy/csympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sympy/csympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sympy/csympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sympy/csympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sympy/csympy/statuses/{sha}","languages_url":"https://api.github.com/repos/sympy/csympy/languages","stargazers_url":"https://api.github.com/repos/sympy/csympy/stargazers","contributors_url":"https://api.github.com/repos/sympy/csympy/contributors","subscribers_url":"https://api.github.com/repos/sympy/csympy/subscribers","subscription_url":"https://api.github.com/repos/sympy/csympy/subscription","commits_url":"https://api.github.com/repos/sympy/csympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sympy/csympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sympy/csympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sympy/csympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sympy/csympy/contents/{+path}","compare_url":"https://api.github.com/repos/sympy/csympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sympy/csympy/merges","archive_url":"https://api.github.com/repos/sympy/csympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sympy/csympy/downloads","issues_url":"https://api.github.com/repos/sympy/csympy/issues{/number}","pulls_url":"https://api.github.com/repos/sympy/csympy/pulls{/number}","milestones_url":"https://api.github.com/repos/sympy/csympy/milestones{/number}","notifications_url":"https://api.github.com/repos/sympy/csympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sympy/csympy/labels{/name}","releases_url":"https://api.github.com/repos/sympy/csympy/releases{/id}","created_at":"2008-08-13T18:40:14Z","updated_at":"2015-04-17T19:06:26Z","pushed_at":"2015-04-17T19:06:26Z","git_url":"git://github.com/sympy/csympy.git","ssh_url":"git@github.com:sympy/csympy.git","clone_url":"https://github.com/sympy/csympy.git","svn_url":"https://github.com/sympy/csympy","homepage":"http://sympy.org","size":5363,"stargazers_count":52,"watchers_count":52,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":51,"mirror_url":null,"open_issues_count":68,"forks":51,"open_issues":68,"watchers":52,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/csympy/pulls/423"},"html":{"href":"https://github.com/sympy/csympy/pull/423"},"issue":{"href":"https://api.github.com/repos/sympy/csympy/issues/423"},"comments":{"href":"https://api.github.com/repos/sympy/csympy/issues/423/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/csympy/pulls/423/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/csympy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/csympy/pulls/423/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/csympy/statuses/7b587ab8cdacb680c9377eccc0bf8a70c41e8b0c"}}}}