def test_profile_merge_edge_case(self): data = [2.0, 'not a float', 6.0, 'not a float'] df = pd.Series(data).apply(str) profiler1 = FloatColumn("Float") profiler1.update(df) profiler1.match_count = 0 data2 = [10.0, 'not a float', 15.0, 'not a float'] df2 = pd.Series(data2).apply(str) profiler2 = FloatColumn("Float") profiler2.update(df2) profiler3 = profiler1 + profiler2 self.assertEqual(profiler3.stddev, profiler2.stddev) # test merge with empty data df1 = pd.Series([], dtype=object) profiler1 = FloatColumn("Float") profiler1.update(df1) df2 = pd.Series([], dtype=object) profiler2 = FloatColumn("Float") profiler2.update(df2) profiler = profiler1 + profiler2 self.assertEqual(profiler.min, None) self.assertEqual(profiler.max, None) df3 = pd.Series([2.0, 3.0]).apply(str) profiler3 = FloatColumn("Float") profiler3.update(df3) profiler = profiler1 + profiler3 self.assertEqual(profiler.min, 2.0) self.assertEqual(profiler.max, 3.0) df4 = pd.Series([4.0, 5.0]).apply(str) profiler4 = FloatColumn("Float") profiler4.update(df4) profiler = profiler3 + profiler4 self.assertEqual(profiler.min, 2.0) self.assertEqual(profiler.max, 5.0)
def test_profile_merge_no_bin_overlap(self): data = [2.0, 'not a float', 6.0, 'not a float'] df = pd.Series(data).apply(str) profiler1 = FloatColumn("Float") profiler1.update(df) profiler1.match_count = 0 data2 = [10.0, 'not a float', 15.0, 'not a float'] df2 = pd.Series(data2).apply(str) profiler2 = FloatColumn("Float") profiler2.update(df2) # set bin names so no overlap profiler1.histogram_bin_method_names = ['No overlap 1'] profiler2.histogram_bin_method_names = ['No overlap 2'] with self.assertRaisesRegex( ValueError, 'Profiles have no overlapping bin methods ' 'and therefore cannot be added together.'): profiler1 + profiler2