當前位置: 首頁>>代碼示例>>Python>>正文


Python Sortings.find_maximum方法代碼示例

本文整理匯總了Python中SortingStudy.Sortings.find_maximum方法的典型用法代碼示例。如果您正苦於以下問題:Python Sortings.find_maximum方法的具體用法?Python Sortings.find_maximum怎麽用?Python Sortings.find_maximum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SortingStudy.Sortings的用法示例。


在下文中一共展示了Sortings.find_maximum方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_find_maximum__if_non_list_value__exception_thrown

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import find_maximum [as 別名]
    def test_find_maximum__if_non_list_value__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with float value
        3. Call find_maximum()

        Expected result: Exception thrown
        """
        sortings = Sortings()
        sortings.list = 20.12

        with self.assertRaises(Exception) as actual:
            sortings.find_maximum()

        self.assertEqual("Can not find maximum for object of type not 'list'", actual.exception.message)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:18,代碼來源:SortingStudyTests.py

示例2: test_find_maximum__if_list_of_lists__exception_thrown

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import find_maximum [as 別名]
    def test_find_maximum__if_list_of_lists__exception_thrown(self):
        """
        Scenario:
        1. Create object of class Sortings
        2. Initialize list by list of two lists
        3. Call find_maximum()

        Expected result: Exception thrown
        """
        sorting = Sortings()
        sorting.list = [[1, 3, 4, 5, 0], [1, 2, 4, 6, 0, 9]]

        with self.assertRaises(Exception) as actual:
            sorting.find_maximum()

        self.assertEqual("An input list should contain only numeric values", actual.exception.message)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:18,代碼來源:SortingStudyTests.py

示例3: test__find_maximum__if_none__exception_thrown

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import find_maximum [as 別名]
    def test__find_maximum__if_none__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with None
        3. Call find_maximum()

        Expected result: Exception is thrown
        """

        sortings = Sortings()
        sortings.list = None

        with self.assertRaises(Exception) as actual:
            sortings.find_maximum()

        self.assertEqual("Can not find maximum in a list 'None'", actual.exception.message)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:19,代碼來源:SortingStudyTests.py

示例4: test__find_maximum__if_empty_list__exception_thrown

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import find_maximum [as 別名]
    def test__find_maximum__if_empty_list__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with an empty list
        3. Call find_maximum()

        Expected result: Exception is thrown
        """

        sortings = Sortings()
        sortings.list = []

        with self.assertRaises(Exception) as exc:
            sortings.find_maximum()

        self.assertEqual("Can not find maximum in an empty list", exc.exception.message)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:19,代碼來源:SortingStudyTests.py

示例5: test__find_maximum__if_all_values_are_identical__returns_one_value

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import find_maximum [as 別名]
    def test__find_maximum__if_all_values_are_identical__returns_one_value(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with equal values
        3. Call find_maximum()

        Expected result: Single initialized value returned
        """
        sortings = Sortings()
        sortings.list = [2, 2, 2, 2, 2, 2]

        actual_result = sortings.find_maximum()

        self.assertEqual(2, actual_result)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:17,代碼來源:SortingStudyTests.py

示例6: test__find_maximum__if_one_value__returns_this_value

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import find_maximum [as 別名]
    def test__find_maximum__if_one_value__returns_this_value(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with single value
        3. Call find_maximum()

        Expected result: This value is returned
        """
        sortings = Sortings()
        sortings.list = [0]

        actual_result = sortings.find_maximum()

        self.assertEqual(0, actual_result)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:17,代碼來源:SortingStudyTests.py

示例7: test__find_maximum__if_float_values__returns_maximum

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import find_maximum [as 別名]
    def test__find_maximum__if_float_values__returns_maximum(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with float values
        3. Call find_minimum()

        Expected result: The minimal value returned
        """
        sortings = Sortings()
        sortings.list = [0.333, 0, 1 / 3, 1.0 / 3.0]

        actual_result = sortings.find_maximum()

        self.assertEqual(1.0 / 3.0, actual_result)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:17,代碼來源:SortingStudyTests.py

示例8: test__find_maximum__if_negative_values__returns_maximum

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import find_maximum [as 別名]
    def test__find_maximum__if_negative_values__returns_maximum(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with negative values
        3. Call find_maximum()

        Expected result: Maximum value returned
        """
        sortings = Sortings()
        sortings.list = [-2, 2, -1, 0]

        actual_result = sortings.find_maximum()

        self.assertEqual(2, actual_result)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:17,代碼來源:SortingStudyTests.py


注:本文中的SortingStudy.Sortings.find_maximum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。