compare
find_equal_in_lists(a, b)
¶
Find equal values in two lists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
list
|
list with a values |
required |
b |
list
|
list with b values |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
List[int]
|
list with 1 if equal, otherwise 0 |
Examples:
>>> from spotpython.utils.compare import find_equal_in_lists
a = [1, 2, 3, 4, 5]
b = [1, 2, 3, 4, 5]
find_equal_in_lists(a, b)
[1, 1, 1, 1, 1]
Source code in spotpython/utils/compare.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
selectNew(A, X, tolerance=0)
¶
Select rows from A that are not in X.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A |
ndarray
|
A array with new values |
required |
X |
ndarray
|
X array with known values |
required |
tolerance |
float
|
tolerance value for comparison |
0
|
Returns:
Type | Description |
---|---|
ndarray
|
array with unknown (new) values |
ndarray
|
array with |
Examples:
from spotpython.utils.compare import selectNew import numpy as np A = np.array([[1,2,3],[4,5,6]]) X = np.array([[1,2,3],[4,5,6]]) B, ind = selectNew(A, X) assert B.shape[0] == 0 assert np.equal(ind, np.array([False, False])).all() from spotpython.utils.compare import selectNew A = np.array([[1,2,3],[4,5,7]]) X = np.array([[1,2,3],[4,5,6]]) B, ind = selectNew(A, X) assert B.shape[0] == 1 assert np.equal(ind, np.array([False, True])).all()
Source code in spotpython/utils/compare.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|