Exemplo n.º 1
0
 def test_fit(self):
     a = LocalEncodedAngle()
     a.fit(ALL_DATA)
     expected = (('C', 'C'), ('C', 'H'), ('C', 'N'), ('C', 'O'),
                 ('H', 'H'), ('H', 'N'), ('H', 'O'), ('N', 'N'),
                 ('N', 'O'), ('O', 'O'))
     self.assertEqual(a._pairs, expected)
Exemplo n.º 2
0
 def test_fit(self):
     a = LocalEncodedAngle()
     a.fit(ALL_DATA)
     expected = set([('C', 'C'), ('C', 'H'), ('C', 'N'), ('C', 'O'),
                     ('H', 'H'), ('H', 'N'), ('H', 'O'), ('N', 'N'),
                     ('N', 'O'), ('O', 'O')])
     self.assertEqual(a._pairs, expected)
Exemplo n.º 3
0
 def test_get_labels(self):
     a = LocalEncodedAngle(segments=2)
     m = a.fit_transform([METHANE])
     labels = a.get_labels()
     self.assertEqual(m.shape[2], len(labels))
     expected = (
         'C-H_0.0', 'C-H_3.14159',
         'H-H_0.0', 'H-H_3.14159',
     )
     self.assertEqual(labels, expected)
Exemplo n.º 4
0
 def test_transform_max_depth1(self):
     a = LocalEncodedAngle(max_depth=1)
     a.fit(ALL_DATA)
     m = a.transform(ALL_DATA)
     expected_results = numpy.array([13.078022, 7.028573, 146.255683])
     mm = numpy.array([x.sum() for x in m])
     try:
         numpy.testing.assert_allclose(mm, expected_results)
     except AssertionError as e:
         self.fail(e)
Exemplo n.º 5
0
 def test_transform(self):
     a = LocalEncodedAngle()
     a.fit(ALL_DATA)
     m = a.transform([METHANE, MID])
     expected_results = numpy.array([42.968775, 53.28433])
     mm = numpy.array([x.sum() for x in m])
     try:
         numpy.testing.assert_allclose(mm, expected_results)
     except AssertionError as e:
         self.fail(e)
Exemplo n.º 6
0
 def test_transform(self):
     a = LocalEncodedAngle()
     a.fit(ALL_DATA)
     m = a.transform([METHANE, MID])
     expected_results = numpy.array([42.968775,
                                     53.28433])
     mm = numpy.array([x.sum() for x in m])
     try:
         numpy.testing.assert_allclose(mm, expected_results)
     except AssertionError as e:
         self.fail(e)
Exemplo n.º 7
0
 def test_get_labels(self):
     a = LocalEncodedAngle(segments=2)
     m = a.fit_transform([METHANE])
     labels = a.get_labels()
     self.assertEqual(m.shape[2], len(labels))
     expected = (
         'C-H_0.0',
         'C-H_3.14159',
         'H-H_0.0',
         'H-H_3.14159',
     )
     self.assertEqual(labels, expected)
Exemplo n.º 8
0
 def test_transform_max_depth1(self):
     a = LocalEncodedAngle(max_depth=1)
     a.fit(ALL_DATA)
     m = a.transform(ALL_DATA)
     expected_results = numpy.array([13.078022,
                                     7.028573,
                                     146.255683])
     mm = numpy.array([x.sum() for x in m])
     try:
         numpy.testing.assert_allclose(mm, expected_results)
     except AssertionError as e:
         self.fail(e)
Exemplo n.º 9
0
    def test_small_to_large(self):
        a = LocalEncodedAngle()
        a.fit([METHANE])

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.005350052647,  # mean
            0.036552192752,  # std
            0.,  # min
            0.614984152986,  # max
            9.630094765591,  # sum
        ])
        try:
            m = a.transform([MID])
            val = numpy.array([
                m.mean(),
                m.std(),
                m.min(),
                m.max(),
                m.sum(),
            ])
            numpy.testing.assert_allclose(val, expected_results)
        except AssertionError as e:
            self.fail(e)
Exemplo n.º 10
0
    def test_small_to_large(self):
        a = LocalEncodedAngle()
        a.fit([METHANE])

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.005350052647,  # mean
            0.036552192752,  # std
            0.,              # min
            0.614984152986,  # max
            9.630094765591,  # sum
        ])
        try:
            m = a.transform([MID])
            val = numpy.array([
                m.mean(),
                m.std(),
                m.min(),
                m.max(),
                m.sum(),
            ])
            numpy.testing.assert_allclose(val, expected_results)
        except AssertionError as e:
            self.fail(e)
Exemplo n.º 11
0
 def test_form0(self):
     a = LocalEncodedAngle(form=0)
     m = a.fit_transform([METHANE])
     self.assertEqual(m.shape, (1, 5, 100))
Exemplo n.º 12
0
 def test_add_unknown(self):
     a = LocalEncodedAngle(add_unknown=True)
     a.fit([METHANE])
     m = a.transform([MID])
     self.assertEqual(m.shape, (1, 9, 300))
Exemplo n.º 13
0
 def test_transform_invalid_smoothing(self):
     a = LocalEncodedAngle(smoothing='not real"')
     with self.assertRaises(KeyError):
         a.fit_transform(ALL_DATA)
Exemplo n.º 14
0
 def test_transform_before_fit(self):
     a = LocalEncodedAngle()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)
Exemplo n.º 15
0
 def test_form0(self):
     a = LocalEncodedAngle(form=0)
     m = a.fit_transform([METHANE])
     self.assertEqual(m.shape, (1, 5, 100))
Exemplo n.º 16
0
 def test_add_unknown(self):
     a = LocalEncodedAngle(add_unknown=True)
     a.fit([METHANE])
     m = a.transform([MID])
     self.assertEqual(m.shape, (1, 9, 300))
Exemplo n.º 17
0
 def test_transform_invalid_smoothing(self):
     a = LocalEncodedAngle(smoothing='not real"')
     with self.assertRaises(KeyError):
         a.fit_transform(ALL_DATA)
Exemplo n.º 18
0
 def test_transform_before_fit(self):
     a = LocalEncodedAngle()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)