Skip to content

Commit 6200869

Browse files
committed
REF: Avoid bokeh.colors.HSL deprecation warnings
1 parent e69cd5c commit 6200869

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

backtesting/_plotting.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
import re
33
import sys
44
import warnings
5+
from colorsys import hls_to_rgb, rgb_to_hls
56
from itertools import cycle, combinations
67
from functools import partial
78
from typing import Callable, List, Union
89

910
import numpy as np
1011
import pandas as pd
1112

13+
from bokeh.colors import RGB
1214
from bokeh.colors.named import (
1315
lime as BULL_COLOR,
1416
tomato as BEAR_COLOR
@@ -81,9 +83,10 @@ def colorgen():
8183

8284

8385
def lightness(color, lightness=.94):
84-
color = color.to_hsl()
85-
color.l = lightness # noqa
86-
return color.to_rgb()
86+
rgb = np.array([color.r, color.g, color.b]) / 255
87+
h, _, s = rgb_to_hls(*rgb)
88+
rgb = np.array(hls_to_rgb(h, lightness, s)) * 255
89+
return RGB(*rgb)
8790

8891

8992
_MAX_CANDLES = 10_000

0 commit comments

Comments
 (0)