halib 0.1.40__py3-none-any.whl → 0.1.41__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.
halib/__init__.py CHANGED
@@ -23,6 +23,10 @@ __all__ = [
23
23
  "tcuda",
24
24
  "timebudget",
25
25
  "tqdm",
26
+ "rcolor_all_str",
27
+ "rcolor_palette",
28
+ "rcolor_str",
29
+ "rcolor_palette_all"
26
30
  ]
27
31
 
28
32
  import numpy as np
@@ -48,3 +52,4 @@ import arrow
48
52
  import omegaconf
49
53
  from omegaconf import OmegaConf
50
54
  from omegaconf.dictconfig import DictConfig
55
+ from .rich_color import rcolor_str, rcolor_palette, rcolor_palette_all, rcolor_all_str
halib/common.py CHANGED
@@ -43,7 +43,6 @@ def norm_str(in_str):
43
43
  norm_string = norm_string.strip()
44
44
  return norm_string
45
45
 
46
-
47
46
  def console_rule(msg, do_norm_msg=True, is_end_tag=False):
48
47
  msg = norm_str(msg) if do_norm_msg else msg
49
48
  if is_end_tag:
halib/rich_color.py ADDED
@@ -0,0 +1,259 @@
1
+ from rich.console import Console
2
+ from rich.pretty import pprint
3
+ from rich.table import Table
4
+ from rich.text import Text
5
+ from rich.panel import Panel
6
+
7
+ # List of colors
8
+ # ! https://rich.readthedocs.io/en/stable/appendix/colors.html
9
+ all_colors = [
10
+ "black",
11
+ "red",
12
+ "green",
13
+ "yellow",
14
+ "blue",
15
+ "magenta",
16
+ "cyan",
17
+ "white",
18
+ "bright_black",
19
+ "bright_red",
20
+ "bright_green",
21
+ "bright_yellow",
22
+ "bright_blue",
23
+ "bright_magenta",
24
+ "bright_cyan",
25
+ "bright_white",
26
+ "grey0",
27
+ "navy_blue",
28
+ "dark_blue",
29
+ "blue3",
30
+ "blue1",
31
+ "dark_green",
32
+ "deep_sky_blue4",
33
+ "dodger_blue3",
34
+ "dodger_blue2",
35
+ "green4",
36
+ "spring_green4",
37
+ "turquoise4",
38
+ "deep_sky_blue3",
39
+ "dodger_blue1",
40
+ "dark_cyan",
41
+ "light_sea_green",
42
+ "deep_sky_blue2",
43
+ "deep_sky_blue1",
44
+ "green3",
45
+ "spring_green3",
46
+ "cyan3",
47
+ "dark_turquoise",
48
+ "turquoise2",
49
+ "green1",
50
+ "spring_green2",
51
+ "spring_green1",
52
+ "medium_spring_green",
53
+ "cyan2",
54
+ "cyan1",
55
+ "purple4",
56
+ "purple3",
57
+ "blue_violet",
58
+ "grey37",
59
+ "medium_purple4",
60
+ "slate_blue3",
61
+ "royal_blue1",
62
+ "chartreuse4",
63
+ "pale_turquoise4",
64
+ "steel_blue",
65
+ "steel_blue3",
66
+ "cornflower_blue",
67
+ "dark_sea_green4",
68
+ "cadet_blue",
69
+ "sky_blue3",
70
+ "chartreuse3",
71
+ "sea_green3",
72
+ "aquamarine3",
73
+ "medium_turquoise",
74
+ "steel_blue1",
75
+ "sea_green2",
76
+ "sea_green1",
77
+ "dark_slate_gray2",
78
+ "dark_red",
79
+ "dark_magenta",
80
+ "orange4",
81
+ "light_pink4",
82
+ "plum4",
83
+ "medium_purple3",
84
+ "slate_blue1",
85
+ "wheat4",
86
+ "grey53",
87
+ "light_slate_grey",
88
+ "medium_purple",
89
+ "light_slate_blue",
90
+ "yellow4",
91
+ "dark_sea_green",
92
+ "light_sky_blue3",
93
+ "sky_blue2",
94
+ "chartreuse2",
95
+ "pale_green3",
96
+ "dark_slate_gray3",
97
+ "sky_blue1",
98
+ "chartreuse1",
99
+ "light_green",
100
+ "aquamarine1",
101
+ "dark_slate_gray1",
102
+ "deep_pink4",
103
+ "medium_violet_red",
104
+ "dark_violet",
105
+ "purple",
106
+ "medium_orchid3",
107
+ "medium_orchid",
108
+ "dark_goldenrod",
109
+ "rosy_brown",
110
+ "grey63",
111
+ "medium_purple2",
112
+ "medium_purple1",
113
+ "dark_khaki",
114
+ "navajo_white3",
115
+ "grey69",
116
+ "light_steel_blue3",
117
+ "light_steel_blue",
118
+ "dark_olive_green3",
119
+ "dark_sea_green3",
120
+ "light_cyan3",
121
+ "light_sky_blue1",
122
+ "green_yellow",
123
+ "dark_olive_green2",
124
+ "pale_green1",
125
+ "dark_sea_green2",
126
+ "pale_turquoise1",
127
+ "red3",
128
+ "deep_pink3",
129
+ "magenta3",
130
+ "dark_orange3",
131
+ "indian_red",
132
+ "hot_pink3",
133
+ "hot_pink2",
134
+ "orchid",
135
+ "orange3",
136
+ "light_salmon3",
137
+ "light_pink3",
138
+ "pink3",
139
+ "plum3",
140
+ "violet",
141
+ "gold3",
142
+ "light_goldenrod3",
143
+ "tan",
144
+ "misty_rose3",
145
+ "thistle3",
146
+ "plum2",
147
+ "yellow3",
148
+ "khaki3",
149
+ "light_yellow3",
150
+ "grey84",
151
+ "light_steel_blue1",
152
+ "yellow2",
153
+ "dark_olive_green1",
154
+ "dark_sea_green1",
155
+ "honeydew2",
156
+ "light_cyan1",
157
+ "red1",
158
+ "deep_pink2",
159
+ "deep_pink1",
160
+ "magenta2",
161
+ "magenta1",
162
+ "orange_red1",
163
+ "indian_red1",
164
+ "hot_pink",
165
+ "medium_orchid1",
166
+ "dark_orange",
167
+ "salmon1",
168
+ "light_coral",
169
+ "pale_violet_red1",
170
+ "orchid2",
171
+ "orchid1",
172
+ "orange1",
173
+ "sandy_brown",
174
+ "light_salmon1",
175
+ "light_pink1",
176
+ "pink1",
177
+ "plum1",
178
+ "gold1",
179
+ "light_goldenrod2",
180
+ "navajo_white1",
181
+ "misty_rose1",
182
+ "thistle1",
183
+ "yellow1",
184
+ "light_goldenrod1",
185
+ "khaki1",
186
+ "wheat1",
187
+ "cornsilk1",
188
+ "grey100",
189
+ "grey3",
190
+ "grey7",
191
+ "grey11",
192
+ "grey15",
193
+ "grey19",
194
+ "grey23",
195
+ "grey27",
196
+ "grey30",
197
+ "grey35",
198
+ "grey39",
199
+ "grey42",
200
+ "grey46",
201
+ "grey50",
202
+ "grey54",
203
+ "grey58",
204
+ "grey62",
205
+ "grey66",
206
+ "grey70",
207
+ "grey74",
208
+ "grey78",
209
+ "grey82",
210
+ "grey85",
211
+ "grey89",
212
+ "grey93",
213
+ ]
214
+
215
+ def rcolor_all_str():
216
+ pprint(all_colors)
217
+
218
+ def rcolor_str(in_str, color="white"):
219
+ assert color in all_colors, f"color must be one of {all_colors}"
220
+ return f"[{color}]{in_str}[/{color}]"
221
+
222
+ def rcolor_palette(color_list):
223
+ # make sure all colors are valid (in all_colors)
224
+ for color in color_list:
225
+ assert (
226
+ color in all_colors
227
+ ), f"color must be a valid color. call <rcolor_all_str()> or <rcolor_palette_all()> to see all valid colors"
228
+ # Initialize console
229
+ console = Console()
230
+
231
+ # Create a table with horizontal lines and six columns
232
+ table = Table(show_header=True, header_style="bold magenta", show_lines=True)
233
+
234
+ # Define the columns
235
+ table.add_column("Color Name 1", style="bold")
236
+ table.add_column("Sample 1", style="bold")
237
+ table.add_column("Color Name 2", style="bold")
238
+ table.add_column("Sample 2", style="bold")
239
+ table.add_column("Color Name 3", style="bold")
240
+ table.add_column("Sample 3", style="bold")
241
+
242
+ # Adjust the number of rows needed for the table
243
+ num_colors = len(color_list)
244
+ num_rows = (num_colors + 2) // 3 # Ceiling division to ensure all colors fit
245
+
246
+ # Add rows to the table
247
+ for i in range(num_rows):
248
+ color1 = color_list[i * 3] if i * 3 < num_colors else ""
249
+ color2 = color_list[i * 3 + 1] if i * 3 + 1 < num_colors else ""
250
+ color3 = color_list[i * 3 + 2] if i * 3 + 2 < num_colors else ""
251
+ filled_rect1 = Text(" " * 10, style=f"on {color1}") if color1 else ""
252
+ filled_rect2 = Text(" " * 10, style=f"on {color2}") if color2 else ""
253
+ filled_rect3 = Text(" " * 10, style=f"on {color3}") if color3 else ""
254
+ table.add_row(color1, filled_rect1, color2, filled_rect2, color3, filled_rect3)
255
+
256
+ # Print the table
257
+ console.print(table)
258
+ def rcolor_palette_all():
259
+ rcolor_palette(all_colors)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.40
3
+ Version: 0.1.41
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -42,6 +42,9 @@ Requires-Dist: tqdm
42
42
  Requires-Dist: tube-dl
