code: def label_faces(network, tol=0.0, label='surface'):
      r
      if label not in network.labels():
          find_surface_pores(network, label=label)
      Psurf = network['pore.'+label]
      crds = network['pore.coords']
      xmin, xmax = sp.amin(crds[:, 0]), sp.amax(crds[:, 0])
      xspan = xmax - xmin
      ymin, ymax = sp.amin(crds[:, 1]), sp.amax(crds[:, 1])
      yspan = ymax - ymin
      zmin, zmax = sp.amin(crds[:, 2]), sp.amax(crds[:, 2])
      zspan = zmax - zmin
      network['pore.back'] = (crds[:, 0] >= (1-tol)*xmax) * Psurf
      network['pore.right'] = (crds[:, 1] >= (1-tol)*ymax) * Psurf
      network['pore.top'] = (crds[:, 2] >= (1-tol)*zmax) * Psurf
      network['pore.front'] = (crds[:, 0] <= (xmin + tol*xspan)) * Psurf
      network['pore.left'] = (crds[:, 1] <= (ymin + tol*yspan)) * Psurf
      network['pore.bottom'] = (crds[:, 2] <= (zmin + tol*zspan)) * Psurf
docs: r"""
      Finds pores on the surface of the network and labels them according to
      whether they are on the *top*, *bottom*, etc.  This function assumes the
      network is cubic in shape (i.e. with six flat sides)
  
      Parameters
      ----------
      network : OpenPNM Network object
          The network to apply the labels
  
      tol : scalar
          The tolerance for defining what counts as a surface pore, which is
          specifically meant for random networks.  All pores with ``tol`` of
          the maximum or minimum along each axis are counts as pores.  The
          default is 0.
  
      label : string
          An identifying label to isolate the pores on the faces of the network.
          default is 'surface'.