Exemple #1
0
def insert_unique_hand(interface, hand, hand_list, finger_list):
    """
    @brief insert a Hand into the database if it does not already exist in this list of fingers.
    otherwise, it simply sets the id of the given Hand to the similar Hand found in the database.

    FIXME - Maybe the test for uniqueness should be on the database server side instead of maintaining a unique list
    This is probably really inefficient as we do it so many times, but it doesn't occur during the blocking phase of the experiment
    For longer experiments where the number of fingers becomes astronomically large, this could really be a problem

    @param hand - the Finger to install
    @param hand_list - The list of hands to test against.
    @param finger_list - The list of fingers to test against.     
    """
    hand.fingers = [
        insert_unique_finger(interface, finger, finger_list)
        for finger in hand.fingers
    ]
    hand.finger_id_list = [finger.finger_id for finger in hand.fingers]
    equivalent_hand = eigenhand_db_objects.find_equivalent_hand(
        hand_list, hand)
    if equivalent_hand:
        hand.hand_id = equivalent_hand.hand_id
        interface.update_hand_generation(hand)
        return equivalent_hand
    hand.hand_id = interface.add_hand_to_db(hand)[0]
    return hand
def insert_new_hand(hand, hand_list, interface):
    """
    @brief Inserts a Hand into the database if it does not exist in a list of known Hands

    @param hand - The Finger to add
    @param hand_list - The list of Hands to compare the new hand to.
    @param interface - The database interface to use to add the hand. 
    """
    if(not eigenhand_db_objects.find_equivalent_hand(hand_list, hand)):
        return interface.add_hand_to_db(hand)
    return -1
Exemple #3
0
def insert_new_hand(hand, hand_list, interface):
    """
    @brief Inserts a Hand into the database if it does not exist in a list of known Hands

    @param hand - The Finger to add
    @param hand_list - The list of Hands to compare the new hand to.
    @param interface - The database interface to use to add the hand. 
    """
    if (not eigenhand_db_objects.find_equivalent_hand(hand_list, hand)):
        return interface.add_hand_to_db(hand)
    return -1
def insert_unique_hand(interface, hand, hand_list, finger_list):
    """
    @brief insert a Hand into the database if it does not already exist in this list of fingers.
    otherwise, it simply sets the id of the given Hand to the similar Hand found in the database.

    FIXME - Maybe the test for uniqueness should be on the database server side instead of maintaining a unique list
    This is probably really inefficient as we do it so many times, but it doesn't occur during the blocking phase of the experiment
    For longer experiments where the number of fingers becomes astronomically large, this could really be a problem

    @param hand - the Finger to install
    @param hand_list - The list of hands to test against.
    @param finger_list - The list of fingers to test against.     
    """
    hand.fingers = [insert_unique_finger(interface, finger, finger_list) for finger in hand.fingers]
    hand.finger_id_list = [finger.finger_id for finger in hand.fingers]
    equivalent_hand = eigenhand_db_objects.find_equivalent_hand(hand_list, hand)    
    if equivalent_hand:
        hand.hand_id = equivalent_hand.hand_id
        interface.update_hand_generation(hand)
        return equivalent_hand
    hand.hand_id = interface.add_hand_to_db(hand)[0]
    return hand