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

Method display

pager_lib/tqdm/gui.py:110–169  ·  view source on GitHub ↗
(self, *_, **__)

Source from the content-addressed store, hash-verified

108 pass
109
110 def display(self, *_, **__):
111 n = self.n
112 cur_t = self._time()
113 elapsed = cur_t - self.start_t
114 delta_it = n - self.last_print_n
115 delta_t = cur_t - self.last_print_t
116
117 # Inline due to multiple calls
118 total = self.total
119 xdata = self.xdata
120 ydata = self.ydata
121 zdata = self.zdata
122 ax = self.ax
123 line1 = self.line1
124 line2 = self.line2
125 hspan = getattr(self, 'hspan', None)
126 # instantaneous rate
127 y = delta_it / delta_t
128 # overall rate
129 z = n / elapsed
130 # update line data
131 xdata.append(n * 100.0 / total if total else cur_t)
132 ydata.append(y)
133 zdata.append(z)
134
135 # Discard old values
136 # xmin, xmax = ax.get_xlim()
137 # if (not total) and elapsed > xmin * 1.1:
138 if (not total) and elapsed > 66:
139 xdata.popleft()
140 ydata.popleft()
141 zdata.popleft()
142
143 ymin, ymax = ax.get_ylim()
144 if y > ymax or z > ymax:
145 ymax = 1.1 * y
146 ax.set_ylim(ymin, ymax)
147 ax.figure.canvas.draw()
148
149 if total:
150 line1.set_data(xdata, ydata)
151 line2.set_data(xdata, zdata)
152 if hspan:
153 hspan.set_xy((0, ymin))
154 hspan.set_height(ymax - ymin)
155 hspan.set_width(n / total)
156 else:
157 t_ago = [cur_t - i for i in xdata]
158 line1.set_data(t_ago, ydata)
159 line2.set_data(t_ago, zdata)
160
161 d = self.format_dict
162 # remove {bar}
163 d['bar_format'] = (d['bar_format'] or "{l_bar}<bar/>{r_bar}").replace(
164 "{bar}", "<bar/>")
165 msg = self.format_meter(**d)
166 if '<bar/>' in msg:
167 msg = "".join(re.split(r'\|?<bar/>\|?', msg, maxsplit=1))

Callers 1

closeMethod · 0.95

Calls 3

appendMethod · 0.80
drawMethod · 0.80
format_meterMethod · 0.80

Tested by

no test coverage detected