def test_read_and_write_data_set(self): with TemporaryDirectory() as d: self.data_set.write_data_set(d) new_data_set = DataSet.read_data_set("{}/test".format(d)) self.assertEqual(new_data_set.publisher_count, 2) self.assertEqual(new_data_set.name, "test") self.assertEqual( new_data_set.reach_by_impressions([4, 0]).reach(), 3) self.assertEqual( new_data_set.reach_by_impressions([0, 2]).reach(), 2) self.assertEqual( new_data_set.reach_by_impressions([4, 2]).reach(), 4)
def by_name(self, name: str) -> DataSet: """Returns the DataSet having the given name.""" return DataSet.read_data_set(join(self._dirpath, name), self._filesystem)