Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"def ismember()" The actual function is different from the meaning of the name. why??? #12

Open
BingYu94860 opened this issue Apr 4, 2020 · 0 comments

Comments

@BingYu94860
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant