Ejemplo n.º 1
0
 def test_cannot_instantiate(self):
     """showing we normally can't instantiate an abstract class"""
     with self.assertRaises(TypeError) as e:
         BaseColumnPrimitiveTypeProfiler()
     self.assertEqual(
         "Can't instantiate abstract class BaseColumnPrimitiveTypeProfiler "
         "with abstract methods _update_helper, profile, update",
         str(e.exception))
Ejemplo n.º 2
0
    def test_add_helper(self):
        with patch.multiple(BaseColumnPrimitiveTypeProfiler,
                            __abstractmethods__=set()):
            profile1 = BaseColumnPrimitiveTypeProfiler(name=0)

        with patch.multiple(BaseColumnPrimitiveTypeProfiler,
                            __abstractmethods__=set()):
            profile2 = BaseColumnPrimitiveTypeProfiler(name=0)

        with patch.multiple(BaseColumnPrimitiveTypeProfiler,
                            __abstractmethods__=set()):
            merged_profile = BaseColumnPrimitiveTypeProfiler(name=0)

        profile1.match_count = 2
        profile2.match_count = 3

        profile1.sample_size = 2
        profile2.sample_size = 3

        # Check if match_count was merged
        merged_profile._add_helper(profile1, profile2)
        self.assertEqual(merged_profile.match_count, 5)

        # Check if sample size merged
        self.assertEqual(merged_profile.sample_size, 5)

        # Check for np.nan column index values for the merged profile
        self.assertTrue(np.isnan(merged_profile.col_index))

        # Check for name alignment
        self.assertEqual(merged_profile.name, profile2.name)
Ejemplo n.º 3
0
 def setUpClass(cls):
     with patch.multiple(BaseColumnPrimitiveTypeProfiler,
                         __abstractmethods__=set()):
         cls.b_profile = BaseColumnPrimitiveTypeProfiler(name=0)
Ejemplo n.º 4
0
 def test_combine_unqiue_sets(self):
     a = [1, 2, 3]
     b = [3, 1, 4, -1]
     c = BaseColumnPrimitiveTypeProfiler._combine_unique_sets(a, b)
     six.assertCountEqual(self, [1, 2, 3, 4, -1], c)