Skip to content

Bugfix: Manual page sizes now overwrite the default page size if they…#18664

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
ackbar345:mikkel/fix-manual-page-size
Oct 27, 2020
Merged

Bugfix: Manual page sizes now overwrite the default page size if they…#18664
opencv-pushbot merged 1 commit intoopencv:3.4from
ackbar345:mikkel/fix-manual-page-size

Conversation

@ackbar345
Copy link
Copy Markdown

Bugfix: Manual page sizes now overwrite the default page size if they are both specified.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • [ x] I agree to contribute to the project under Apache 2 License.
  • [ x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • [ x] The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you for contribution!

As a "bugfix" this patch should go into 3.4 branch first.
We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

So, please:

  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no needs to re-open PR, apply changes "inplace".

# page size dict (ISO standard, mm) for easy lookup. format - size: [width, height]
page_sizes = {"A0": [840, 1188], "A1": [594, 840], "A2": [420, 594], "A3": [297, 420], "A4": [210, 297],
"A5": [148, 210]}
page_width = page_sizes[page_size.upper()][0]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let make error messages user-friendly:

assert page_size.upper() in page_sizes, page_size.keys()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@alalek That wasn't originally my code, but I did some tests and those .upper() calls are redundant. The choices list in argparse enforces a 1 to 1 match on the user entered string and the keys in page_sizes. I just went ahead and removed it altogether.

@ackbar345 ackbar345 changed the base branch from master to 3.4 October 27, 2020 00:54
@ackbar345 ackbar345 force-pushed the mikkel/fix-manual-page-size branch from 19241ee to 817ae10 Compare October 27, 2020 01:00
… are both specified. Remove redudant .upper() call, 1 to 1 key matching enforced

by argparse choices.
@ackbar345 ackbar345 force-pushed the mikkel/fix-manual-page-size branch from 817ae10 to d011383 Compare October 27, 2020 01:24
@opencv-pushbot opencv-pushbot merged commit 4a07607 into opencv:3.4 Oct 27, 2020
@alalek alalek mentioned this pull request Oct 28, 2020
@alalek alalek mentioned this pull request Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants