py2ls 0.1.8.2__py3-none-any.whl → 0.1.8.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py2ls/ips.py
CHANGED
@@ -457,13 +457,15 @@ def str2date(date_str, fmt="%Y-%m-%d_%H:%M:%S"):
|
|
457
457
|
# print(str2)
|
458
458
|
|
459
459
|
|
460
|
-
def str2num(s, *args):
|
461
|
-
delimiter = None
|
462
|
-
round_digits = None
|
460
|
+
def str2num(s, *args, **kwargs):
|
461
|
+
delimiter = kwargs.get("sep", None)
|
462
|
+
round_digits = kwargs.get("round", None)
|
463
|
+
if delimiter is not None:
|
464
|
+
s = s.replace(delimiter, "")
|
463
465
|
for arg in args:
|
464
|
-
if isinstance(arg, str):
|
466
|
+
if isinstance(arg, str) and delimiter is None:
|
465
467
|
delimiter = arg
|
466
|
-
elif isinstance(arg, int):
|
468
|
+
elif isinstance(arg, int) and round_digits is None:
|
467
469
|
round_digits = arg
|
468
470
|
try:
|
469
471
|
num = int(s)
|
@@ -491,17 +493,17 @@ def str2num(s, *args):
|
|
491
493
|
"Multiple number segments found, cannot determine single numeric value"
|
492
494
|
)
|
493
495
|
except Exception as e:
|
494
|
-
|
496
|
+
return None
|
495
497
|
|
496
498
|
# Apply rounding if specified
|
497
499
|
if round_digits is not None:
|
498
500
|
num_adj = num + 0.00000000001 # Ensure precise rounding
|
499
501
|
num = round(num_adj, round_digits)
|
500
|
-
|
501
|
-
|
502
|
-
if delimiter is not None:
|
503
|
-
|
504
|
-
|
502
|
+
if round_digits == 0:
|
503
|
+
num = int(num)
|
504
|
+
# if delimiter is not None:
|
505
|
+
# num_str = f"{num:,}".replace(",", delimiter)
|
506
|
+
# return num_str#s.replace(delimiter, "")
|
505
507
|
|
506
508
|
return num
|
507
509
|
|
@@ -516,9 +518,9 @@ def str2num(s, *args):
|
|
516
518
|
# print(str2num("12345.6789", " ", 2)) # Output: 12 345.68
|
517
519
|
# print(str2num('111113.34555',3,',')) # Output: 111,113.346
|
518
520
|
# print(str2num("123.55555 sec miniuets",3)) # Output: 1.3
|
519
|
-
def num2str(num, *args):
|
520
|
-
delimiter = None
|
521
|
-
round_digits = None
|
521
|
+
def num2str(num, *args, **kwargs):
|
522
|
+
delimiter = kwargs.get("sep", None)
|
523
|
+
round_digits = kwargs.get("round", None)
|
522
524
|
|
523
525
|
# Parse additional arguments
|
524
526
|
for arg in args:
|
py2ls/plot.py
CHANGED
@@ -983,9 +983,8 @@ def get_color(
|
|
983
983
|
cmap: str = "auto",
|
984
984
|
by: str = "start",
|
985
985
|
alpha: float = 1.0,
|
986
|
-
output: str = "
|
986
|
+
output: str = "hue",
|
987
987
|
):
|
988
|
-
# Extract the colormap as a list
|
989
988
|
def cmap2hex(cmap_name):
|
990
989
|
cmap_ = matplotlib.pyplot.get_cmap(cmap_name)
|
991
990
|
colors = [cmap_(i) for i in range(cmap_.N)]
|
@@ -1018,6 +1017,22 @@ def get_color(
|
|
1018
1017
|
rgba_values = [hex_to_rgba(hex_color, alpha) for hex_color in hex_colors]
|
1019
1018
|
return rgba_values
|
1020
1019
|
|
1020
|
+
def rgba2hue(rgba_color):
|
1021
|
+
if len(rgba_color) == 3:
|
1022
|
+
r, g, b = rgba_color
|
1023
|
+
a = 1
|
1024
|
+
else:
|
1025
|
+
r, g, b, a = rgba_color
|
1026
|
+
# Convert each component to a scale of 0-255
|
1027
|
+
r = int(r * 255)
|
1028
|
+
g = int(g * 255)
|
1029
|
+
b = int(b * 255)
|
1030
|
+
a = int(a * 255)
|
1031
|
+
if a < 255:
|
1032
|
+
return "#{:02X}{:02X}{:02X}{:02X}".format(r, g, b, a)
|
1033
|
+
else:
|
1034
|
+
return "#{:02X}{:02X}{:02X}".format(r, g, b)
|
1035
|
+
|
1021
1036
|
# Determine color list based on cmap parameter
|
1022
1037
|
if "aut" in cmap:
|
1023
1038
|
colorlist = [
|
@@ -1042,15 +1057,17 @@ def get_color(
|
|
1042
1057
|
for i in [int(i) for i in np.linspace(0, len(colorlist) - 1, n)]
|
1043
1058
|
]
|
1044
1059
|
|
1045
|
-
if
|
1060
|
+
if "rgb" in output.lower():
|
1046
1061
|
return hue2rgb(clist, alpha)
|
1047
|
-
elif
|
1048
|
-
|
1062
|
+
elif "h" in output.lower():
|
1063
|
+
hue_list = []
|
1064
|
+
[hue_list.append(rgba2hue(i)) for i in hue2rgb(clist, alpha)]
|
1065
|
+
return hue_list
|
1049
1066
|
else:
|
1050
1067
|
raise ValueError("Invalid output type. Choose 'rgb' or 'hue'.")
|
1051
1068
|
|
1052
1069
|
# # Example usage
|
1053
|
-
# colors = get_color(n=5, cmap="viridis", by="linear", alpha=0.5)
|
1070
|
+
# colors = get_color(n=5, cmap="viridis", by="linear", alpha=0.5,output='rgb')
|
1054
1071
|
# print(colors)
|
1055
1072
|
|
1056
1073
|
|
@@ -134,14 +134,14 @@ py2ls/db2ls.py,sha256=MMfFX47aIPIyu7fU9aPvX9lbPRPYOpJ_VXwlnWk-8qo,13615
|
|
134
134
|
py2ls/doc.py,sha256=xN3g1OWfoaGUhikbJ0NqbN5eKy1VZVvWwRlhHMgyVEc,4243
|
135
135
|
py2ls/export_requirements.py,sha256=x2WgUF0jYKz9GfA1MVKN-MdsM-oQ8yUeC6Ua8oCymio,2325
|
136
136
|
py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
|
137
|
-
py2ls/ips.py,sha256=
|
137
|
+
py2ls/ips.py,sha256=mBFTARM6Pvj5EaVRR05CXCBlyNcbX2JfMQWBjnxONjI,100773
|
138
138
|
py2ls/netfinder.py,sha256=MY_0TQY_zaRBZ6wfR4RxNCGrU93HFmDVDRRy1EXl75o,47566
|
139
|
-
py2ls/plot.py,sha256=
|
139
|
+
py2ls/plot.py,sha256=WIAUDd4cRjFTX_Y_SWwsSw9_gIQF_Ye6R_-MvhB9G1k,50437
|
140
140
|
py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
|
141
141
|
py2ls/sleep_events_detectors.py,sha256=bQA3HJqv5qnYKJJEIhCyhlDtkXQfIzqksnD0YRXso68,52145
|
142
142
|
py2ls/stats.py,sha256=Wd9yCKQ_61QD29WMEgMuEcreFxF91NmlPW65iWT2B5w,39041
|
143
143
|
py2ls/translator.py,sha256=bc5FB-wqC4TtQz9gyCP1mE38HqNRJ_pmuRIgKnAlMzM,30581
|
144
144
|
py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
|
145
|
-
py2ls-0.1.8.
|
146
|
-
py2ls-0.1.8.
|
147
|
-
py2ls-0.1.8.
|
145
|
+
py2ls-0.1.8.4.dist-info/METADATA,sha256=ieFZ6Fgi3Tw6gIm1kdxkpLbk3XMgEwJ7uUIZTjSr-eo,20017
|
146
|
+
py2ls-0.1.8.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
147
|
+
py2ls-0.1.8.4.dist-info/RECORD,,
|
File without changes
|