[add] new function added which return the index of the value of an array which is nearest to a desired value
This commit is contained in:
parent
4606f84809
commit
78a5a5117a
@ -246,6 +246,16 @@ def findComboBoxIndex(combo_box, val):
|
|||||||
"""
|
"""
|
||||||
return combo_box.findText(val) if combo_box.findText(val) is not -1 else 0
|
return combo_box.findText(val) if combo_box.findText(val) is not -1 else 0
|
||||||
|
|
||||||
|
def find_nearest(array, value):
|
||||||
|
'''
|
||||||
|
Function find_nearest takes an array and a value and returns the
|
||||||
|
index of the nearest value found in the array.
|
||||||
|
:param array:
|
||||||
|
:param value:
|
||||||
|
:return:
|
||||||
|
'''
|
||||||
|
return (np.abs(array-value)).argmin()
|
||||||
|
|
||||||
def fnConstructor(s):
|
def fnConstructor(s):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user