def _where_close_unmasked(x, y, rtol=1.e-5, atol=1.e-8): """Version of where_close for unmasked arrays. See docstring for where_close for details regarding parameters and function. """ abs = N.absolute #- Make sure input is numpy/Numeric/numarray type: xN = N.array(x) yN = N.array(y) #- Safe compare if floating. Strict compare if integer. Any other # type returns an error: if (num.typecode(xN) in N.typecodes['Float']) or \ (num.typecode(yN) in N.typecodes['Float']): output_mask = N.less_equal(abs(xN-yN), atol+rtol*abs(yN)) elif (num.typecode(xN) in N.typecodes['Integer']) and \ (num.typecode(yN) in N.typecodes['Integer']): output_mask = N.equal(xN, yN) else: raise ValueError, "where_close: Inputs must be Float or Integer" #- Return output_mask: if isinstance(output_mask, int): return output_mask else: return output_mask.astype(int)