class_docstr: Object to validate a list of strings to use as field names.
  
  The strings are stripped of any non alphanumeric character, and spaces
  are replaced by '_'. During instantiation, the user can define a list
  of names to exclude, as well as a list of invalid characters. Names in
  the exclusion list are appended a '_' character.
  
  Once an instance has been created, it can be called with a list of
  names, and a list of valid names will be created.  The `__call__`
  method accepts an optional keyword "default" that sets the default name
  in case of ambiguity. By default this is 'f', so that names will
  default to `f0`, `f1`, etc.
  
  Parameters
  ----------
  excludelist : sequence, optional
      A list of names to exclude. This list is appended to the default
      list ['return', 'file', 'print']. Excluded names are appended an
      underscore: for example, `file` becomes `file_` if supplied.
  deletechars : str, optional
      A string combining invalid characters that must be deleted from the
      names.
  case_sensitive : {True, False, 'upper', 'lower'}, optional
      * If True, field names are case-sensitive.
      * If False or 'upper', field names are converted to upper case.
      * If 'lower', field names are converted to lower case.
  
      The default value is True.
  replace_space : '_', optional
      Character(s) used in replacement of white spaces.
  
  Notes
  -----
  Calling an instance of `NameValidator` is the same as calling its
  method `validate`.
  
  Examples
  --------
  >>> validator = np.lib._iotools.NameValidator()
  >>> validator(['file', 'field2', 'with space', 'CaSe'])
  ['file_', 'field2', 'with_space', 'CaSe']
  
  >>> validator = np.lib._iotools.NameValidator(excludelist=['excl'],
                                                deletechars='q',
                                                case_sensitive='False')
  >>> validator(['excl', 'field2', 'no_q', 'with space', 'CaSe'])
  ['excl_', 'field2', 'no_', 'with_space', 'case']
class_docstr_tok: ["Object","to","validate","a","list","of","strings","to","use","as","field","names",".","The","strings","are","stripped","of","any","non","alphanumeric","character",",","and","spaces","are","replaced","by","'","_","'",".","During","instantiation",",","the","user","can","define","a","list","of","names","to","exclude",",","as","well","as","a","list","of","invalid","characters",".","Names","in","the","exclusion","list","are","appended","a","'","_","'","character",".","Once","an","instance","has","been","created",",","it","can","be","called","with","a","list","of","names",",","and","a","list","of","valid","names","will","be","created",".","The","`","__call__","`","method","accepts","an","optional","keyword","``","default","''","that","sets","the","default","name","in","case","of","ambiguity",".","By","default","this","is","'","f","'",",","so","that","names","will","default","to","`","f0","`",",","`","f1","`",",","etc",".","Parameters","--","--","--","--","--","excludelist",":","sequence",",","optional","A","list","of","names","to","exclude",".","This","list","is","appended","to","the","default","list","[","'return","'",",","'file","'",",","'print","'","]",".","Excluded","names","are","appended","an","underscore",":","for","example",",","`","file","`","becomes","`","file_","`","if","supplied",".","deletechars",":","str",",","optional","A","string","combining","invalid","characters","that","must","be","deleted","from","the","names",".","case_sensitive",":","{","True",",","False",",","'upper","'",",","'lower","'","}",",","optional","*","If","True",",","field","names","are","case-sensitive",".","*","If","False","or","'upper","'",",","field","names","are","converted","to","upper","case",".","*","If","'lower","'",",","field","names","are","converted","to","lower","case",".","The","default","value","is","True",".","replace_space",":","'","_","'",",","optional","Character","(","s",")","used","in","replacement","of","white","spaces",".","Notes","--","--","-","Calling","an","instance","of","`","NameValidator","`","is","the","same","as","calling","its","method","`","validate","`",".","Examples","--","--","--","--",">",">",">","validator","=","np.lib._iotools.NameValidator","(",")",">",">",">","validator","(","[","'file","'",",","'field2","'",",","'with","space","'",",","'CaSe","'","]",")","[","'file_","'",",","'field2","'",",","'with_space","'",",","'CaSe","'","]",">",">",">","validator","=","np.lib._iotools.NameValidator","(","excludelist=","[","'excl","'","]",",","deletechars=","'","q","'",",","case_sensitive='False","'",")",">",">",">","validator","(","[","'excl","'",",","'field2","'",",","'no_q","'",",","'with","space","'",",","'CaSe","'","]",")","[","'excl_","'",",","'field2","'",",","'no_","'",",","'with_space","'",",","'case","'","]"]
docstr: Validate a list of strings as field names for a structured array.
  
  Parameters
  ----------
  names : sequence of str
      Strings to be validated.
  defaultfmt : str, optional
      Default format string, used if validating a given string
      reduces its length to zero.
  nbfields : integer, optional
      Final number of validated names, used to expand or shrink the
      initial list of names.
  
  Returns
  -------
  validatednames : list of str
      The list of validated field names.
  
  Notes
  -----
  A `NameValidator` instance can be called directly, which is the
  same as calling `validate`. For examples, see `NameValidator`.
