Example #1
0
 def test_0d(self):
     # verify our work around for pd.isnull not working for 0-dimensional
     # object arrays
     self.assertTrue(ops.array_equiv(0, np.array(0, dtype=object)))
     self.assertTrue(ops.array_equiv(np.nan, np.array(np.nan,
                                                      dtype=object)))
     self.assertFalse(ops.array_equiv(0, np.array(1, dtype=object)))
Example #2
0
 def test_0d(self):
     # verify our work around for pd.isnull not working for 0-dimensional
     # object arrays
     self.assertTrue(ops.array_equiv(0, np.array(0, dtype=object)))
     self.assertTrue(
         ops.array_equiv(np.nan, np.array(np.nan, dtype=object)))
     self.assertFalse(
         ops.array_equiv(0, np.array(1, dtype=object)))
Example #3
0
def data_allclose_or_equiv(arr1, arr2, rtol=1e-05, atol=1e-08):
    if any(arr.dtype.kind == 'S' for arr in [arr1, arr2]):
        arr1 = decode_string_data(arr1)
        arr2 = decode_string_data(arr2)
    exact_dtypes = ['M', 'm', 'O', 'U']
    if any(arr.dtype.kind in exact_dtypes for arr in [arr1, arr2]):
        return ops.array_equiv(arr1, arr2)
    else:
        return ops.allclose_or_equiv(arr1, arr2, rtol=rtol, atol=atol)
Example #4
0
def data_allclose_or_equiv(arr1, arr2, rtol=1e-05, atol=1e-08):
    if any(arr.dtype.kind == 'S' for arr in [arr1, arr2]):
        arr1 = decode_string_data(arr1)
        arr2 = decode_string_data(arr2)
    exact_dtypes = ['M', 'm', 'O', 'U']
    if any(arr.dtype.kind in exact_dtypes for arr in [arr1, arr2]):
        return ops.array_equiv(arr1, arr2)
    else:
        return ops.allclose_or_equiv(arr1, arr2, rtol=rtol, atol=atol)
Example #5
0
def data_allclose_or_equiv(arr1, arr2, rtol=1e-05, atol=1e-08):
    from xarray.core import ops

    if any(arr.dtype.kind == "S" for arr in [arr1, arr2]):
        arr1 = decode_string_data(arr1)
        arr2 = decode_string_data(arr2)
    exact_dtypes = ["M", "m", "O", "U"]
    if any(arr.dtype.kind in exact_dtypes for arr in [arr1, arr2]):
        return ops.array_equiv(arr1, arr2)
    else:
        return ops.allclose_or_equiv(arr1, arr2, rtol=rtol, atol=atol)