def testCountOverlap(self):
    """
    Test that the internal method _countOverlap works as expected.
    """
    enc = RandomDistributedScalarEncoder(name='enc', resolution=1.0, n=500)

    r1 = numpy.array([1, 2, 3, 4, 5, 6])
    r2 = numpy.array([1, 2, 3, 4, 5, 6])
    self.assertEqual(enc._countOverlap(r1, r2), 6,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([1, 2, 3, 4, 5, 6])
    r2 = numpy.array([1, 2, 3, 4, 5, 7])
    self.assertEqual(enc._countOverlap(r1, r2), 5,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([1, 2, 3, 4, 5, 6])
    r2 = numpy.array([6, 5, 4, 3, 2, 1])
    self.assertEqual(enc._countOverlap(r1, r2), 6,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([1, 2, 8, 4, 5, 6])
    r2 = numpy.array([1, 2, 3, 4, 9, 6])
    self.assertEqual(enc._countOverlap(r1, r2), 4,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([1, 2, 3, 4, 5, 6])
    r2 = numpy.array([1, 2, 3])
    self.assertEqual(enc._countOverlap(r1, r2), 3,
                     "_countOverlap result is incorrect")

    r1 = numpy.array([7, 8, 9, 10, 11, 12])
    r2 = numpy.array([1, 2, 3, 4, 5, 6])
    self.assertEqual(enc._countOverlap(r1, r2), 0,
                     "_countOverlap result is incorrect")
Exemple #2
0
    def testCountOverlap(self):
        """
    Test that the internal method _countOverlap works as expected.
    """
        enc = RandomDistributedScalarEncoder(name='enc', resolution=1.0, n=500)

        r1 = numpy.array([1, 2, 3, 4, 5, 6])
        r2 = numpy.array([1, 2, 3, 4, 5, 6])
        self.assertEqual(enc._countOverlap(r1, r2), 6,
                         "_countOverlap result is incorrect")

        r1 = numpy.array([1, 2, 3, 4, 5, 6])
        r2 = numpy.array([1, 2, 3, 4, 5, 7])
        self.assertEqual(enc._countOverlap(r1, r2), 5,
                         "_countOverlap result is incorrect")

        r1 = numpy.array([1, 2, 3, 4, 5, 6])
        r2 = numpy.array([6, 5, 4, 3, 2, 1])
        self.assertEqual(enc._countOverlap(r1, r2), 6,
                         "_countOverlap result is incorrect")

        r1 = numpy.array([1, 2, 8, 4, 5, 6])
        r2 = numpy.array([1, 2, 3, 4, 9, 6])
        self.assertEqual(enc._countOverlap(r1, r2), 4,
                         "_countOverlap result is incorrect")

        r1 = numpy.array([1, 2, 3, 4, 5, 6])
        r2 = numpy.array([1, 2, 3])
        self.assertEqual(enc._countOverlap(r1, r2), 3,
                         "_countOverlap result is incorrect")

        r1 = numpy.array([7, 8, 9, 10, 11, 12])
        r2 = numpy.array([1, 2, 3, 4, 5, 6])
        self.assertEqual(enc._countOverlap(r1, r2), 0,
                         "_countOverlap result is incorrect")