43
43
 
44
44
  Helper package for coding and automation
45
+ **Version 0.1.41**
46
+ + add <rich_color.py> to display rich color information in <rich> python package (rcolor_str, rcolor_pallet_all, etc.)
47
+
45
48
  **Version 0.1.40**
46
49
 
47
50
  + update <csvfile.py> to use `itables` and `pygwalker` to display dataframe in jupyter notebook.
@@ -1,5 +1,5 @@
1
- halib/__init__.py,sha256=fmB0TlY6yyNyKOAFqj2JNp7vTgwc1JD2OYByOZW5cJI,999
2
- halib/common.py,sha256=TsUHMCTZQ1dYwIDqTHv38NzNNkFCNHNAr92Ghtxfd48,2041
1
+ halib/__init__.py,sha256=KrD3NLEgEE3mWparYxAu2iprtv6Al42zaDmECUpa_dE,1176
2
+ halib/common.py,sha256=28kBN56Ema1A1pIDF2B8BydepXy799L21o2cc01SANc,2039
3
3
  halib/csvfile.py,sha256=Eoeni0NIbNG3mB5ESWAvNwhJxOjmCaPd1qqYRHImbvk,1567
4
4
  halib/cuda.py,sha256=1bvtBY8QvTWdLaxalzK9wqXPl0Ft3AfhcrebupxGzEA,1010
