<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ones(dur=None):
 """ Ones stream generator. You may multiply your endless stream by this to enforce an end to it. Parameters dur : Duration, in number of samples; endless if not given. Returns ------- Stream that repeats "1.0" during a given time duration (if any) or endlessly. """

  if dur is None or (isinf(dur) and dur > 0):
    while True:
      yield 1.0
  for x in xrange(int(.5 + dur)):
    yield 1.0