Skip to content

Commit

Permalink
score: fix bug in sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Dynamos committed Mar 25, 2024
1 parent 9780c78 commit 18ac08f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 4 additions & 6 deletions materialyoucolor/score/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(


SCORE_OPTION_DEFAULTS = ScoreOptions(
desired=128,
desired=4,
fallback_color_argb=0xFF4285F4, # Google Blue.
filter=True, # Avoid unsuitable colors.
dislike_filter=False, # Fix globally disliked colors
Expand Down Expand Up @@ -85,11 +85,9 @@ def score(colors_to_population: dict, options: ScoreOptions = None) -> list[int]
chroma_score = (hct.chroma - Score.TARGET_CHROMA) * chroma_weight
score = proportion_score + chroma_score
scored_hct.append({"hct": hct, "score": score})

scored_hct.sort(
key=lambda x: -1 if x["score"] > 0 else (1 if x["score"] < 0 else 0)
)


scored_hct.sort(key=lambda x: x["score"] , reverse=True)

chosen_colors = []
for difference_degrees_ in range(90, 14, -1):
chosen_colors.clear()
Expand Down
1 change: 0 additions & 1 deletion tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
)
console.print(st)


def print_scheme(scheme_function, name):
print()
schemes = [scheme_function(rgb) for rgb in selected]
Expand Down

0 comments on commit 18ac08f

Please sign in to comment.