5
5
  halib/dataset.py,sha256=QU0Hr5QFb8_XlvnOMgC9QJGIpwXAZ9lDd0RdQi_QRec,6743
@@ -11,6 +11,7 @@ halib/jsonfile.py,sha256=9XfdFS1wcTdBRmpAGzVu2dVCcJp8RCpsSY16f6KUNts,480
11
11
  halib/listop.py,sha256=Vpa8_2fI0wySpB2-8sfTBkyi_A4FhoFVVvFiuvW8N64,339
12
12
  halib/plot.py,sha256=4pUJ5GeKQ1LzgiQXbAZlUqSydXSk5tt2_qsw78nSzA4,9445
13
13
  halib/projectmake.py,sha256=8dNTxB2jgQlwvovaOnJcCKgHe5vM0nBwzm46Yc8INEI,4048
14
+ halib/rich_color.py,sha256=3048TppVjaJX7P0K3OpJZajH3_wlF6JLFFUKIOeuk3Q,5971
14
15
  halib/tele_noti.py,sha256=xL8f889VFR65uVJTj1NNT3qSi3lJ7s_iDjcObwZ0-V0,5926
15
16
  halib/textfile.py,sha256=EhVFrit-nRBJx18e6rtIqcE1cSbgsLnMXe_kdhi1EPI,399
16
17
  halib/torchloader.py,sha256=-q9YE-AoHZE1xQX2dgNxdqtucEXYs4sQ22WXdl6EGfI,6500
@@ -32,8 +33,8 @@ halib/sys/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
32
33
  halib/system/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
34
  halib/system/cmd.py,sha256=b2x7JPcNnFjLGheIESVYvqAb-w2UwBM1PAwYxMZ5YjA,228
34
35
  halib/system/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
35
- halib-0.1.40.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
36
- halib-0.1.40.dist-info/METADATA,sha256=eFwReuUr51KBxzpHNiwcsVJ9rlsvn1lGf7A9ZZ-i3PE,3344
37
- halib-0.1.40.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
38
- halib-0.1.40.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
39
- halib-0.1.40.dist-info/RECORD,,
36
+ halib-0.1.41.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
37
+ halib-0.1.41.dist-info/METADATA,sha256=c9F-wY1MFnD-88XjO2yCwtljfINAwxJlYrfWvbHzNVw,3483
38
+ halib-0.1.41.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
39
+ halib-0.1.41.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
40
+ halib-0.1.41.dist-info/RECORD,,
File without changes