code: def nicelogger(
      points, info, region, transformLayer, region_fresh=False
  ):
      """Log current live points and integration progress to stdout.
  
      Parameters
      -----------
      points: dict with keys "u", "p", "logl"
          live points (u: cube coordinates, p: transformed coordinates,
          logl: loglikelihood values)
      info: dict
          integration information. Keys are:
  
          - paramlims (optional): parameter ranges
          - logvol: expected volume at this iteration
  
      region: MLFriends
          Current region.
      transformLayer: ScaleLayer or AffineLayer
          Current transformLayer (for clustering information).
      region_fresh: bool
          Whether the region was just updated.
  
      """
      p = points["p"]
      paramnames = info["paramnames"]
      # print()
      # print('lnZ = %.1f, remainder = %.1f, lnLike = %.1f | Efficiency: %d/%d = %.4f%%\r' % (
      #       logz, logz_remain, np.max(logl), ncall, it, it * 100 / ncall))
  
      plo = p.min(axis=0)
      phi = p.max(axis=0)
      plo_rounded, phi_rounded, paramformats = round_parameterlimits(
          plo, phi, paramlimitguess=info.get("paramlims")
      )
  
      if sys.stderr.isatty() and hasattr(shutil, "get_terminal_size"):
          columns, _ = shutil.get_terminal_size(fallback=(80, 25))
      else:
          columns, _ = 80, 25
  
      paramwidth = max([len(pname) for pname in paramnames])
      width = columns - 23 - paramwidth
      width = max(width, 10)
      indices = (
          (p - plo_rounded)
          * width
          / (phi_rounded - plo_rounded).reshape((1, -1))
      ).astype(int)
      indices[indices >= width] = width - 1
      indices[indices < 0] = 0
      ndim = len(plo)
  
      print()
      print()
      clusterids = transformLayer.clusterids % len(clusteridstrings)
      nmodes = transformLayer.nclusters
      print(
          "Mono-modal" if nmodes == 1 else "Have %d modes" % nmodes,
          "Volume: ~exp(%.2f)" % region.estimate_volume(),
          "*" if region_fresh else " ",
          "Expected Volume: exp(%.2f)" % info["logvol"],
          ""
          if "order_test_correlation" not in info
          else (
              "Quality: correlation length: %d (%s)"
              % (
                  info["order_test_correlation"],
                  "+" if info["order_test_direction"] >= 0 else "-",
              )
          )
          if np.isfinite(info["order_test_correlation"])
          else "Quality: ok",
      )
  
      print()
      if ndim == 1:
          pass
      elif ndim == 2 and spearman is not None:
          rho, pval = spearman(p)
          if pval < 0.01 and abs(rho) > 0.75:
              print(
                  "   %s between %s and %s: rho=%.2f"
                  % (
                      "positive degeneracy"
                      if rho > 0
                      else "negative degeneracy",
                      paramnames[0],
                      paramnames[1],
                      rho,
                  )
              )
      elif spearman is not None:
          rho, pval = spearman(p)
          if np.isfinite(pval).all() and pval.ndim == 2:
              for i, param in enumerate(paramnames):
                  for j, param2 in enumerate(paramnames[:i]):
                      if pval[i, j] < 0.01 and abs(rho[i, j]) > 0.99:
                          s = (
                              "positive relation"
                              if rho[i, j] > 0
                              else "negative relation"
                          )
                          print(
                              "   perfect %s between %s and %s"
                              % (s, param, param2)
                          )
                      elif pval[i, j] < 0.01 and abs(rho[i, j]) > 0.75:
                          s = (
                              "positive degeneracy"
                              if rho[i, j] > 0
                              else "negative degeneracy"
                          )
                          print(
                              "   %s between %s and %s: rho=%.2f"
                              % (s, param, param2, rho[i, j])
                          )
  
      for i, (param, fmt) in enumerate(zip(paramnames, paramformats)):
          if nmodes == 1:
              line = [" " for _ in range(width)]
              for j in np.unique(indices[:, i]):
                  line[j] = "*"
              linestr = "".join(line)
          else:
              line = [" " for _ in range(width)]
              for clusterid, j in zip(clusterids, indices[:, i]):
                  if clusterid > 0 and line[j] in (" ", "0"):
                      # set it to correct cluster id
                      line[j] = clusteridstrings[clusterid]
                  elif clusterid == 0 and line[j] == " ":
                      # empty, so set it although we don't know the cluster id
                      line[j] = "0"
                  # else:
                  #    line[j] = '*'
              linestr = "".join(line)
  
          line = linestr
          ilo, ihi = indices[:, i].min(), indices[:, i].max()
          if ilo > 10:
              assert line[:10] == " " * 10
              leftstr = fmt % plo[i]
              j = ilo - 2 - len(leftstr)  # left-bound
              if j < width and j > 0:
                  line = line[:j] + leftstr + line[j + len(leftstr) :]
          if ihi < width - 10:
              rightstr = fmt % phi[i]
              j = ihi + 3  # right-bound
              if j < width and j > 0:
                  line = line[:j] + rightstr + line[j + len(rightstr) :]
  
          parampadded = ("%%-%ds" % paramwidth) % param
          print(
              "%s: %09s|%s|%9s"
              % (
                  parampadded,
                  fmt % plo_rounded[i],
                  line,
                  fmt % phi_rounded[i],
              )
          )
  
      print()
  
file_path: ultranest/ultranest/viz.py
imports: from __future__ import print_function, division
  import sys
  import shutil
  from numpy import log10
  import numpy
  import string
  from xml.sax.saxutils import escape
label_desc: Use image node_id 2 for calling a global function with example usage: nicelogger(points, info, region, transformLayer, region_fresh) without return types