Beispiel #1
0
    def set_internal_unmasked_qaids(qreq_, unmasked_qaid_list):
        """
        used by the pipeline to execute a subset of the query request
        without modifying important state

        Example:
            >>> # ENABLE_DOCTEST
            >>> from ibeis.algo.hots.query_request import *  # NOQA
            >>> import utool as ut
            >>> from ibeis.algo.hots import pipeline
            >>> cfgdict1 = dict(codename='vsone', sv_on=True)
            >>> qaid_list = [1, 2, 3, 4]
            >>> daid_list = [1, 2, 3, 4]
            >>> ibs, qreq_ = plh.get_pipeline_testdata(cfgdict=cfgdict1,
            ...     qaid_list=qaid_list, daid_list=daid_list)
            >>> qaids = qreq_.get_internal_qaids()
            >>> ut.assert_lists_eq(qaid_list, qaids)
            >>> unmasked_qaid_list = [1, 2, 3,]
            >>> qreq_.set_internal_unmasked_qaids(unmasked_qaid_list)
            >>> new_internal_aids = qreq_.get_internal_qaids()
            >>> ut.assert_lists_eq(new_internal_aids, unmasked_qaid_list)
        """
        if unmasked_qaid_list is None:
            qreq_.internal_qaids_mask = None
        else:
            # input denotes valid elements
            # mark all elements not in that list as False
            flags = vt.get_covered_mask(
                qreq_.internal_qaids, unmasked_qaid_list)
            assert len(flags) == len(qreq_.internal_qaids), (
                'unequal len internal qaids')
            qreq_.internal_qaids_mask = flags
Beispiel #2
0
    def set_internal_unmasked_qaids(qreq_, unmasked_qaid_list):
        """
        used by the pipeline to execute a subset of the query request
        without modifying important state

        Example:
            >>> # ENABLE_DOCTEST
            >>> from ibeis.algo.hots.query_request import *  # NOQA
            >>> import utool as ut
            >>> import ibeis
            >>> qaid_list = [1, 2, 3, 4]
            >>> daid_list = [1, 2, 3, 4]
            >>> qreq_ = ibeis.testdata_qreq_(qaid_override=qaid_list, daid_override=daid_list, p='default:codename=vsone,sv_on=True')
            >>> qaids = qreq_.get_internal_qaids()
            >>> ut.assert_lists_eq(qaid_list, qaids)
            >>> unmasked_qaid_list = [1, 2, 3,]
            >>> qreq_.set_internal_unmasked_qaids(unmasked_qaid_list)
            >>> new_internal_aids = qreq_.get_internal_qaids()
            >>> ut.assert_lists_eq(new_internal_aids, unmasked_qaid_list)
        """
        if unmasked_qaid_list is None:
            qreq_.internal_qaids_mask = None
        else:
            # input denotes valid elements
            # mark all elements not in that list as False
            flags = vt.get_covered_mask(
                qreq_.internal_qaids, unmasked_qaid_list)
            assert len(flags) == len(qreq_.internal_qaids), (
                'unequal len internal qaids')
            qreq_.internal_qaids_mask = flags
Beispiel #3
0
    def remove_internal_daids(qreq_, remove_daids):
        r"""
        State Modification: remove daids from the query request.  Do not call
        this function often. It invalidates the indexer, which is very slow to
        rebuild.  Should only be done between query pipeline runs.

        CommandLine:
            python -m ibeis.algo.hots.query_request --test-remove_internal_daids

        Example:
            >>> # ENABLE_DOCTEST
            >>> from ibeis.algo.hots.query_request import *  # NOQA
            >>> import ibeis
            >>> # build test data
            >>> ibs = ibeis.opendb('testdb1')
            >>> species = ibeis.const.TEST_SPECIES.ZEB_PLAIN
            >>> daids = ibs.get_valid_aids(species=species, is_exemplar=True)
            >>> qaids = ibs.get_valid_aids(species=species, is_exemplar=False)
            >>> qreq_ = ibs.new_query_request(qaids, daids)
            >>> remove_daids = daids[0:1]
            >>> # execute function
            >>> assert len(qreq_.internal_daids) == 4, 'bad setup data'
            >>> qreq_.remove_internal_daids(remove_daids)
            >>> # verify results
            >>> assert len(qreq_.internal_daids) == 3, 'did not remove'
        """
        # Invalidate the current indexer, mask and metadata
        qreq_.indexer = None
        qreq_.internal_daids_mask = None
        #qreq_.metadata = {}
        # Find indices to remove
        delete_flags = vt.get_covered_mask(qreq_.internal_daids, remove_daids)
        delete_indices = np.where(delete_flags)[0]
        assert len(delete_indices) == len(remove_daids), (
            'requested removal of nonexistant daids')
        # Remove indices
        qreq_.internal_daids = np.delete(qreq_.internal_daids, delete_indices)
        # TODO: multi-indexer delete support
        if qreq_.indexer is not None:
            warnings.warn('Implement point removal from trees')
            qreq_.indexer.remove_ibeis_support(qreq_, remove_daids)
Beispiel #4
0
    def remove_internal_daids(qreq_, remove_daids):
        r"""
        State Modification: remove daids from the query request.  Do not call
        this function often. It invalidates the indexer, which is very slow to
        rebuild.  Should only be done between query pipeline runs.

        CommandLine:
            python -m ibeis.algo.hots.query_request --test-remove_internal_daids

        Example:
            >>> # ENABLE_DOCTEST
            >>> from ibeis.algo.hots.query_request import *  # NOQA
            >>> import ibeis
            >>> # build test data
            >>> ibs = ibeis.opendb('testdb1')
            >>> species = ibeis.const.TEST_SPECIES.ZEB_PLAIN
            >>> daids = ibs.get_valid_aids(species=species, is_exemplar=True)
            >>> qaids = ibs.get_valid_aids(species=species, is_exemplar=False)
            >>> qreq_ = ibs.new_query_request(qaids, daids)
            >>> remove_daids = daids[0:1]
            >>> # execute function
            >>> assert len(qreq_.internal_daids) == 4, 'bad setup data'
            >>> qreq_.remove_internal_daids(remove_daids)
            >>> # verify results
            >>> assert len(qreq_.internal_daids) == 3, 'did not remove'
        """
        # Invalidate the current indexer, mask and metadata
        qreq_.indexer = None
        qreq_.internal_daids_mask = None
        #qreq_.metadata = {}
        # Find indices to remove
        delete_flags = vt.get_covered_mask(qreq_.internal_daids, remove_daids)
        delete_indices = np.where(delete_flags)[0]
        assert len(delete_indices) == len(remove_daids), (
            'requested removal of nonexistant daids')
        # Remove indices
        qreq_.internal_daids = np.delete(qreq_.internal_daids, delete_indices)
        # TODO: multi-indexer delete support
        if qreq_.indexer is not None:
            warnings.warn('Implement point removal from trees')
            qreq_.indexer.remove_ibeis_support(qreq_, remove_daids)