@@ -190,7 +190,7 @@ def _apply(self, group):
190
190
lsel = self .lsel .apply (group )
191
191
192
192
# Mask which lsel indices appear in rsel
193
- mask = np .in1d (rsel .indices , lsel .indices )
193
+ mask = np .isin (rsel .indices , lsel .indices )
194
194
# and mask rsel according to that
195
195
return rsel [mask ]
196
196
@@ -267,7 +267,7 @@ class NotSelection(UnarySelection):
267
267
268
268
def _apply (self , group ):
269
269
notsel = self .sel .apply (group )
270
- return group [~ np .in1d (group .indices , notsel .indices )]
270
+ return group [~ np .isin (group .indices , notsel .indices )]
271
271
272
272
273
273
class GlobalSelection (UnarySelection ):
@@ -292,7 +292,7 @@ class ByResSelection(UnarySelection):
292
292
def _apply (self , group ):
293
293
res = self .sel .apply (group )
294
294
unique_res = unique_int_1d (res .resindices )
295
- mask = np .in1d (group .resindices , unique_res )
295
+ mask = np .isin (group .resindices , unique_res )
296
296
297
297
return group [mask ]
298
298
@@ -312,7 +312,7 @@ def _apply(self, group):
312
312
indices = []
313
313
sel = self .sel .apply (group )
314
314
# All atoms in group that aren't in sel
315
- sys = group [~ np .in1d (group .indices , sel .indices )]
315
+ sys = group [~ np .isin (group .indices , sel .indices )]
316
316
317
317
if not sys or not sel :
318
318
return sys [[]]
@@ -372,7 +372,7 @@ def _apply(self, group):
372
372
indices = []
373
373
sel = self .sel .apply (group )
374
374
# All atoms in group that aren't in sel
375
- sys = group [~ np .in1d (group .indices , sel .indices )]
375
+ sys = group [~ np .isin (group .indices , sel .indices )]
376
376
377
377
if not sys or not sel :
378
378
return sys [[]]
@@ -389,7 +389,7 @@ def _apply(self, group):
389
389
sys_ind_outer = np .sort (np .unique (pairs_outer [:,1 ]))
390
390
if pairs_inner .size > 0 :
391
391
sys_ind_inner = np .sort (np .unique (pairs_inner [:,1 ]))
392
- indices = sys_ind_outer [~ np .in1d (sys_ind_outer , sys_ind_inner )]
392
+ indices = sys_ind_outer [~ np .isin (sys_ind_outer , sys_ind_inner )]
393
393
else :
394
394
indices = sys_ind_outer
395
395
@@ -577,9 +577,9 @@ def _apply(self, group):
577
577
578
578
idx = []
579
579
# left side
580
- idx .append (bix [:, 0 ][np .in1d (bix [:, 1 ], grpidx )])
580
+ idx .append (bix [:, 0 ][np .isin (bix [:, 1 ], grpidx )])
581
581
# right side
582
- idx .append (bix [:, 1 ][np .in1d (bix [:, 0 ], grpidx )])
582
+ idx .append (bix [:, 1 ][np .isin (bix [:, 0 ], grpidx )])
583
583
584
584
idx = np .union1d (* idx )
585
585
@@ -603,7 +603,7 @@ def __init__(self, parser, tokens):
603
603
raise ValueError (errmsg ) from None
604
604
605
605
def _apply (self , group ):
606
- mask = np .in1d (group .indices , self .grp .indices )
606
+ mask = np .isin (group .indices , self .grp .indices )
607
607
return group [mask ]
608
608
609
609
@@ -657,7 +657,7 @@ def _apply(self, group):
657
657
# atomname indices for members of this group
658
658
nmidx = nmattr .nmidx [getattr (group , self .level )]
659
659
660
- return group [np .in1d (nmidx , matches )]
660
+ return group [np .isin (nmidx , matches )]
661
661
662
662
663
663
class AromaticSelection (Selection ):
@@ -743,7 +743,7 @@ def _apply(self, group):
743
743
# flatten all matches and remove duplicated indices
744
744
indices = np .unique ([idx for match in matches for idx in match ])
745
745
# create boolean mask for atoms based on index
746
- mask = np .in1d (range (group .n_atoms ), indices )
746
+ mask = np .isin (range (group .n_atoms ), indices )
747
747
return group [mask ]
748
748
749
749
@@ -1053,7 +1053,7 @@ def _apply(self, group):
1053
1053
# index of each atom's resname
1054
1054
nmidx = resname_attr .nmidx [group .resindices ]
1055
1055
# intersect atom's resname index and matches to prot_res
1056
- return group [np .in1d (nmidx , matches )]
1056
+ return group [np .isin (nmidx , matches )]
1057
1057
1058
1058
1059
1059
class NucleicSelection (Selection ):
@@ -1089,7 +1089,7 @@ def _apply(self, group):
1089
1089
1090
1090
matches = [ix for (nm , ix ) in resnames .namedict .items ()
1091
1091
if nm in self .nucl_res ]
1092
- mask = np .in1d (nmidx , matches )
1092
+ mask = np .isin (nmidx , matches )
1093
1093
1094
1094
return group [mask ]
1095
1095
@@ -1116,13 +1116,13 @@ def _apply(self, group):
1116
1116
name_matches = [ix for (nm , ix ) in atomnames .namedict .items ()
1117
1117
if nm in self .bb_atoms ]
1118
1118
nmidx = atomnames .nmidx [group .ix ]
1119
- group = group [np .in1d (nmidx , name_matches )]
1119
+ group = group [np .isin (nmidx , name_matches )]
1120
1120
1121
1121
# filter by resnames
1122
1122
resname_matches = [ix for (nm , ix ) in resnames .namedict .items ()
1123
1123
if nm in self .prot_res ]
1124
1124
nmidx = resnames .nmidx [group .resindices ]
1125
- group = group [np .in1d (nmidx , resname_matches )]
1125
+ group = group [np .isin (nmidx , resname_matches )]
1126
1126
1127
1127
return group .unique
1128
1128
@@ -1149,13 +1149,13 @@ def _apply(self, group):
1149
1149
name_matches = [ix for (nm , ix ) in atomnames .namedict .items ()
1150
1150
if nm in self .bb_atoms ]
1151
1151
nmidx = atomnames .nmidx [group .ix ]
1152
- group = group [np .in1d (nmidx , name_matches )]
1152
+ group = group [np .isin (nmidx , name_matches )]
1153
1153
1154
1154
# filter by resnames
1155
1155
resname_matches = [ix for (nm , ix ) in resnames .namedict .items ()
1156
1156
if nm in self .nucl_res ]
1157
1157
nmidx = resnames .nmidx [group .resindices ]
1158
- group = group [np .in1d (nmidx , resname_matches )]
1158
+ group = group [np .isin (nmidx , resname_matches )]
1159
1159
1160
1160
return group .unique
1161
1161
@@ -1187,13 +1187,13 @@ def _apply(self, group):
1187
1187
name_matches = [ix for (nm , ix ) in atomnames .namedict .items ()
1188
1188
if nm in self .base_atoms ]
1189
1189
nmidx = atomnames .nmidx [group .ix ]
1190
- group = group [np .in1d (nmidx , name_matches )]
1190
+ group = group [np .isin (nmidx , name_matches )]
1191
1191
1192
1192
# filter by resnames
1193
1193
resname_matches = [ix for (nm , ix ) in resnames .namedict .items ()
1194
1194
if nm in self .nucl_res ]
1195
1195
nmidx = resnames .nmidx [group .resindices ]
1196
- group = group [np .in1d (nmidx , resname_matches )]
1196
+ group = group [np .isin (nmidx , resname_matches )]
1197
1197
1198
1198
return group .unique
1199
1199
@@ -1217,13 +1217,13 @@ def _apply(self, group):
1217
1217
name_matches = [ix for (nm , ix ) in atomnames .namedict .items ()
1218
1218
if nm in self .sug_atoms ]
1219
1219
nmidx = atomnames .nmidx [group .ix ]
1220
- group = group [np .in1d (nmidx , name_matches )]
1220
+ group = group [np .isin (nmidx , name_matches )]
1221
1221
1222
1222
# filter by resnames
1223
1223
resname_matches = [ix for (nm , ix ) in resnames .namedict .items ()
1224
1224
if nm in self .nucl_res ]
1225
1225
nmidx = resnames .nmidx [group .resindices ]
1226
- group = group [np .in1d (nmidx , resname_matches )]
1226
+ group = group [np .isin (nmidx , resname_matches )]
1227
1227
1228
1228
return group .unique
1229
1229
@@ -1408,7 +1408,7 @@ def _apply(self, group):
1408
1408
# indices are same as fragment(s) indices
1409
1409
allfrags = functools .reduce (lambda x , y : x + y , res .fragments )
1410
1410
1411
- mask = np .in1d (group .indices , allfrags .indices )
1411
+ mask = np .isin (group .indices , allfrags .indices )
1412
1412
return group [mask ]
1413
1413
# [xyz] must come before self.prop_trans lookups too!
1414
1414
try :
@@ -1419,7 +1419,7 @@ def _apply(self, group):
1419
1419
# KeyError at this point is impossible!
1420
1420
attrname = self .prop_trans [self .prop ]
1421
1421
vals = getattr (res , attrname )
1422
- mask = np .in1d (getattr (group , attrname ), vals )
1422
+ mask = np .isin (getattr (group , attrname ), vals )
1423
1423
1424
1424
return group [mask ]
1425
1425
else :
0 commit comments