- Timestamp:
- Aug 30, 2016, 4:56:08 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r1061 r1065 48 48 # index_mat_way: Function to look for a value within a matrix following a direction 49 49 # list_combos: Function to construct a new list with all possible N-combinations of the list-values 50 # list_coincidences: Function to provide the coincidences between two lists 51 # list_differences: Function to provide the differences between two lists 50 52 # num_chainSnum: Function to pass a value to a `ChainStrNum' number 51 53 # num_split: Function to split a string at each numeric value keeping the number as the last character of each cut … … 8373 8375 return stringv 8374 8376 8377 def list_coincidences(listA, listB): 8378 """ Function to provide the coincdences between two lists 8379 listA= list with values 8380 listB= list with values to match with 8381 >>> list_coincidences(range(10),range(8,15)) 8382 [8, 9], [8, 9], [0, 1] 8383 """ 8384 fname = 'list_coincidences' 8385 8386 coinc = list(set(listA).intersection(set(listB))) 8387 Acoin = [] 8388 Bcoin = [] 8389 8390 # Positions in each list 8391 for coinv in coinc: 8392 Acoin.append(listA.index(coinv)) 8393 Bcoin.append(listB.index(coinv)) 8394 8395 return coinc, Acoin, Bcoin 8396 8397 def list_differences(listA, listB): 8398 """ Function to provide the differences between two lists 8399 listA= list with values to match with 8400 listB= list with values 8401 >>> list_coincidences(range(10),range(8,15)) 8402 [10, 11, 12, 13, 14], [2, 3, 4, 5, 6] 8403 """ 8404 fname = 'list_differences' 8405 8406 # Not coincident of B in A 8407 diffs = list(set(listB).difference(set(listA))) 8408 Bdiff = [] 8409 8410 for diff in diffs: 8411 Bdiff.append(listB.index(diff)) 8412 8413 return diffs, Bdiff 8414 8375 8415 #quit() 8376 8416
Note: See TracChangeset
for help on using the changeset viewer.