python - check if a numpy 1d sub-array is consecutively included in a numpy Nd array -


defined 1d array (or 1d slice of bigger array), like:

a=np.array([ 5, 12, 13]) 

if there higher dimension array, like:

c1=np.array([[1, 2, 3], [ 5, 12, 13], [7, 8, 9]]) c2=np.array([[1, 2, 3], [ 5, 6, 7], [7, 8, 9]]) 

it turns out be:

a in c1, in c2 (true, true) 

i first condition, a consecutively contained sub-array true. while a in c2 give false. there function taking care of that?

you can use .tolist() , call functions normally:

>>> a=np.array([ 5, 12, 13]) >>> c1=np.array([[1, 2, 3], [ 5, 12, 13], [7, 8, 9]]) >>> c2=np.array([[1, 2, 3], [ 5, 6, 7], [7, 8, 9]]) >>> a.tolist() in c1.tolist(), a.tolist() in c2.tolist() (true, false) >>>  

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -