{"action":"created","issue":{"url":"https://api.github.com/repos/blaze/datashape/issues/214","repository_url":"https://api.github.com/repos/blaze/datashape","labels_url":"https://api.github.com/repos/blaze/datashape/issues/214/labels{/name}","comments_url":"https://api.github.com/repos/blaze/datashape/issues/214/comments","events_url":"https://api.github.com/repos/blaze/datashape/issues/214/events","html_url":"https://github.com/blaze/datashape/issues/214","id":153107552,"number":214,"title":"promote(string, ?string) still returns ?object","user":{"login":"richafrank","id":2123660,"avatar_url":"https://avatars.githubusercontent.com/u/2123660?v=3","gravatar_id":"","url":"https://api.github.com/users/richafrank","html_url":"https://github.com/richafrank","followers_url":"https://api.github.com/users/richafrank/followers","following_url":"https://api.github.com/users/richafrank/following{/other_user}","gists_url":"https://api.github.com/users/richafrank/gists{/gist_id}","starred_url":"https://api.github.com/users/richafrank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richafrank/subscriptions","organizations_url":"https://api.github.com/users/richafrank/orgs","repos_url":"https://api.github.com/users/richafrank/repos","events_url":"https://api.github.com/users/richafrank/events{/privacy}","received_events_url":"https://api.github.com/users/richafrank/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/blaze/datashape/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/blaze/datashape/labels/promotion","name":"promotion","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/blaze/datashape/milestones/8","html_url":"https://github.com/blaze/datashape/milestones/0.5.3","labels_url":"https://api.github.com/repos/blaze/datashape/milestones/8/labels","id":1749904,"number":8,"title":"0.5.3","description":"","creator":{"login":"kwmsmith","id":288771,"avatar_url":"https://avatars.githubusercontent.com/u/288771?v=3","gravatar_id":"","url":"https://api.github.com/users/kwmsmith","html_url":"https://github.com/kwmsmith","followers_url":"https://api.github.com/users/kwmsmith/followers","following_url":"https://api.github.com/users/kwmsmith/following{/other_user}","gists_url":"https://api.github.com/users/kwmsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/kwmsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwmsmith/subscriptions","organizations_url":"https://api.github.com/users/kwmsmith/orgs","repos_url":"https://api.github.com/users/kwmsmith/repos","events_url":"https://api.github.com/users/kwmsmith/events{/privacy}","received_events_url":"https://api.github.com/users/kwmsmith/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":0,"state":"open","created_at":"2016-05-05T15:31:15Z","updated_at":"2016-05-05T15:31:50Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-05-04T20:30:00Z","updated_at":"2016-05-05T16:52:16Z","closed_at":null,"body":"Hello,\r\n\r\nAfter updating to datashape==0.5.2, I had hoped that https://github.com/blaze/datashape/pull/213 would fix my issue, but it didn't.  I'd like\r\n```python\r\n>>> promote(dshape(\"string\"), dshape(\"{a: ?string}\").subshape['a'])\r\n```\r\nto return ```Option(ty=ctype(\"string\"))``` but it actually returns ```Option(ty=ctype(\"object\"))```.\r\n\r\nThe [special casing] (https://github.com/blaze/datashape/blob/master/datashape/promote.py#L45) added by that PR doesn't get hit because `dshape(\"string\") != ctype(\"string\")`:\r\n```python\r\n>>> dshape('{a: string}').subshape['a']\r\nctype(\"string\")\r\n>>> dshape('string')\r\ndshape(\"string\")\r\n>>> dshape('{a: string}').subshape['a'] == dshape('string')\r\nFalse\r\n```\r\ni.e. a `Mono` leaf node in the datashape tree does not compare equal to a `DataShape` node wrapping that leaf node.  \r\n\r\nIdeally, I'd like to be able to compare the lhs and rhs here as equal.  In talking with @llllllllll, we saw a couple options:\r\n\r\n1. Change `DataShape.__eq__` to compare only `shape` and `measure` instead of type.\r\n1. Remove the box when the tree is only a box around the Mono, possibly by short circuiting `DataShape.__new__` and returning the single `Mono` parameter.  This looks to require updating blaze as well, since there are checks for whether a `DataShape` is being passed around, and this change would mean `dshape(\"string\")` would NOT return a `DataShape` instance.\r\n\r\nDo you agree with the intent here?  What's the right path?"},"comment":{"url":"https://api.github.com/repos/blaze/datashape/issues/comments/217208631","html_url":"https://github.com/blaze/datashape/issues/214#issuecomment-217208631","issue_url":"https://api.github.com/repos/blaze/datashape/issues/214","id":217208631,"user":{"login":"kwmsmith","id":288771,"avatar_url":"https://avatars.githubusercontent.com/u/288771?v=3","gravatar_id":"","url":"https://api.github.com/users/kwmsmith","html_url":"https://github.com/kwmsmith","followers_url":"https://api.github.com/users/kwmsmith/followers","following_url":"https://api.github.com/users/kwmsmith/following{/other_user}","gists_url":"https://api.github.com/users/kwmsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/kwmsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwmsmith/subscriptions","organizations_url":"https://api.github.com/users/kwmsmith/orgs","repos_url":"https://api.github.com/users/kwmsmith/repos","events_url":"https://api.github.com/users/kwmsmith/events{/privacy}","received_events_url":"https://api.github.com/users/kwmsmith/received_events","type":"User","site_admin":false},"created_at":"2016-05-05T16:52:16Z","updated_at":"2016-05-05T16:52:16Z","body":"OK, looking into it a bit more, I've generalized `Mono.__eq__` thusly:\r\n\r\n```python\r\n    def __eq__(self, other):\r\n        return (issubclass(type(other), Mono) and\r\n                self.shape == other.shape and\r\n                self.measure.info() == other.measure.info())\r\n```\r\n\r\nAmong other things, this generalizes equality as one would expect so `dshape('?string') == Option('string')`.  The current implementation of `promote()` now works for your case, and I've added your case (and a few others) to `promote`'s tests.\r\n\r\nTesting blaze and odo with this change, their testsuites all pass without issue."}}