def elem_find ( self , field , value ) : if isinstance ( value , ( int , float , str ) ) : value = [ value ] f = list ( self . __dict__ [ field ] ) uid = np . vectorize ( f . index ) ( value ) return self . get_idx ( uid )
python locate index for certain value
Return the indices of elements whose field first satisfies the given values
def elem_find(self, field, value):
        """
        Return the indices of elements whose field first satisfies the given values

        ``value`` should be unique in self.field.
        This function does not check the uniqueness.

        :param field: name of the supplied field
        :param value: value of field of the elemtn to find
        :return: idx of the elements
        :rtype: list, int, float, str
        """
        if isinstance(value, (int, float, str)):
            value = [value]

        f = list(self.__dict__[field])
        uid = np.vectorize(f.index)(value)
        return self.get_idx(uid)