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

Refactor Colors using itertools #31

Merged
merged 3 commits into from Oct 8, 2019

Conversation

@Oxylibrium
Copy link
Contributor

commented Oct 7, 2019

Improve code readability by using itertools.zip_longest(), zip() and moving clamp() to a separate static method.

Does not change behaviour.

Copy link
Owner

left a comment

Clamp should have a default min/max of 0..255 but should have params to change this.
These code snippets can then also all use the clamp method:

if percent < 0 or percent > 1:
percent = 0.5

if percent1 < 0 or percent1 > 1:
percent1 = 1
if percent2 < 0 or percent2 > 1:
percent2 = 1

(These can just clamp instead of reverting to a default)

@Oxylibrium

This comment has been minimized.

Copy link
Contributor Author

commented Oct 7, 2019

Clamp as of right now returns an integer, but to clamp percentage means it'll have to return floats too. Should I define a type Number = Union[int, float] above for the function?

@MattIPv4

This comment has been minimized.

Copy link
Owner

commented Oct 7, 2019

You can just set the return type to be the union, not point creating a custom type for it.

@Oxylibrium Oxylibrium requested a review from MattIPv4 Oct 7, 2019
@Oxylibrium

This comment has been minimized.

Copy link
Contributor Author

commented Oct 8, 2019

Tests on Scrutinizer have completed a long time ago but still show as pending, there's some kind of bug.

PyDMXControl/_Colors.py Outdated Show resolved Hide resolved
PyDMXControl/_Colors.py Outdated Show resolved Hide resolved
@Oxylibrium Oxylibrium requested a review from MattIPv4 Oct 8, 2019
Copy link
Owner

left a comment

Lgtm. ❤️

@MattIPv4 MattIPv4 merged commit a319cd8 into MattIPv4:master Oct 8, 2019
4 checks passed
4 checks passed
Codacy/PR Quality Review Up to standards. A positive pull request.
Details
Scrutinizer Analysis: 3 updated code elements – Tests: passed
Details
WIP Ready for review
Details
codebeat no reportable quality changes
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.