docstr: create a bounds instance
  
  bounds is a tuple of (lower, upper) bound
  
  additionally, one can specify:
      - xlb: lower bound
      - xub: upper bound
      - n: repeat
  
  Examples:
      >>> b = Bounds(7, 8, n=2)
      >>> b.xlb, b.xub
      (7, 8)
      >>> b()
      [(7, 8), (7, 8)]
      >>> b.lower
      [7, 7]
      >>> b.upper
      [8, 8]
  
      >>> c = Bounds((0,1),(3,4), n=2)
      >>> c()
      [(0, 3), (0, 3), (1, 4), (1, 4)]
      
docstr_tok: ["create","a","bounds","instance","bounds","is","a","tuple","of","(","lower",",","upper",")","bound","additionally",",","one","can","specify",":","-","xlb",":","lower","bound","-","xub",":","upper","bound","-","n",":","repeat","Examples",":",">",">",">","b","=","Bounds","(","7",",","8",",","n=2",")",">",">",">","b.xlb",",","b.xub","(","7",",","8",")",">",">",">","b","(",")","[","(","7",",","8",")",",","(","7",",","8",")","]",">",">",">","b.lower","[","7",",","7","]",">",">",">","b.upper","[","8",",","8","]",">",">",">","c","=","Bounds","(","(","0,1",")",",","(","3,4",")",",","n=2",")",">",">",">","c","(",")","[","(","0",",","3",")",",","(","0",",","3",")",",","(","1",",","4",")",",","(","1",",","4",")","]"]
code: def __init__(self, *bounds, **kwds):
      """create a bounds instance
  
      bounds is a tuple of (lower, upper) bound
  
      additionally, one can specify:
          - xlb: lower bound
          - xub: upper bound
          - n: repeat
  
      Examples:
          >>> b = Bounds(7, 8, n=2)
          >>> b.xlb, b.xub
          (7, 8)
          >>> b()
          [(7, 8), (7, 8)]
          >>> b.lower
          [7, 7]
          >>> b.upper
          [8, 8]
  
          >>> c = Bounds((0,1),(3,4), n=2)
          >>> c()
          [(0, 3), (0, 3), (1, 4), (1, 4)]
      """
      self.n = kwds.pop("n", 1)
      self.wub = None  # 1.0
      self.wlb = None  # 1.0
  
      xlb = -float("inf")
      xub = float("inf")
  
      blen = len(bounds)
      if blen == 0:
          self.xub = kwds.pop("xub", xub)
          self.xlb = kwds.pop("xlb", xlb)
      elif blen == 1:
          self.xlb = bounds[0]
          self.xub = kwds.pop("xub", xub)
          if "xlb" in kwds:
              msg = "__init__() got multiple values for argument 'xlb'"
              raise TypeError(msg)
      else:
          self.xlb, self.xub = bounds
          if "xlb" in kwds:
              msg = "__init__() got multiple values for argument 'xlb'"
              raise TypeError(msg)
          if "xub" in kwds:
              msg = "__init__() got multiple values for argument 'xub'"
              raise TypeError(msg)
      # single xub stretched to xlb
      if hasattr(self.xlb, "__len__") and not hasattr(
          self.xub, "__len__"
      ):
          self.xub = len(self.xlb) * (self.xub,)
      # single xlb stretched to xub
      elif hasattr(self.xub, "__len__") and not hasattr(
          self.xlb, "__len__"
      ):
          self.xlb = len(self.xub) * (self.xlb,)
      # single n stretched to xub
      if hasattr(self.xub, "__len__") and not hasattr(
          self.n, "__len__"
      ):
          self.n = len(self.xub) * (self.n,)
      # single xlb,xub stretched to n
      elif hasattr(self.n, "__len__") and not hasattr(
          self.xub, "__len__"
      ):
          self.xub = len(self.n) * (self.xub,)
          self.xlb = len(self.n) * (self.xlb,)
  
imports: from mystic.tools import flatten
label_desc: Use image node_id 1 to create a new Bounds object from inherited base classes: object with example: obj = Bounds()