docstr_tok: ["Validate","a","list","of","strings","as","field","names","for","a","structured","array",".","Parameters","--","--","--","--","--","names",":","sequence","of","str","Strings","to","be","validated",".","defaultfmt",":","str",",","optional","Default","format","string",",","used","if","validating","a","given","string","reduces","its","length","to","zero",".","nbfields",":","integer",",","optional","Final","number","of","validated","names",",","used","to","expand","or","shrink","the","initial","list","of","names",".","Returns","--","--","--","-","validatednames",":","list","of","str","The","list","of","validated","field","names",".","Notes","--","--","-","A","`","NameValidator","`","instance","can","be","called","directly",",","which","is","the","same","as","calling","`","validate","`",".","For","examples",",","see","`","NameValidator","`","."]
code: def validate(self, names, defaultfmt="f%i", nbfields=None):
      """
      Validate a list of strings as field names for a structured array.
  
      Parameters
      ----------
      names : sequence of str
          Strings to be validated.
      defaultfmt : str, optional
          Default format string, used if validating a given string
          reduces its length to zero.
      nbfields : integer, optional
          Final number of validated names, used to expand or shrink the
          initial list of names.
  
      Returns
      -------
      validatednames : list of str
          The list of validated field names.
  
      Notes
      -----
      A `NameValidator` instance can be called directly, which is the
      same as calling `validate`. For examples, see `NameValidator`.
  
      """
      # Initial checks ..............
      if names is None:
          if nbfields is None:
              return None
          names = []
      if isinstance(names, basestring):
          names = [
              names,
          ]
      if nbfields is not None:
          nbnames = len(names)
          if nbnames < nbfields:
              names = list(names) + [""] * (nbfields - nbnames)
          elif nbnames > nbfields:
              names = names[:nbfields]
      # Set some shortcuts ...........
      deletechars = self.deletechars
      excludelist = self.excludelist
      case_converter = self.case_converter
      replace_space = self.replace_space
      # Initializes some variables ...
      validatednames = []
      seen = dict()
      nbempty = 0
      #
      for item in names:
          item = case_converter(item).strip()
          if replace_space:
              item = item.replace(" ", replace_space)
          item = "".join([c for c in item if c not in deletechars])
          if item == "":
              item = defaultfmt % nbempty
              while item in names:
                  nbempty += 1
                  item = defaultfmt % nbempty
              nbempty += 1
          elif item in excludelist:
              item += "_"
          cnt = seen.get(item, 0)
          if cnt > 0:
              validatednames.append(item + "_%d" % cnt)
          else:
              validatednames.append(item)
          seen[item] = cnt + 1
      return tuple(validatednames)
  
imports: from __future__ import division, absolute_import, print_function
  import sys
  import numpy
  import numpy.core.numeric
  from numpy.compat import asbytes, asunicode, bytes, basestring
label_desc: Use image node_id 2 for calling the NameValidator obj's underlying member method code with example usage: obj.validate(names, defaultfmt, nbfields) and returns: tuple, None