Skip to content

compare

selectNew(A, X, tolerance=0)

Select rows from A that are not in X.

Parameters:

Name Type Description Default
A numpy.ndarray

A array with new values

required
X numpy.ndarray

X array with known values

required

Returns:

Type Description
numpy.ndarray

array with unknown (new) values

numpy.ndarray

array with True if value is new, otherwise False.

Source code in spotPython/utils/compare.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def selectNew(A, X, tolerance=0):
    """
    Select rows from A that are not in X.

    Args:
        A (numpy.ndarray): A array with new values
        X (numpy.ndarray): X array with known values

    Returns:
        (numpy.ndarray): array with unknown (new) values
        (numpy.ndarray): array with `True` if value is new, otherwise `False`.
    """
    ind = np.zeros(A.shape[0], dtype=bool)
    for i in range(X.shape[0]):
        B = np.abs(A - X[i, :])
        ind = ind + np.all(B <= tolerance, axis=1)
    return A[~ind], ~ind