class_docstr: Component that controls execution of a remote job, and draws a progress bar as it goes along.
  
  Usage example::
  
      def progress_generator():
          for i in range(10):
              yield i + 1, 0.5
  
      from progressbar import ProgressBar, PBWBar, PBWPercentage
      pb = ProgressBar(maxval=10, widgets_tty=["Job progress:", PBWBar(), PBWPercentage()])
      pb.execute(progress_generator())
  
  One of the important features of this class is that it takes an active role in controlling the progress of the
  underlying process. In particular, the :meth:`execute` method takes a ``progress_fn`` parameter, which is a
  generator that the :meth:`execute` method will periodically call in order to find what the progress level is.
  The generator may return either a single value (the progress amount), or a tuple
  ``(progress_amount, poll_interval)``, where the second element specifies how long (in seconds) ProgressBar
  should wait before calling the generator again.
  
  Once the :meth:`execute` method is called, it will not return until the progress reaches 100%. However the progress
  function can raise ``StopIteration(message)`` in order to cancel the current progress (and if possible display the
  provided message, which should be short).
  
  Another feature of this class is that it models the progress as a smooth process, so that progress values reported
  by the executor are used merely as signals, and the class makes up its own mind regarding what the actual progress
  at each moment of time is. More specifically, this works as follows:
  
  Suppose x(t) is the progress level as a function of time t, and v(t) is its speed (i.e. v(t) = dx/dt). Let T be
  the expected time when progress reaches 100%. Suppose current progress level is x₀ and speed v₀ at time t₀. Ideally
  we'd want to move to x(T) = 1 at a constant speed, which would be (1-x₀)/(T-t₀). However unless current v₀ is
  exactly that, such strategy is not feasible (we do not allow sudden jumps in speed). Instead, we let the
  progress move with the speed v(t) = vₑ + (v₀ - vₑ)e⁻ᵝ⁽ᵗ⁻ᵗ⁰⁾, where vₑ is the target speed that has to be
  determined based on the requirement to reach 1 at time T, and β is the rate of convergence towards the target
  speed vₑ.
  
  After some simple calculus, we obtain
      x(t) = x₀ + vₑ·(t - t₀) + (v₀ - vₑ)/β·(1 - e⁻ᵝ⁽ᵗ⁻ᵗ⁰⁾),
      v(t) = vₑ + (v₀ - vₑ)e⁻ᵝ⁽ᵗ⁻ᵗ⁰⁾,  and
      vₑ = v₀ + β(1 - x₀ - v₀(T - t₀))/(β(T - t₀) - 1 + e⁻ᵝ⁽ᵀ⁻ᵗ⁰⁾)
  
  In order to ensure smoothness of the model, we need to be careful as the progress approaches 100% and t
  approaches T. First, under no circumstance we are allowed to finish the progress if the underlying process did
  not report 100% status. At the same time we don't want to jump suddenly from, say, 90% to 100% at the final step.
  Thus, we allow the model to progress for a very short amount of time after the process has completed.
