def replace(X, old, new, strict=True, cols=None, rows=None):
if cols == None:<EOL><INDENT>cols = X.dtype.names<EOL><DEDENT>elif isinstance(cols, str):<EOL><INDENT>cols = cols.split('<STR_LIT:U+002C>')<EOL><DEDENT>if rows == None:<EOL><INDENT>rows = np.ones((len(X),), bool)<EOL><DEDENT>if strict:<EOL><INDENT>new = np.array(new)<EOL>for a in cols:<EOL><INDENT>if X.dtype[a] < new.dtype:<EOL><INDENT>print(('<STR_LIT>', a, <EOL>'<STR_LIT>', new, <EOL>'<STR_LIT>'))<EOL><DEDENT>try:<EOL><INDENT>X[a][(X[a] == old)[rows]] = new<EOL><DEDENT>except:<EOL><INDENT>print(('<STR_LIT>', a, '<STR_LIT:.>'))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for a in cols:<EOL><INDENT>QuickRep = True<EOL>try:<EOL><INDENT>colstr = '<STR_LIT>'.join(X[a][rows])<EOL><DEDENT>except TypeError:<EOL><INDENT>print(('<STR_LIT>', a, '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>avoid = [ord(o) for o in utils.uniqify(old + new + colstr)]<EOL>ok = set(range(<NUM_LIT>)).difference(avoid)<EOL>if len(ok) > <NUM_LIT:0>:<EOL><INDENT>sep = chr(list(ok)[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>ok = set(range(<NUM_LIT>)).difference(avoid)<EOL>if len(ok) > <NUM_LIT:0>:<EOL><INDENT>sep = chr(list(ok)[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>print(('<STR_LIT>', <EOL>a, '<STR_LIT>'))<EOL>QuickRep = False<EOL><DEDENT><DEDENT>if QuickRep:<EOL><INDENT>newrows = np.array(sep.join(X[a][rows])<EOL>.replace(old, new).split(sep))<EOL><DEDENT>else:<EOL><INDENT>newrows = np.array([aa.replace(old,new) for aa in <EOL>X[a][rows]])<EOL><DEDENT>X[a][rows] = np.cast[X.dtype[a]](newrows)<EOL>if newrows.dtype > X.dtype[a]:<EOL><INDENT>print(('<STR_LIT>', a, '<STR_LIT>' <EOL>'<STR_LIT>'<EOL>'<STR_LIT>'))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Replace value `old` with `new` everywhere it appears in-place.

Implemented by the tabarray method 
:func:`tabular.tab.tabarray.replace`.

**Parameters**

        **X** :  numpy ndarray with structured dtype

                Numpy array for which in-place replacement of `old` with 
                `new` is to be done.

        **old** : string

        **new** : string

        **strict** :  boolean, optional

        *   If `strict` = `True`, replace only exact occurences of `old`.

        *   If `strict` = `False`, assume `old` and `new` are strings and   
            replace all occurences of substrings (e.g. like 
            :func:`str.replace`)

        **cols** :  list of strings, optional

                Names of columns to make replacements in; if `None`, make 
                replacements everywhere.

        **rows** : list of booleans or integers, optional

                Rows to make replacements in; if `None`, make replacements 
                everywhere.

Note:  This function does in-place replacements.  Thus there are issues 
handling data types here when replacement dtype is larger than original 
dtype.  This can be resolved later by making a new array when necessary ...