Exemple #1
0
        public void TestGenerate_Simple()
        {
            var m_seedMock = new Mock <IAtomHashGenerator>(); var seedMock = m_seedMock.Object;
            var m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            SuppressedAtomHashGenerator generator = new SuppressedAtomHashGenerator(new Mock <IAtomHashGenerator>().Object,
                                                                                    new Xorshift(), AtomSuppression.Unsuppressed, 2);

            // no suppression
            {
                // first iteration, values are distributed and then neighbours xor'd
                // in. when two neighbours have the same value the second should be
                // rotated
                long[] first = new long[] { generator.Distribute(1) ^ 2L,
                                            generator.Distribute(2L) ^ 1L ^ generator.Rotate(1L), generator.Distribute(1) ^ 2L };

                long[] second = new long[] { generator.Distribute(first[0]) ^ first[1],
                                             generator.Distribute(first[1]) ^ first[0] ^ generator.Rotate(first[2]),
                                             generator.Distribute(first[2]) ^ first[1] };

                Assert.IsTrue(Compares.AreDeepEqual(
                                  second,
                                  generator.Generate(new long[] { 1L, 2L, 1L }, StereoEncoder.Empty, new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1 } },
                                                     Suppressed.None)));
            }
            // vertex '2' supressed
            BitArray suppressed = new BitArray(3);

            suppressed.Set(2, true);
            {
                long[] first = new long[] { generator.Distribute(1) ^ 2L, generator.Distribute(2L) ^ 1L, // generator.Rotate(1L) not included is '[2]' is suppressed
                                            0L, };

                long[] second = new long[] { generator.Distribute(first[0]) ^ first[1], // generator.Rotate(first[2]) not included is '[2]' is suppressed
                                             generator.Distribute(first[1]) ^ first[0], 0L };

                Assert.IsTrue(Compares.AreDeepEqual(
                                  second,
                                  generator.Generate(new long[] { 1L, 2L, 1L }, StereoEncoder.Empty, new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1 } },
                                                     Suppressed.FromBitSet(suppressed))));
            }
        }
Exemple #2
0
        public void TestGenerate_Disconnected()
        {
            var m_seedMock = new Mock <IAtomHashGenerator>(); var seedMock = m_seedMock.Object;
            var m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            SuppressedAtomHashGenerator generator = new SuppressedAtomHashGenerator(new Mock <IAtomHashGenerator>().Object,
                                                                                    new Xorshift(), AtomSuppression.Unsuppressed, 2);
            // there are no neighbours, the values should be rotated
            long expected = generator.Distribute(generator.Distribute(1));

            Assert.IsTrue(Compares.AreDeepEqual(
                              new long[] { expected, expected, expected },
                              generator.Generate(new long[] { 1L, 1L, 1L }, StereoEncoder.Empty, new int[][] { new int[] { }, new int[] { }, new int[] { } },
                                                 Suppressed.None)));
            BitArray suppressed = new BitArray(3);

            suppressed.Set(1, true);
            Assert.IsTrue(Compares.AreDeepEqual(
                              new long[] { expected, 0L, expected },
                              generator.Generate(new long[] { 1L, 1L, 1L }, StereoEncoder.Empty, new int[][] { new int[] { }, new int[] { }, new int[] { } },
                                                 Suppressed.FromBitSet(suppressed))));
        }
Exemple #3
0
        public void TestGenerate_ZeroDepth()
        {
            var m_seedMock = new Mock <IAtomHashGenerator>(); var seedMock = m_seedMock.Object;
            var m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            SuppressedAtomHashGenerator generator = new SuppressedAtomHashGenerator(new Mock <IAtomHashGenerator>().Object,
                                                                                    new Xorshift(), AtomSuppression.Unsuppressed, 0);

            Assert.IsTrue(Compares.AreDeepEqual(
                              new long[] { 1L, 1L, 1L },
                              generator.Generate(new long[] { 1L, 1L, 1L }, StereoEncoder.Empty, new int[][] { new int[] { }, new int[] { }, new int[] { } },
                                                 Suppressed.None)));

            BitArray suppressed = new BitArray(3);

            suppressed.Set(0, true);
            suppressed.Set(2, true);

            Assert.IsTrue(Compares.AreDeepEqual(
                              new long[] { 0L, 1L, 0L },
                              generator.Generate(new long[] { 1L, 1L, 1L }, StereoEncoder.Empty, new int[][] { new int[] { }, new int[] { }, new int[] { } },
                                                 Suppressed.FromBitSet(suppressed))));
        }
Exemple #4
0
        public void TestGenerate()
        {
            var m_seedMock = new Mock <IAtomHashGenerator>(); var seedMock = m_seedMock.Object;
            var m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            IAtomHashGenerator generator = new SuppressedAtomHashGenerator(seedMock, new Xorshift(),
                                                                           AtomSuppression.Unsuppressed, 0);

            m_seedMock.Setup(n => n.Generate(container)).Returns(new long[0]);
            m_container.SetupGet(n => n.Bonds).Returns(new IBond[0]);

            generator.Generate(container);

            m_seedMock.Verify(n => n.Generate(container), Times.Exactly(1));
        }