{"action":"created","comment":{"url":"https://api.github.com/repos/astropy/astropy/pulls/comments/87886213","pull_request_review_id":8479338,"id":87886213,"diff_hunk":"@@ -382,18 +384,43 @@ class JsonCustomEncoder(json.JSONEncoder):\n \n     \"\"\"\n     def default(self, obj):\n+        from .. import units as u\n         import numpy as np\n-        if isinstance(obj, (np.ndarray, np.number)):\n+        if isinstance(obj, np.number):\n+            return obj.tolist()\n+        elif isinstance(obj, u.Quantity):\n+            return dict(value=obj.value, unit=obj.unit.to_string())\n+        elif isinstance(obj, np.ndarray):  # Must come after Quantity\n             return obj.tolist()\n         elif isinstance(obj, (complex, np.complex)):\n             return [obj.real, obj.imag]\n         elif isinstance(obj, set):\n             return list(obj)\n         elif isinstance(obj, bytes):  # pragma: py3\n             return obj.decode()\n+        elif isinstance(obj, u.UnitBase):\n+            return obj.name\n+        elif obj is u.dimensionless_unscaled:","path":"astropy/utils/misc.py","position":30,"original_position":30,"commit_id":"46441e82e8d0b98db39bde864a0ed5450c793b92","original_commit_id":"46441e82e8d0b98db39bde864a0ed5450c793b92","user":{"login":"mhvk","id":2789820,"avatar_url":"https://avatars.githubusercontent.com/u/2789820?v=3","gravatar_id":"","url":"https://api.github.com/users/mhvk","html_url":"https://github.com/mhvk","followers_url":"https://api.github.com/users/mhvk/followers","following_url":"https://api.github.com/users/mhvk/following{/other_user}","gists_url":"https://api.github.com/users/mhvk/gists{/gist_id}","starred_url":"https://api.github.com/users/mhvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhvk/subscriptions","organizations_url":"https://api.github.com/users/mhvk/orgs","repos_url":"https://api.github.com/users/mhvk/repos","events_url":"https://api.github.com/users/mhvk/events{/privacy}","received_events_url":"https://api.github.com/users/mhvk/received_events","type":"User","site_admin":false},"body":"Since `isinstance(u.dimensionless_unscaled, u.UnitBase)` is true, this needs to be rewritten (and tested!). Since it also is not a unique unit, I would write:\r\n```\r\nelif isinstance(obj, (u.UnitBase, u.FunctionUnitBase)):\r\n    if obj == u.dimensionless_unscaled:\r\n        obj = 'dimensionless_unit'\r\n    else:\r\n        obj = obj.to_string()\r\n```\r\n(note the inclusion of function units here -- we do need #3650... -- as well as the use of `to_string` instead of `name`, which I think is more reliable).","created_at":"2016-11-14T20:31:32Z","updated_at":"2016-11-14T20:31:32Z","html_url":"https://github.com/astropy/astropy/pull/5471#discussion_r87886213","pull_request_url":"https://api.github.com/repos/astropy/astropy/pulls/5471","_links":{"self":{"href":"https://api.github.com/repos/astropy/astropy/pulls/comments/87886213"},"html":{"href":"https://github.com/astropy/astropy/pull/5471#discussion_r87886213"},"pull_request":{"href":"https://api.github.com/repos/astropy/astropy/pulls/5471"}}},"pull_request":{"url":"https://api.github.com/repos/astropy/astropy/pulls/5471","id":93626352,"html_url":"https://github.com/astropy/astropy/pull/5471","diff_url":"https://github.com/astropy/astropy/pull/5471.diff","patch_url":"https://github.com/astropy/astropy/pull/5471.patch","issue_url":"https://api.github.com/repos/astropy/astropy/issues/5471","number":5471,"state":"open","locked":false,"title":"Expand JsonCustomEncoder","user":{"login":"profxj","id":3998093,"avatar_url":"https://avatars.githubusercontent.com/u/3998093?v=3","gravatar_id":"","url":"https://api.github.com/users/profxj","html_url":"https://github.com/profxj","followers_url":"https://api.github.com/users/profxj/followers","following_url":"https://api.github.com/users/profxj/following{/other_user}","gists_url":"https://api.github.com/users/profxj/gists{/gist_id}","starred_url":"https://api.github.com/users/profxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/profxj/subscriptions","organizations_url":"https://api.github.com/users/profxj/orgs","repos_url":"https://api.github.com/users/profxj/repos","events_url":"https://api.github.com/users/profxj/events{/privacy}","received_events_url":"https://api.github.com/users/profxj/received_events","type":"User","site_admin":false},"body":"Adds support for several astropy-specific objects including\nunits and Quantity.\n\nAlso includes a simple method to use in place of json.dumps\nfor those less accustomed to its syntax:  astropy.utils.misc.jsondumps\n\nIncludes new tests (passing tests on Travis)","created_at":"2016-11-14T19:02:56Z","updated_at":"2016-11-14T20:31:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a8d0c17368988972527f2b749e78b72026362ed","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/astropy/astropy/pulls/5471/commits","review_comments_url":"https://api.github.com/repos/astropy/astropy/pulls/5471/comments","review_comment_url":"https://api.github.com/repos/astropy/astropy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/5471/comments","statuses_url":"https://api.github.com/repos/astropy/astropy/statuses/46441e82e8d0b98db39bde864a0ed5450c793b92","head":{"label":"profxj:jsonify","ref":"jsonify","sha":"46441e82e8d0b98db39bde864a0ed5450c793b92","user":{"login":"profxj","id":3998093,"avatar_url":"https://avatars.githubusercontent.com/u/3998093?v=3","gravatar_id":"","url":"https://api.github.com/users/profxj","html_url":"https://github.com/profxj","followers_url":"https://api.github.com/users/profxj/followers","following_url":"https://api.github.com/users/profxj/following{/other_user}","gists_url":"https://api.github.com/users/profxj/gists{/gist_id}","starred_url":"https://api.github.com/users/profxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/profxj/subscriptions","organizations_url":"https://api.github.com/users/profxj/orgs","repos_url":"https://api.github.com/users/profxj/repos","events_url":"https://api.github.com/users/profxj/events{/privacy}","received_events_url":"https://api.github.com/users/profxj/received_events","type":"User","site_admin":false},"repo":{"id":73720431,"name":"astropy","full_name":"profxj/astropy","owner":{"login":"profxj","id":3998093,"avatar_url":"https://avatars.githubusercontent.com/u/3998093?v=3","gravatar_id":"","url":"https://api.github.com/users/profxj","html_url":"https://github.com/profxj","followers_url":"https://api.github.com/users/profxj/followers","following_url":"https://api.github.com/users/profxj/following{/other_user}","gists_url":"https://api.github.com/users/profxj/gists{/gist_id}","starred_url":"https://api.github.com/users/profxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/profxj/subscriptions","organizations_url":"https://api.github.com/users/profxj/orgs","repos_url":"https://api.github.com/users/profxj/repos","events_url":"https://api.github.com/users/profxj/events{/privacy}","received_events_url":"https://api.github.com/users/profxj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/profxj/astropy","description":"Repository for the Astropy core package","fork":true,"url":"https://api.github.com/repos/profxj/astropy","forks_url":"https://api.github.com/repos/profxj/astropy/forks","keys_url":"https://api.github.com/repos/profxj/astropy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/profxj/astropy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/profxj/astropy/teams","hooks_url":"https://api.github.com/repos/profxj/astropy/hooks","issue_events_url":"https://api.github.com/repos/profxj/astropy/issues/events{/number}","events_url":"https://api.github.com/repos/profxj/astropy/events","assignees_url":"https://api.github.com/repos/profxj/astropy/assignees{/user}","branches_url":"https://api.github.com/repos/profxj/astropy/branches{/branch}","tags_url":"https://api.github.com/repos/profxj/astropy/tags","blobs_url":"https://api.github.com/repos/profxj/astropy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/profxj/astropy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/profxj/astropy/git/refs{/sha}","trees_url":"https://api.github.com/repos/profxj/astropy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/profxj/astropy/statuses/{sha}","languages_url":"https://api.github.com/repos/profxj/astropy/languages","stargazers_url":"https://api.github.com/repos/profxj/astropy/stargazers","contributors_url":"https://api.github.com/repos/profxj/astropy/contributors","subscribers_url":"https://api.github.com/repos/profxj/astropy/subscribers","subscription_url":"https://api.github.com/repos/profxj/astropy/subscription","commits_url":"https://api.github.com/repos/profxj/astropy/commits{/sha}","git_commits_url":"https://api.github.com/repos/profxj/astropy/git/commits{/sha}","comments_url":"https://api.github.com/repos/profxj/astropy/comments{/number}","issue_comment_url":"https://api.github.com/repos/profxj/astropy/issues/comments{/number}","contents_url":"https://api.github.com/repos/profxj/astropy/contents/{+path}","compare_url":"https://api.github.com/repos/profxj/astropy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/profxj/astropy/merges","archive_url":"https://api.github.com/repos/profxj/astropy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/profxj/astropy/downloads","issues_url":"https://api.github.com/repos/profxj/astropy/issues{/number}","pulls_url":"https://api.github.com/repos/profxj/astropy/pulls{/number}","milestones_url":"https://api.github.com/repos/profxj/astropy/milestones{/number}","notifications_url":"https://api.github.com/repos/profxj/astropy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/profxj/astropy/labels{/name}","releases_url":"https://api.github.com/repos/profxj/astropy/releases{/id}","deployments_url":"https://api.github.com/repos/profxj/astropy/deployments","created_at":"2016-11-14T15:49:30Z","updated_at":"2016-11-14T15:49:35Z","pushed_at":"2016-11-14T18:59:48Z","git_url":"git://github.com/profxj/astropy.git","ssh_url":"git@github.com:profxj/astropy.git","clone_url":"https://github.com/profxj/astropy.git","svn_url":"https://github.com/profxj/astropy","homepage":"www.astropy.org","size":50247,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"astropy:master","ref":"master","sha":"a2d0fe7944153a4c87785537ea8416918b52c6d8","user":{"login":"astropy","id":847984,"avatar_url":"https://avatars.githubusercontent.com/u/847984?v=3","gravatar_id":"","url":"https://api.github.com/users/astropy","html_url":"https://github.com/astropy","followers_url":"https://api.github.com/users/astropy/followers","following_url":"https://api.github.com/users/astropy/following{/other_user}","gists_url":"https://api.github.com/users/astropy/gists{/gist_id}","starred_url":"https://api.github.com/users/astropy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astropy/subscriptions","organizations_url":"https://api.github.com/users/astropy/orgs","repos_url":"https://api.github.com/users/astropy/repos","events_url":"https://api.github.com/users/astropy/events{/privacy}","received_events_url":"https://api.github.com/users/astropy/received_events","type":"Organization","site_admin":false},"repo":{"id":2081289,"name":"astropy","full_name":"astropy/astropy","owner":{"login":"astropy","id":847984,"avatar_url":"https://avatars.githubusercontent.com/u/847984?v=3","gravatar_id":"","url":"https://api.github.com/users/astropy","html_url":"https://github.com/astropy","followers_url":"https://api.github.com/users/astropy/followers","following_url":"https://api.github.com/users/astropy/following{/other_user}","gists_url":"https://api.github.com/users/astropy/gists{/gist_id}","starred_url":"https://api.github.com/users/astropy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astropy/subscriptions","organizations_url":"https://api.github.com/users/astropy/orgs","repos_url":"https://api.github.com/users/astropy/repos","events_url":"https://api.github.com/users/astropy/events{/privacy}","received_events_url":"https://api.github.com/users/astropy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/astropy/astropy","description":"Repository for the Astropy core package","fork":false,"url":"https://api.github.com/repos/astropy/astropy","forks_url":"https://api.github.com/repos/astropy/astropy/forks","keys_url":"https://api.github.com/repos/astropy/astropy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/astropy/astropy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/astropy/astropy/teams","hooks_url":"https://api.github.com/repos/astropy/astropy/hooks","issue_events_url":"https://api.github.com/repos/astropy/astropy/issues/events{/number}","events_url":"https://api.github.com/repos/astropy/astropy/events","assignees_url":"https://api.github.com/repos/astropy/astropy/assignees{/user}","branches_url":"https://api.github.com/repos/astropy/astropy/branches{/branch}","tags_url":"https://api.github.com/repos/astropy/astropy/tags","blobs_url":"https://api.github.com/repos/astropy/astropy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/astropy/astropy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/astropy/astropy/git/refs{/sha}","trees_url":"https://api.github.com/repos/astropy/astropy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/astropy/astropy/statuses/{sha}","languages_url":"https://api.github.com/repos/astropy/astropy/languages","stargazers_url":"https://api.github.com/repos/astropy/astropy/stargazers","contributors_url":"https://api.github.com/repos/astropy/astropy/contributors","subscribers_url":"https://api.github.com/repos/astropy/astropy/subscribers","subscription_url":"https://api.github.com/repos/astropy/astropy/subscription","commits_url":"https://api.github.com/repos/astropy/astropy/commits{/sha}","git_commits_url":"https://api.github.com/repos/astropy/astropy/git/commits{/sha}","comments_url":"https://api.github.com/repos/astropy/astropy/comments{/number}","issue_comment_url":"https://api.github.com/repos/astropy/astropy/issues/comments{/number}","contents_url":"https://api.github.com/repos/astropy/astropy/contents/{+path}","compare_url":"https://api.github.com/repos/astropy/astropy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/astropy/astropy/merges","archive_url":"https://api.github.com/repos/astropy/astropy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/astropy/astropy/downloads","issues_url":"https://api.github.com/repos/astropy/astropy/issues{/number}","pulls_url":"https://api.github.com/repos/astropy/astropy/pulls{/number}","milestones_url":"https://api.github.com/repos/astropy/astropy/milestones{/number}","notifications_url":"https://api.github.com/repos/astropy/astropy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/astropy/astropy/labels{/name}","releases_url":"https://api.github.com/repos/astropy/astropy/releases{/id}","deployments_url":"https://api.github.com/repos/astropy/astropy/deployments","created_at":"2011-07-21T01:33:49Z","updated_at":"2016-11-12T15:19:11Z","pushed_at":"2016-11-14T19:02:56Z","git_url":"git://github.com/astropy/astropy.git","ssh_url":"git@github.com:astropy/astropy.git","clone_url":"https://github.com/astropy/astropy.git","svn_url":"https://github.com/astropy/astropy","homepage":"www.astropy.org","size":69626,"stargazers_count":1027,"watchers_count":1027,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":609,"mirror_url":null,"open_issues_count":798,"forks":609,"open_issues":798,"watchers":1027,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/astropy/astropy/pulls/5471"},"html":{"href":"https://github.com/astropy/astropy/pull/5471"},"issue":{"href":"https://api.github.com/repos/astropy/astropy/issues/5471"},"comments":{"href":"https://api.github.com/repos/astropy/astropy/issues/5471/comments"},"review_comments":{"href":"https://api.github.com/repos/astropy/astropy/pulls/5471/comments"},"review_comment":{"href":"https://api.github.com/repos/astropy/astropy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/astropy/astropy/pulls/5471/commits"},"statuses":{"href":"https://api.github.com/repos/astropy/astropy/statuses/46441e82e8d0b98db39bde864a0ed5450c793b92"}}}}
{"actor":{"display_login":"mhvk"}}