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


Python Model.get_gender方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get_gender [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 get_gender [as 别名]
class UnitTest(unittest.TestCase):

    def test_file_input(self):
        self.myModel = Model()
        self.myModel.data_handler.read_in("TestData.csv")
        self.expected = Person('D003', 'M', 12, 312, 'Normal', 123)
        self.assertEquals(self.myModel.data_handler.get_data()[0].get_id(), self.expected.get_id())
        self.assertEquals(self.myModel.data_handler.get_data()[0].get_weight(), self.expected.get_weight())
        self.assertEquals(self.myModel.data_handler.get_data()[0].get_age(), self.expected.get_age())
        self.assertEquals(self.myModel.data_handler.get_data()[0].get_sales(), self.expected.get_sales())
        self.assertEquals(self.myModel.data_handler.get_data()[0].get_income(), self.expected.get_income())

    def test_csv_file_input(self):
        self.myModel = Model()
        self.myModel.data_handler.read_in("TestData.csv")
        self.expected = 12
        self.failUnlessEqual(len(self.myModel.data_handler.unwashed_data_set), self.expected)

    def test_washing_data(self):
        self.myModel = Model()
        # There are 5 errors so length should be cut down to 7 after washing
        self.myModel.data_handler.read_in("TestData.csv")
        self.expected = 7
        self.failUnlessEqual(len(self.myModel.data_handler.get_data()), self.expected)

    def test_get_weight(self):
        self.myModel = Model()
        self.myModel.data_handler.read_in("TestData.csv")
        self.expected = 4
        self.failUnlessEqual(len(self.myModel.get_weight()), self.expected)
        self.failUnlessEqual(self.myModel.get_weight()[0], 2)
        self.failUnlessEqual(self.myModel.get_weight()[3], 4)
        self.failUnlessEqual(self.myModel.get_weight()[2], 1)

    def test_get_gender(self):
        self.myModel = Model()
        self.myModel.data_handler.read_in("TestData.csv")
        self.expected = 2
        self.failUnlessEqual(len(self.myModel.get_gender()), self.expected)
        self.failUnlessEqual(self.myModel.get_gender()[0], 2)
        self.failUnlessEqual(self.myModel.get_gender()[1], 5)

    def test_get_sales(self):
        self.myModel = Model()
        self.myModel.data_handler.read_in("TestData.csv")
        self.expected = 7
        self.failUnlessEqual(len(self.myModel.get_sales()), self.expected)
        self.failUnlessEqual(self.myModel.get_sales()[0], 312)
        self.failUnlessEqual(self.myModel.get_sales()[3], 636)
        self.failUnlessEqual(self.myModel.get_sales()[-1], 345)

    def test_del_data(self):
        self.myModel = Model()
        self.myModel.data_handler.read_in("TestData.csv")
        self.expected = 7
        self.failUnlessEqual(len(self.myModel.data_handler.get_data()), self.expected)
        self.myModel.data_handler.del_data()
        self.expected = 0
        self.failUnlessEqual(len(self.myModel.data_handler.get_data()), self.expected)

    def test_pickle_methods(self):
        self.myModel = Model()
        self.myModel.data_handler.read_in("TestData.csv")
        self.myModel.data_handler.save_pickle_data()
        self.myModel.data_handler.del_data()
        self.myModel.data_handler.load_pickle_data()
        self.expected = 7
        self.failUnlessEqual(len(self.myModel.data_handler.get_data()), self.expected)
开发者ID:ZachChristensen,项目名称:PR301InterpreterPattern,代码行数:70,代码来源:UnitTests.py


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