{"action":"created","issue":{"url":"https://api.github.com/repos/yt-project/yt/issues/1710","repository_url":"https://api.github.com/repos/yt-project/yt","labels_url":"https://api.github.com/repos/yt-project/yt/issues/1710/labels{/name}","comments_url":"https://api.github.com/repos/yt-project/yt/issues/1710/comments","events_url":"https://api.github.com/repos/yt-project/yt/issues/1710/events","html_url":"https://github.com/yt-project/yt/pull/1710","id":301132962,"number":1710,"title":"FixedResolutionBuffer image resolutions","user":{"login":"ngoldbaum","id":3126246,"avatar_url":"https://avatars2.githubusercontent.com/u/3126246?v=4","gravatar_id":"","url":"https://api.github.com/users/ngoldbaum","html_url":"https://github.com/ngoldbaum","followers_url":"https://api.github.com/users/ngoldbaum/followers","following_url":"https://api.github.com/users/ngoldbaum/following{/other_user}","gists_url":"https://api.github.com/users/ngoldbaum/gists{/gist_id}","starred_url":"https://api.github.com/users/ngoldbaum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngoldbaum/subscriptions","organizations_url":"https://api.github.com/users/ngoldbaum/orgs","repos_url":"https://api.github.com/users/ngoldbaum/repos","events_url":"https://api.github.com/users/ngoldbaum/events{/privacy}","received_events_url":"https://api.github.com/users/ngoldbaum/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-02-28T18:28:45Z","updated_at":"2018-02-28T23:20:07Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/yt-project/yt/pulls/1710","html_url":"https://github.com/yt-project/yt/pull/1710","diff_url":"https://github.com/yt-project/yt/pull/1710.diff","patch_url":"https://github.com/yt-project/yt/pull/1710.patch"},"body":"As noted in #1709, currently FixedResolutionBuffer will flip the image resolution for non-square buffers. The reason for this goes back to [Bitbucket pull request 2245](https://bitbucket.org/yt_analysis/yt/pull-requests/2245) where Matt rewrote how the pixelizers work. We actually had a similar problem even earlier than that that @yihaochen pointed out.\r\n\r\nThe basic issue is illustrated by this notebook:\r\n\r\nhttps://gist.github.com/anonymous/4ab071eb7284f17ae062a2aee927fbcd\r\n\r\nMatplotlib's imshow command interprets an image with shape (m, n) as m *rows* and n *columns*, which is backwards of yt's way of working with images where each pixel corresponds to an (x, y) location.\r\n\r\nMy proposed fix here is to make it so that if someone creates a FixedResolutionBuffer object manually or via a `to_frb` method hanging off a data object that we respect the resolution order specified by the user.\r\n\r\nTo maintain backwards compatibility for the way images look in `PlotWindow` plots and to comply with the natural user expectation that if I do `plot.set_buff_size((nx, ny))` there will be `nx` pixels along the x direction in the plot and `ny` pixels along the y direction, I've made it so that `set_buff_size` will reverse the order of the shape it passes to the `FixedResolutionBuffer` initializer. I've also added a note to the docstring of `set_buff_size` that this is the case to hopefully head off future confusion. I've also added comments throughout the codebase (or rewrote existing comments) to hopefully make it clearer to future readers of the codebase why we sometimes are reversing the image shape.\r\n\r\n# tl;dr\r\n\r\nNow when you create an FRB object directly, you get exactly the resolution you expect. The appearance of PlotWindow plots and the plot callbacks on a PlotWindow plot should be unaffected by this change."},"comment":{"url":"https://api.github.com/repos/yt-project/yt/issues/comments/369418427","html_url":"https://github.com/yt-project/yt/pull/1710#issuecomment-369418427","issue_url":"https://api.github.com/repos/yt-project/yt/issues/1710","id":369418427,"user":{"login":"yihaochen","id":2981181,"avatar_url":"https://avatars3.githubusercontent.com/u/2981181?v=4","gravatar_id":"","url":"https://api.github.com/users/yihaochen","html_url":"https://github.com/yihaochen","followers_url":"https://api.github.com/users/yihaochen/followers","following_url":"https://api.github.com/users/yihaochen/following{/other_user}","gists_url":"https://api.github.com/users/yihaochen/gists{/gist_id}","starred_url":"https://api.github.com/users/yihaochen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yihaochen/subscriptions","organizations_url":"https://api.github.com/users/yihaochen/orgs","repos_url":"https://api.github.com/users/yihaochen/repos","events_url":"https://api.github.com/users/yihaochen/events{/privacy}","received_events_url":"https://api.github.com/users/yihaochen/received_events","type":"User","site_admin":false},"created_at":"2018-02-28T23:20:07Z","updated_at":"2018-02-28T23:20:07Z","author_association":"CONTRIBUTOR","body":"It seems that I misunderstood the points of this PR. \r\nIf one uses `set_buff_size((nx, ny))`, the frb will still have shape `(ny, nx)`. This PR will only affect directly calling `to_frb`. When one calls `to_frb(width, (nx, ny))`, the resulting frb array will have shape `(nx, ny)`. Is this correct?"}}
{"actor":{"display_login":"yihaochen"}}