MCPcopy Index your code
hub / github.com/nalepae/pandarallel / ProgressBarsNotebookLab

Class ProgressBarsNotebookLab

pandarallel/progress_bars.py:121–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119
120
121class ProgressBarsNotebookLab(ProgressBars):
122 def __init__(self, maxs: List[int], show: bool) -> None:
123 """Initialization.
124 Positional argument:
125 maxs - List containing the max value of each progress bar
126 """
127 self.__show = show
128
129 if not show:
130 return
131
132 from IPython.display import display
133 from ipywidgets import HBox, IntProgress, Label, VBox
134
135 self.__bars = [
136 HBox(
137 [
138 IntProgress(0, 0, max, description="{:.2f}%".format(0)),
139 Label("{} / {}".format(0, max)),
140 ]
141 )
142 for max in maxs
143 ]
144
145 display(VBox(self.__bars))
146
147 def update(self, values: List[int]) -> None:
148 """Update a bar value.
149 Positional arguments:
150 values - The new values of each bar
151 """
152 if not self.__show:
153 return
154
155 for index, value in enumerate(values):
156 bar, label = self.__bars[index].children
157
158 bar.value = value
159 bar.description = "{:.2f}%".format(value / bar.max * 100)
160
161 if value >= bar.max:
162 bar.bar_style = "success"
163
164 label.value = "{} / {}".format(value, bar.max)
165
166 def set_error(self, index: int) -> None:
167 """Set a bar on error"""
168 if not self.__show:
169 return
170
171 bar, _ = self.__bars[index].children
172 bar.bar_style = "danger"
173
174
175def get_progress_bars(

Callers 1

get_progress_barsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…