Skip to content

Commit

Permalink
fix: similar percentage for colors
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinKweyu committed May 16, 2024
1 parent 0cd682c commit 0ad15b6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
34 changes: 20 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
repos:
- repo: https://github.com/ambv/black
rev: 22.8.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
language_version: python3
- repo: https://github.com/ambv/black
rev: 22.8.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
language_version: python3

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
skip: []
submodules: false
5 changes: 2 additions & 3 deletions colordetect/color_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,8 @@ def _find_unique_colors(self, cluster, centroids) -> dict:
hist /= hist.sum()

# iterate through each cluster's color and percentage
colors = sorted(
[((percent * 100), color) for (percent, color) in zip(hist, centroids)]
)
colors = [(percent * 100, color) for (percent, color) in zip(hist, centroids)]
colors.sort(key=lambda x: (x[0], id(x[1])))

for (percent, color) in colors:
color.astype("uint8").tolist()
Expand Down

0 comments on commit 0ad15b6

Please sign in to comment.