本文整理汇总了Python中Model.Model.wash_data方法的典型用法代码示例。如果您正苦于以下问题:Python Model.wash_data方法的具体用法?Python Model.wash_data怎么用?Python Model.wash_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.wash_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import wash_data [as 别名]
class Controller:
def __init__(self, path):
self.myModel = Model(Filer(), Validator())
if path != "" or path is not None:
self.load_data(path)
self.myView = View(self)
self.myModel.pickle_data()
self.myView.cmdloop()
def delete_data(self):
self.myModel.del_data()
def wash_data(self):
self.myModel.wash_data()
self.myModel.toDataSet()
def get_data(self):
return self.myModel.get_data()
def get_weight_data(self):
return self.myModel.get_weight()
def get_sales_data(self):
return self.myModel.get_sales()
def get_gender_data(self):
return self.myModel.get_gender()
def load_data(self, path):
try:
file = open(path)
file.read()
except FileNotFoundError:
print("File Does Not Exist")
return
self.myModel.read(path)
self.wash_data()
def save_data(self):
self.myModel.save_data()
示例2: UnitTest
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import wash_data [as 别名]
class UnitTest(unittest.TestCase):
def test_file_input(self):
self.myFiler = Filer()
self.myValidator = Validator()
self.myModel = Model(self.myFiler,self.myValidator)
self.myFiler.read("TestData.csv")
self.myModel.toDataSet()
self.failIfEqual(self.myModel.get_data_set(), None)
def test_csv_file_input(self):
self.myFiler = Filer()
self.myValidator = Validator()
self.myModel = Model(self.myFiler,self.myValidator)
self.myFiler.read("TestData.csv")
self.expected = 12
self.myModel.toDataSet()
self.failUnlessEqual(self.myModel.get_data_set().__len__(), self.expected)
def test_washing_data(self):
# There are 5 errors so length should be cut down to 7 after washing
self.myFiler = Filer()
self.myValidator = Validator()
self.myModel = Model(self.myFiler,self.myValidator)
self.myFiler.read("TestData.csv")
self.expected = 8
self.myModel.toDataSet()
self.failUnlessEqual(self.myModel.wash_data().__len__(), self.expected)
def test_validator_id(self):
self.myValidator = Validator()
self.result = self.myValidator.match_id("D003")
self.expected = None
self.failIfEqual(self.result, self.expected)
self.result = self.myValidator.match_id("DDD03")
self.expected = None
self.failUnlessEqual(self.result, self.expected)
def test_validator_gender(self):
self.myValidator = Validator()
self.result = self.myValidator.match_gender("M")
self.expected = None
self.failIfEqual(self.result, self.expected)
self.result = self.myValidator.match_gender("G")
self.expected = None
self.failUnlessEqual(self.result, self.expected)
def test_validator_age(self):
self.myValidator = Validator()
self.result = self.myValidator.match_age("13")
self.expected = None
self.failIfEqual(self.result, self.expected)
self.result = self.myValidator.match_age("F")
self.expected = None
self.failUnlessEqual(self.result, self.expected)
def test_validator_bmi(self):
self.myValidator = Validator()
self.result = self.myValidator.match_bmi("235")
self.expected = None
self.failIfEqual(self.result, self.expected)
self.result = self.myValidator.match_bmi("F")
self.expected = None
self.failUnlessEqual(self.result, self.expected)
def test_validator_weight(self):
self.myValidator = Validator()
self.result = self.myValidator.match_weight("Normal")
self.expected = None
self.failIfEqual(self.result, self.expected)
self.result = self.myValidator.match_weight("F")
self.expected = None
self.failUnlessEqual(self.result, self.expected)
def test_validator_sales(self):
self.myValidator = Validator()
self.result = self.myValidator.match_sales("235")
self.expected = None
self.failIfEqual(self.result, self.expected)
self.result = self.myValidator.match_sales("FED")
self.expected = None
self.failUnlessEqual(self.result, self.expected)
def test_filer_read(self):
self.myFiler = Filer()
self.myFiler.read("TestData.csv")
self.result = self.myFiler.getData()
self.notExpected = None
self.failIfEqual(self.result, self.notExpected)