code: def integrate_singleblock(
      num_live_points, pointstore, x_dim, num_params, dlogz=0.5
  ):
      active_u = []
      active_v = []
      active_logl = []
      for i in range(num_live_points):
          idx, row = pointstore.pop(-np.inf)
          assert row is not None
          active_u.append(row[2 : 2 + x_dim])
          active_v.append(row[2 + x_dim : 2 + x_dim + num_params])
          active_logl.append(row[1])
  
      saved_v = []  # Stored points for posterior results
      saved_logl = []
      saved_logwt = []
      h = 0.0  # Information, initially 0.
      logz = -1e300  # ln(Evidence Z), initially Z=0
      logvol = 0
      logvolf = np.log1p(-np.exp(-1.0 / num_live_points))
      # fraction_remain = 1.0
      max_iters = 10000000
  
      for it in range(0, max_iters):
          # Worst object in collection and its weight (= volume * likelihood)
          worst = np.argmin(active_logl)
          logwt = logvol + logvolf + active_logl[worst]
  
          # Update evidence Z and information h.
          logz_new = np.logaddexp(logz, logwt)
          h = (
              np.exp(logwt - logz_new) * active_logl[worst]
              + np.exp(logz - logz_new) * (h + logz)
              - logz_new
          )
          logz = logz_new
          logz_remain = np.max(active_logl) - it / num_live_points
  
          # print("L=%.1f N=%d V=%.2e logw=%.2e logZ=%.1f logZremain=%.1f" % (active_logl[worst], num_live_points, logvol, logwt, logz, logz_remain))
          # Shrink interval
          logvol -= 1.0 / num_live_points
  
          # Add worst object to samples.
          saved_v.append(np.array(active_v[worst]))
          saved_logwt.append(logwt)
          saved_logl.append(active_logl[worst])
  
          # The new likelihood constraint is that of the worst object.
          loglstar = active_logl[worst]
  
          idx, row = pointstore.pop(loglstar)
          assert row is not None
          u = row[2 : 2 + x_dim]
          v = row[2 + x_dim : 2 + x_dim + num_params]
          logl = row[1]
  
          active_u[worst] = u
          active_v[worst] = v
          active_logl[worst] = logl
  
          # fraction_remain = np.logaddexp(logz, logz_remain) - logz
  
          # Stopping criterion
          if logz_remain < logz:
              break
  
      logvol = -len(saved_v) / num_live_points
      for i in np.argsort(active_logl):
          logwt = logvol - np.log(num_live_points) + active_logl[i]
          logz_new = np.logaddexp(logz, logwt)
          h = (
              np.exp(logwt - logz_new) * active_logl[i]
              + np.exp(logz - logz_new) * (h + logz)
              - logz_new
          )
          logz = logz_new
          # print("L=%.1f N=%d V=%.2e logw=%.2e logZ=%.1f" % (active_logl[i], num_live_points, logvol, logwt, logz))
          saved_v.append(np.array(active_v[i]))
          saved_logwt.append(logwt)
          saved_logl.append(active_logl[i])
  
      saved_v = np.array(saved_v)
      saved_wt = np.exp(np.array(saved_logwt) - logz)
      saved_logl = np.array(saved_logl)
      logzerr = np.sqrt(h / num_live_points)
  
      results = dict(
          niter=it,
          logz=logz,
          logzerr=logzerr,
          weighted_samples=dict(
              v=saved_v, w=saved_wt, logw=saved_logwt, L=saved_logl
          ),
      )
  
      return results
  
file_path: ultranest/tests/test_netiterintegrate.py
imports: from __future__ import print_function, division
  import os
  import numpy
  from ultranest.store import TextPointStore
  from ultranest.netiter import PointPile, TreeNode, count_tree, print_tree, dump_tree
  from ultranest.netiter import SingleCounter, MultiCounter, BreadthFirstIterator
  import time
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: integrate_singleblock(num_live_points, pointstore, x_dim, num_params, dlogz) and returns: results