MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / tqdm_notebook

Class tqdm_notebook

pager_lib/tqdm/notebook.py:90–305  ·  view source on GitHub ↗

Experimental IPython/Jupyter Notebook widget using tqdm!

Source from the content-addressed store, hash-verified

88
89
90class tqdm_notebook(std_tqdm):
91 """
92 Experimental IPython/Jupyter Notebook widget using tqdm!
93 """
94 @staticmethod
95 def status_printer(_, total=None, desc=None, ncols=None):
96 """
97 Manage the printing of an IPython/Jupyter Notebook progress bar widget.
98 """
99 # Fallback to text bar if there's no total
100 # DEPRECATED: replaced with an 'info' style bar
101 # if not total:
102 # return super(tqdm_notebook, tqdm_notebook).status_printer(file)
103
104 # fp = file
105
106 # Prepare IPython progress bar
107 if IProgress is None: # #187 #451 #558 #872
108 raise ImportError(WARN_NOIPYW)
109 if total:
110 pbar = IProgress(min=0, max=total)
111 else: # No total? Show info style bar with no progress tqdm status
112 pbar = IProgress(min=0, max=1)
113 pbar.value = 1
114 pbar.bar_style = 'info'
115 if ncols is None:
116 pbar.layout.width = "20px"
117
118 ltext = HTML()
119 rtext = HTML()
120 if desc:
121 ltext.value = desc
122 container = TqdmHBox(children=[ltext, pbar, rtext])
123 # Prepare layout
124 if ncols is not None: # use default style of ipywidgets
125 # ncols could be 100, "100px", "100%"
126 ncols = str(ncols) # ipywidgets only accepts string
127 try:
128 if int(ncols) > 0: # isnumeric and positive
129 ncols += 'px'
130 except ValueError:
131 pass
132 pbar.layout.flex = '2'
133 container.layout.width = ncols
134 container.layout.display = 'inline-flex'
135 container.layout.flex_flow = 'row wrap'
136
137 return container
138
139 def display(self, msg=None, pos=None,
140 # additional signals
141 close=False, bar_style=None, check_delay=True):
142 # Note: contrary to native tqdm, msg='' does NOT clear bar
143 # goal is to keep all infos if error happens so user knows
144 # at which iteration the loop failed.
145
146 # Clear previous output (really necessary?)
147 # clear_output(wait=1)

Callers 1

tnrangeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected