Skip to content

Commit

Permalink
iss #381 updated tests for adjust_color_lightness
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaMorandi committed May 12, 2023
1 parent 49ca05b commit 0093ec3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tests/test_plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import brightwind as bw
from brightwind.analyse import plot as bw_plt
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
Expand Down Expand Up @@ -152,15 +153,21 @@ def test_adjust_color_lightness():
input_color = '#9CC537'
r, g, b = tuple(255 * np.array(mpl.colors.to_rgb(input_color)))
hue, lightness, saturation = rgb2hls(r / 255, g / 255, b / 255)
r, g, b = tuple(255 * np.array(mpl.colors.to_rgb(bw.analyse.plot._adjust_color_lightness(input_color, 0.1))))
r, g, b = tuple(255 * np.array(mpl.colors.to_rgb(bw_plt.COLOR_PALETTE._adjust_color_lightness(
input_color, 0.1))))
hue1, lightness1, saturation1 = rgb2hls(r / 255, g / 255, b / 255)
assert (int(hue * 100) == int(hue1 * 100)) and (int(saturation * 100) == int(saturation1 * 100)) and \
(lightness1 == 0.1)

assert bw.analyse.plot._adjust_color_lightness(input_color, 0.1) == "#20280b" # darkest green, 10% of primary
assert bw.analyse.plot._adjust_color_lightness(input_color, 0.35) == "#6e8c27" # dark green, 35% of primary
assert bw.analyse.plot._adjust_color_lightness(input_color, 0.8) == "#d8e9af" # light green, 80% of primary
assert bw.analyse.plot._adjust_color_lightness(input_color, 0.9) == "#ecf4d7" # light green, 90% of primary
assert bw.analyse.plot._adjust_color_lightness(input_color, 0.95) == "#f5f9eb" # lightest green, 95% of primary
assert bw_plt.COLOR_PALETTE._adjust_color_lightness(
input_color, 0.1) == "#20280b" # darkest green, 10% of primary
assert bw_plt.COLOR_PALETTE._adjust_color_lightness(
input_color, 0.35) == "#6e8c27" # dark green, 35% of primary
assert bw_plt.COLOR_PALETTE._adjust_color_lightness(
input_color, 0.8) == "#d8e9af" # light green, 80% of primary
assert bw_plt.COLOR_PALETTE._adjust_color_lightness(
input_color, 0.9) == "#ecf4d7" # light green, 90% of primary
assert bw_plt.COLOR_PALETTE._adjust_color_lightness(
input_color, 0.95) == "#f5f9eb" # lightest green, 95% of primary


0 comments on commit 0093ec3

Please sign in to comment.