class_docstr_tok: ["Component","that","controls","execution","of","a","remote","job",",","and","draws","a","progress","bar","as","it","goes","along",".","Usage","example",":",":","def","progress_generator","(",")",":","for","i","in","range","(","10",")",":","yield","i","+","1",",","0.5","from","progressbar","import","ProgressBar",",","PBWBar",",","PBWPercentage","pb","=","ProgressBar","(","maxval=10",",","widgets_tty=","[","``","Job","progress",":","''",",","PBWBar","(",")",",","PBWPercentage","(",")","]",")","pb.execute","(","progress_generator","(",")",")","One","of","the","important","features","of","this","class","is","that","it","takes","an","active","role","in","controlling","the","progress","of","the","underlying","process",".","In","particular",",","the",":","meth",":","`","execute","`","method","takes","a","``","progress_fn","``","parameter",",","which","is","a","generator","that","the",":","meth",":","`","execute","`","method","will","periodically","call","in","order","to","find","what","the","progress","level","is",".","The","generator","may","return","either","a","single","value","(","the","progress","amount",")",",","or","a","tuple","``","(","progress_amount",",","poll_interval",")","``",",","where","the","second","element","specifies","how","long","(","in","seconds",")","ProgressBar","should","wait","before","calling","the","generator","again",".","Once","the",":","meth",":","`","execute","`","method","is","called",",","it","will","not","return","until","the","progress","reaches","100","%",".","However","the","progress","function","can","raise","``","StopIteration","(","message",")","``","in","order","to","cancel","the","current","progress","(","and","if","possible","display","the","provided","message",",","which","should","be","short",")",".","Another","feature","of","this","class","is","that","it","models","the","progress","as","a","smooth","process",",","so","that","progress","values","reported","by","the","executor","are","used","merely","as","signals",",","and","the","class","makes","up","its","own","mind","regarding","what","the","actual","progress","at","each","moment","of","time","is",".","More","specifically",",","this","works","as","follows",":","Suppose","x","(","t",")","is","the","progress","level","as","a","function","of","time","t",",","and","v","(","t",")","is","its","speed","(","i.e",".","v","(","t",")","=","dx\/dt",")",".","Let","T","be","the","expected","time","when","progress","reaches","100","%",".","Suppose","current","progress","level","is","x\u2080","and","speed","v\u2080","at","time","t\u2080",".","Ideally","we","'d","want","to","move","to","x","(","T",")","=","1","at","a","constant","speed",",","which","would","be","(","1-x\u2080",")","\/","(","T-t\u2080",")",".","However","unless","current","v\u2080","is","exactly","that",",","such","strategy","is","not","feasible","(","we","do","not","allow","sudden","jumps","in","speed",")",".","Instead",",","we","let","the","progress","move","with","the","speed","v","(","t",")","=","v\u2091","+","(","v\u2080","-","v\u2091",")","e\u207b\u1d5d\u207d\u1d57\u207b\u1d57\u2070\u207e",",","where","v\u2091","is","the","target","speed","that","has","to","be","determined","based","on","the","requirement","to","reach","1","at","time","T",",","and","\u03b2","is","the","rate","of","convergence","towards","the","target","speed","v\u2091",".","After","some","simple","calculus",",","we","obtain","x","(","t",")","=","x\u2080","+","v\u2091\u00b7","(","t","-","t\u2080",")","+","(","v\u2080","-","v\u2091",")","\/\u03b2\u00b7","(","1","-","e\u207b\u1d5d\u207d\u1d57\u207b\u1d57\u2070\u207e",")",",","v","(","t",")","=","v\u2091","+","(","v\u2080","-","v\u2091",")","e\u207b\u1d5d\u207d\u1d57\u207b\u1d57\u2070\u207e",",","and","v\u2091","=","v\u2080","+","\u03b2","(","1","-","x\u2080","-","v\u2080","(","T","-","t\u2080",")",")","\/","(","\u03b2","(","T","-","t\u2080",")","-","1","+","e\u207b\u1d5d\u207d\u1d40\u207b\u1d57\u2070\u207e",")","In","order","to","ensure","smoothness","of","the","model",",","we","need","to","be","careful","as","the","progress","approaches","100","%","and","t","approaches","T.","First",",","under","no","circumstance","we","are","allowed","to","finish","the","progress","if","the","underlying","process","did","not","report","100","%","status",".","At","the","same","time","we","do","n't","want","to","jump","suddenly","from",",","say",",","90","%","to","100","%","at","the","final","step",".","Thus",",","we","allow","the","model","to","progress","for","a","very","short","amount","of","time","after","the","process","has","completed","."]
docstr: Calculate the modelled progress state for the given time moment.
  
  :returns: tuple (x, v) of the progress level and progress speed.
docstr_tok: ["Calculate","the","modelled","progress","state","for","the","given","time","moment",".",":","returns",":","tuple","(","x",",","v",")","of","the","progress","level","and","progress","speed","."]
code: def _compute_progress_at_time(self, t):
      """
      Calculate the modelled progress state for the given time moment.
  
      :returns: tuple (x, v) of the progress level and progress speed.
      """
      t0, x0, v0, ve = self._t0, self._x0, self._v0, self._ve
      z = (v0 - ve) * math.exp(-self.BETA * (t - t0))
      vt = ve + z
      xt = clamp(x0 + ve * (t - t0) + (v0 - ve - z) / self.BETA, 0, 1)
      return xt, vt
  
imports: from h2o.utils.compatibility import *
  import math
  import os
  import sys
  import time
  from types import FunctionType, GeneratorType, MethodType
  from h2o.utils.shared_utils import clamp
  from h2o.utils.typechecks import assert_is_type, is_type, numeric
label_desc: Use image node_id 8 for calling the ProgressBar obj's underlying member method code with example usage: obj._compute_progress_at_time(t) and returns: xt,  vt