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

Rename drawing areas to cells #47

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Rename drawing areas to cells #47

merged 1 commit into from
Oct 15, 2024

Conversation

mportesdev
Copy link
Owner

@mportesdev mportesdev commented Oct 15, 2024

  • core: rename fill_area keywords to fill_cell
  • core: rename _Area to _Box
  • CLI: rename the -a/--fill-area option to -c/--fill-cell

- core: rename `fill_area` keywords to `fill_cell`
- core: rename `_Area` to `_Box`
- CLI: rename the `-a`/`--fill-area` option to `-c`/`--fill-cell`
Copy link

sourcery-ai bot commented Oct 15, 2024

Reviewer's Guide by Sourcery

This pull request renames "drawing areas" to "cells" throughout the codebase, affecting both the internal implementation and the public API. The changes are primarily focused on variable and function naming, with some adjustments to documentation and comments to reflect the new terminology.

Updated class diagram for PictureShow

classDiagram
    class PictureShow {
        +_position_and_size(pic_size, cell_size, stretch_small, fill_cell)
        +_cells(layout, page_size, margin)
    }
    class _Box {
        +x
        +y
        +width
        +height
    }
    PictureShow --> _Box
    note for PictureShow "Methods renamed to use 'cell' instead of 'area'"
    note for _Box "Renamed from _Area to _Box"
Loading

File-Level Changes

Change Details Files
Rename 'area' to 'cell' in function and variable names
  • Rename 'fill_area' parameter to 'fill_cell'
  • Update '_Area' namedtuple to '_Box'
  • Rename '_areas' method to '_cells'
  • Update variable names (e.g., 'area_size' to 'cell_size')
  • Modify docstrings and comments to reflect new terminology
src/pictureshow/core.py
tests/unit_test.py
Update CLI interface to use 'cell' terminology
  • Rename '-a/--fill-area' option to '-c/--fill-cell'
  • Update help text to use 'cell' instead of 'drawing area'
src/pictureshow/cli.py
Adjust test cases to reflect new 'cell' terminology
  • Rename test functions (e.g., 'test_fill_area' to 'test_fill_cell')
  • Update test class name from 'TestAreas' to 'TestCells'
tests/unit_test.py
tests/test_pictures_to_pdf.py
Add changelog entry for breaking changes
  • Document API changes: 'fill_area' to 'fill_cell'
  • Document CLI option changes: '-a/--fill-area' to '-c/--fill-cell'
changelog.d/20241015_095444_michalportes1_cell_box.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @mportesdev - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 2 issues found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +214 to +215
cell_width = (page_width - (num_columns + 1) * margin) / num_columns
cell_height = (page_height - (num_rows + 1) * margin) / num_rows
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Use math.floor() to ensure integer values for cell dimensions

The calculation of cell_width and cell_height could result in floating-point values. Consider using math.floor() to ensure integer values, which could prevent potential issues with pixel-perfect layouts.

import math

cell_width = math.floor((page_width - (num_columns + 1) * margin) / num_columns)
cell_height = math.floor((page_height - (num_rows + 1) * margin) / num_rows)

-m, --margin MARGIN set width of empty space around the cells containing
pictures; default is 72 (72 points = 1 inch)
-s, --stretch-small scale small pictures up to fit cells
-c, --fill-cell fill cells with pictures, ignoring the pictures'
Copy link

Choose a reason for hiding this comment

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

suggestion (documentation): Consider highlighting the change from -a to -c option

This is a breaking change that might affect existing scripts. It might be helpful to add a note about this change in a prominent place in the README, in addition to the changelog entry.

Suggested change
-c, --fill-cell fill cells with pictures, ignoring the pictures'
-c, --fill-cell fill cells with pictures, ignoring the pictures'
aspect ratio (formerly -a option)

-->
### Breaking changes

- Library API: `fill_area` keyword parameters renamed to `fill_cell`
Copy link

Choose a reason for hiding this comment

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

nitpick (documentation): Typo: 'parameters' should be 'parameter'

Comment on lines +510 to +512
for cell in cells:
assert cell.x == margin
assert cell.width == expected_width
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Avoid loops in tests. (no-loop-in-tests)

ExplanationAvoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:

  • loops
  • conditionals

Some ways to fix this:

  • Use parametrized tests to get rid of the loop.
  • Move the complex logic into helpers.
  • Move the complex part into pytest fixtures.

Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / Don't Put Logic in Tests

Comment on lines +531 to +533
for cell in cells:
assert cell.y == margin
assert cell.height == expected_height
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Avoid loops in tests. (no-loop-in-tests)

ExplanationAvoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:

  • loops
  • conditionals

Some ways to fix this:

  • Use parametrized tests to get rid of the loop.
  • Move the complex logic into helpers.
  • Move the complex part into pytest fixtures.

Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / Don't Put Logic in Tests

Comment on lines +548 to +549
for cell in cells[::3]:
assert cell.x == margin
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Avoid loops in tests. (no-loop-in-tests)

ExplanationAvoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:

  • loops
  • conditionals

Some ways to fix this:

  • Use parametrized tests to get rid of the loop.
  • Move the complex logic into helpers.
  • Move the complex part into pytest fixtures.

Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / Don't Put Logic in Tests

Comment on lines +552 to +553
for cell in cells[6:]:
assert cell.y == margin
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Avoid loops in tests. (no-loop-in-tests)

ExplanationAvoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:

  • loops
  • conditionals

Some ways to fix this:

  • Use parametrized tests to get rid of the loop.
  • Move the complex logic into helpers.
  • Move the complex part into pytest fixtures.

Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / Don't Put Logic in Tests

@mportesdev mportesdev merged commit fdf706a into main Oct 15, 2024
12 checks passed
@mportesdev mportesdev deleted the cell branch October 15, 2024 09:32
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.

1 participant