code: def max_extents(extents, zrange=False):
      
      if zrange:
          num = 6
          inds = [(0, 3), (1, 4), (2, 5)]
          extents = [e if len(e) == 6 else (e[0], e[1], None,
                                            e[2], e[3], None)
                     for e in extents]
      else:
          num = 4
          inds = [(0, 2), (1, 3)]
      arr = list(zip(*extents)) if extents else []
      extents = [np.NaN] * num
      if len(arr) == 0:
          return extents
      with warnings.catch_warnings():
          warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered')
          for lidx, uidx in inds:
              lower = [v for v in arr[lidx] if v is not None and not is_nan(v)]
              upper = [v for v in arr[uidx] if v is not None and not is_nan(v)]
              if lower and isinstance(lower[0], datetime_types):
                  extents[lidx] = np.min(lower)
              elif any(isinstance(l, basestring) for l in lower):
                  extents[lidx] = np.sort(lower)[0]
              elif lower:
                  extents[lidx] = np.nanmin(lower)
              if upper and isinstance(upper[0], datetime_types):
                  extents[uidx] = np.max(upper)
              elif any(isinstance(u, basestring) for u in upper):
                  extents[uidx] = np.sort(upper)[-1]
              elif upper:
                  extents[uidx] = np.nanmax(upper)
      return tuple(extents)
docs: Computes the maximal extent in 2D and 3D space from
      list of 4-tuples or 6-tuples. If zrange is enabled
      all extents are converted to 6-tuples to compute
      x-, y- and z-limits.