Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export_bug_dx_None #257

Merged
merged 2 commits into from
Jan 25, 2018
Merged

export_bug_dx_None #257

merged 2 commits into from
Jan 25, 2018

Conversation

will-moore
Copy link
Member

See https://trello.com/c/0TnhjDrs/1-export-bug-dx-none

This fixes a rarely seen bug (not sure how to reproduce it in normal use) in figure export.
Check that figure export still works as expected, with some images zoomed in and panned off-centre. Check cropped region is same in exported figure as in web.

@will-moore will-moore changed the title Handle missing 'dx' and 'dy' in Export script export_bug_dx_None Dec 18, 2017
@jburel jburel added this to the 3.2.0 milestone Jan 4, 2018
@@ -774,8 +774,8 @@ def get_crop_region(self, panel):
zoom = float(panel['zoom'])
frame_w = panel['width']
frame_h = panel['height']
dx = panel['dx']
dy = panel['dy']
dx = panel.get('dx', 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you have code after checking if if dx > 0 (same for dy) it will be better to introduce a default value default_value= 0. So if later it changes it is only one place to adjust

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see that we'd ever want a default offset that wasn't zero.
The default for these offsets is really set in the panel_model.js and it's only rarely (not reproducible) that it's not set here in the script (so we have to catch it just in case).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 0 is set in get, this is "discovered" further down in another check
having a default value makes that clear and explicit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could introduce a variable with value 0 I think it will make the logic clearer

@will-moore
Copy link
Member Author

@jburel Added default variable.

@jburel
Copy link
Member

jburel commented Jan 24, 2018

If you could also change if dx > 0: to if dx>DEFAULT_OFFSET same for dy

@will-moore
Copy link
Member Author

In that case, we really just need to know if dx is positive or negative and this has nothing to do with the default offset.
E.g. if the default offset was 100, we'd still need to know that dx is positive (not if it was different from 100).

@jburel
Copy link
Member

jburel commented Jan 25, 2018

understood
everything seems to work now merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants