def address_data(data, dims=None, surface=<NUM_LIT:0.5>, strict=True):
if data is None: return (None, None)<EOL>if not is_address(data): raise ValueError('<STR_LIT>')<EOL>faces = np.asarray(data['<STR_LIT>'])<EOL>coords = np.asarray(data['<STR_LIT>'])<EOL>if len(faces.shape) > <NUM_LIT:2> or len(coords.shape) > <NUM_LIT:2>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif len(faces.shape) != len(coords.shape):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif len(faces) == <NUM_LIT:0>: return (None, None)<EOL>if len(faces.shape) == <NUM_LIT:2> and faces.shape[<NUM_LIT:0>] != <NUM_LIT:3>: faces = faces.T<EOL>if faces.shape[<NUM_LIT:0>] != <NUM_LIT:3>: raise ValueError('<STR_LIT>')<EOL>if len(coords.shape) == <NUM_LIT:2> and coords.shape[<NUM_LIT:0>] not in (<NUM_LIT:2>,<NUM_LIT:3>): coords = coords.T<EOL>if coords.shape[<NUM_LIT:0>] not in (<NUM_LIT:2>,<NUM_LIT:3>): raise ValueError('<STR_LIT>')<EOL>if dims is None: dims = coords.shape[<NUM_LIT:0>]<EOL>elif coords.shape[<NUM_LIT:0>] != dims:<EOL><INDENT>if dims == <NUM_LIT:2>: coords = coords[:<NUM_LIT:2>]<EOL>else:<EOL><INDENT>if surface is None: raise ValueError('<STR_LIT>')<EOL>elif pimms.is_str(surface):<EOL><INDENT>surface = surface.lower()<EOL>if surface == '<STR_LIT>': surface = <NUM_LIT:1><EOL>elif surface == '<STR_LIT>': surface = <NUM_LIT:0><EOL>elif surface in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'): surface = <NUM_LIT:0.5><EOL>else: raise ValueError('<STR_LIT>' % surface)<EOL><DEDENT>if not pimms.is_real(surface) or surface < <NUM_LIT:0> or surface > <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>coords = np.vstack((coords, np.full((<NUM_LIT:1>, coords.shape[<NUM_LIT:1>]), surface)))<EOL><DEDENT><DEDENT>if strict:<EOL><INDENT>if np.sum(np.logical_not(np.isfinite(coords))) > <NUM_LIT:0>:<EOL><INDENT>w = np.where(np.logical_not(np.isfinite(coords)))<EOL>if len(w[<NUM_LIT:0>]) > <NUM_LIT:10>:<EOL><INDENT>raise ValueError('<STR_LIT>' % len(w[<NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % (len(w),w))<EOL><DEDENT><DEDENT>if np.sum(np.logical_not(np.isfinite(faces))) > <NUM_LIT:0>:<EOL><INDENT>w = np.where(np.logical_not(np.isfinite(faces)))<EOL>if len(w[<NUM_LIT:0>]) > <NUM_LIT:10>:<EOL><INDENT>raise ValueError('<STR_LIT>' % len(w[<NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % (len(w[<NUM_LIT:0>]),w))<EOL><DEDENT><DEDENT><DEDENT>return (faces, coords)<EOL>
address_data(addr) yields the tuple (faces, coords) of the address data where both faces and
  coords are guaranteed to be numpy arrays with sizes (3 x n) and (d x n); this will coerce
  the data found in addr if necessary to do this. If the data is not valid, then an error is
  raised. If the address is empty, this yields (None, None).

The following options may be given:
   * dims (default None) specifies the dimensions requested for the coordinates. If 2, then
     the final dimension is dropped from 3D coordinates; if 3 then will add the optional
     surface argument as the final dimension of 2D coordinates.
   * surface (default: 0.5) specifies the surface to use for 2D addresses when a 3D address;
     is requested. If None, then an error will be raised when this condition is encountered.
     This should be either 'white', 'pial', 'midgray', or a real number in the range [0,1]
     where 0 is the white surface and 1 is the pial surface.
   * strict (default: True) specifies whether an error should be raised when there are
     non-finite values found in the faces or the coordinates matrices. These values are usually
     indicative of an attempt to address a point that was not inside the mesh/cortex.