Exemple #1
0
    def test_ordered_results_has_results_post_reset(self):
        """
        Test that an empty list is returned after a reset where there was a
        cached value before the reset.
        """
        iqrs = IqrSession()

        # Mocking results map existing for return.
        d0 = DescriptorMemoryElement('', 0).set_vector([0])
        d1 = DescriptorMemoryElement('', 1).set_vector([1])
        d2 = DescriptorMemoryElement('', 2).set_vector([2])
        d3 = DescriptorMemoryElement('', 3).set_vector([3])
        iqrs.results = {
            d0: 0.0,
            d1: 0.8,
            d2: 0.2,
            d3: 0.4,
        }

        # Initial call to ``ordered_results`` should have a non-None return.
        assert iqrs.ordered_results() is not None

        iqrs.reset()

        # Post-reset, there should be no results nor cache.
        actual = iqrs.ordered_results()
        assert actual == []
Exemple #2
0
    def test_reset_result_cache_invalidation(self):
        """
        Test that calling the reset method resets the result view caches to
        None.
        """
        # Setup initial IQR session state
        iqrs = IqrSession()
        iqrs._ordered_pos = iqrs._ordered_neg = iqrs._ordered_non_adj = True

        iqrs.reset()
        assert iqrs._ordered_pos is None
        assert iqrs._ordered_neg is None
        assert iqrs._ordered_non_adj is None