ARGA
ARGA copied to clipboard
"def ismember()" The actual function is different from the meaning of the name. why???
preprocessing.py -> def mask_test_edges(adj): -> def ismember(a, b, tol=5):
The actual function is different from the meaning of the name. why???
Actual function: is same rows (https://www.coder.work/article/2401015) Surface name function: is member
import numpy as np
def ismember(a, b, tol=5):
rows_close = np.all(np.round(a - b[:, None], tol) == 0, axis=-1)
return (np.all(np.any(rows_close, axis=-1), axis=-1) and np.all(np.any(rows_close, axis=0), axis=0))
#[is same rows]
a = np.array([[ 6, 7],
[ 2, 3],
[ 0, 1],
[ 4, 5],
[ 8, 9]])
b = np.array([[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9]])
print(ismember(a, b))
# >> True
#[is member]
a1 = np.array([[ 0, 1]]) # shape=(1, 2)
print(ismember(a1, b))
# >> False # error
a2 = np.array([ 0, 1]) # shape=(2,)
print(ismember(a2, b))
# >> False # error