Skip to content

Commit

Permalink
Fix spelling and lint and types
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Dec 5, 2024
1 parent d237102 commit 7c57780
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion coloraide/average.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ def average(
w, b = cs.indexes()[1:] # type: ignore[attr-defined]
if color[w] + color[b] < 1:
color[w] = 1 - color[b]
elif math.isnan(color[hue_index]) and not math.isnan(color[cs.radial_index()]):
elif math.isnan(color[hue_index]) and not math.isnan(color[cs.radial_index()]): # type: ignore[attr-defined]
color[cs.radial_index()] = 0 # type: ignore[attr-defined]
return color
2 changes: 1 addition & 1 deletion docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
averaging, the color will be treated as if achromatic, setting saturation/chroma as necessary. This is needed to
prevent serialization of achromatic colors to a non-achromatic color when undefined values are resolved.
- **FIX**: Fully transparent colors should only contribute alpha in color averaging, regardless of `premultiply`
setting. This prevents fully transparent color channels, which provide no meaniful data, from distorting averages.
setting. This prevents fully transparent color channels, which provide no meaningful data, from distorting averages.
- **FIX**: When averaging in a polar space, if a color is considered achromatic but does not have an undefined hue,
the hue will be treated as undefined. Essentially the `powerless` parameter is now always `True`. This ensures that
achromatic colors properly contribute to the average without distorting the hue.
Expand Down
8 changes: 4 additions & 4 deletions docs/src/markdown/average.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Color.average(['purple', 'green', 'blue'])
Color.average(['purple', 'green', 'blue'], space='hsl')
```

It should be noted that when averaging colors with hues which are evently distributed around the color wheel, the result
It should be noted that when averaging colors with hues which are evenly distributed around the color wheel, the result
will produce an achromatic hue. When achromatic hues are produced during circular mean, the color will discard
chroma/saturation information, producing an achromatic color.

Expand All @@ -61,10 +61,10 @@ for i in range(12):

There are cases where this approach of averaging may not be desired. It may be that color averaging is desired without
considering transparency. If so, `premultiplied` can be disabled by setting it to `#!py False`. While the average of
transparency is calculated, it can be discared from the final result if desired.
transparency is calculated, it can be discarded from the final result if desired.

It should be noted that when a color is fully transparent, its color components will be ignored, regardless of the
`premultiplied` parameter, as fully transparent colors provide no meaniful color information.
`premultiplied` parameter, as fully transparent colors provide no meaningful color information.

```py play
for i in range(12):
Expand All @@ -84,7 +84,7 @@ Color.average(['white', 'color(srgb 0 0 1)'], space='hsl')
```

When averaging hues in a polar space, implied achromatic hues are also treated as undefined as counting such hues would
distort the average in a non-meaniful way.
distort the average in a non-meaningful way.

```py play
Color.average(['hsl(30 0 100)', 'hsl(240 100 50 / 1)'], space='hsl')
Expand Down
2 changes: 1 addition & 1 deletion tools/average_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def iter_image(img, space, no_resize):
if im.mode not in ('RGBA',):
im = im.convert('RGBA')

if not no_resize and im.size[0] > 500 or im.size[1] > 500:
if not no_resize and (im.size[0] > 500 or im.size[1] > 500):
factor = 500 / max(im.size)
new_im = im.resize((max(1, int(im.size[0] * factor)), max(1, int(im.size[1] * factor))))
else:
Expand Down

0 comments on commit 7c57780

Please sign in to comment.