def test_make_unique_dtype(): x_list = [2, 2, 2, 3, 5] for dtype in (np.float32, np.float64): x = np.array(x_list, dtype=dtype) y = x.copy() w = np.ones_like(x) x, y, w = _make_unique(x, y, w) assert_array_equal(x, [2, 3, 5])
def test_make_unique_tolerance(dtype): # Check that equality takes account of np.finfo tolerance x = np.array([0, 1e-16, 1, 1 + 1e-14], dtype=dtype) y = x.copy() w = np.ones_like(x) x, y, w = _make_unique(x, y, w) if dtype == np.float64: x_out = np.array([0, 1, 1 + 1e-14]) else: x_out = np.array([0, 1]) assert_array_equal(x, x_out)