MCPcopy
hub / github.com/tqdm/tqdm / __init__

Method __init__

tqdm/notebook.py:204–247  ·  view source on GitHub ↗

Supports the usual `tqdm.tqdm` parameters as well as those listed below. Parameters ---------- display : Whether to call `display(self.container)` immediately [default: True].

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

202 self.container.children[-2].style.bar_color = bar_color
203
204 def __init__(self, *args, **kwargs):
205 """
206 Supports the usual `tqdm.tqdm` parameters as well as those listed below.
207
208 Parameters
209 ----------
210 display : Whether to call `display(self.container)` immediately
211 [default: True].
212 """
213 kwargs = kwargs.copy()
214 # Setup default output
215 file_kwarg = kwargs.get('file', sys.stderr)
216 if file_kwarg is sys.stderr or file_kwarg is None:
217 kwargs['file'] = sys.stdout # avoid the red block in IPython
218
219 # Initialize parent class + avoid printing by using gui=True
220 kwargs['gui'] = True
221 # convert disable = None to False
222 kwargs['disable'] = bool(kwargs.get('disable', False))
223 colour = kwargs.pop('colour', None)
224 display_here = kwargs.pop('display', True)
225 super().__init__(*args, **kwargs)
226 if self.disable or not kwargs['gui']:
227 self.disp = lambda *_, **__: None
228 return
229
230 # Get bar width
231 self.ncols = '100%' if self.dynamic_ncols else kwargs.get("ncols", None)
232
233 # Replace with IPython progress bar display (with correct total)
234 unit_scale = 1 if self.unit_scale is True else self.unit_scale or 1
235 total = self.total * unit_scale if self.total else self.total
236 self.container = self.status_printer(self.fp, total, self.desc, self.ncols)
237 self.container.pbar = proxy(self)
238 self.displayed = False
239 if display_here and self.delay <= 0:
240 display(self.container)
241 self.displayed = True
242 self.disp = self.display
243 self.colour = colour
244
245 # Print initial bar state
246 if not self.disable:
247 self.display(check_delay=False)
248
249 def __iter__(self):
250 try:

Callers

nothing calls this directly

Calls 2

status_printerMethod · 0.95
displayMethod · 0.95

Tested by

no test coverage detected