当前位置: 首页>>代码示例>>Python>>正文


Python Model.toDataSet方法代码示例

本文整理汇总了Python中Model.Model.toDataSet方法的典型用法代码示例。如果您正苦于以下问题:Python Model.toDataSet方法的具体用法?Python Model.toDataSet怎么用?Python Model.toDataSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.Model的用法示例。


在下文中一共展示了Model.toDataSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import toDataSet [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()
开发者ID:Jacob-McPhail,项目名称:Interpreter_V2,代码行数:42,代码来源:Controller.py

示例2: UnitTest

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import toDataSet [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)
开发者ID:Jacob-McPhail,项目名称:Interpreter_V2,代码行数:90,代码来源:UnitTests.py


注:本文中的Model.Model.toDataSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。