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


Python Matrix.make_from_list方法代码示例

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


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

示例1: test_can_calculate_determinant_of_matrix6x6

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_can_calculate_determinant_of_matrix6x6(self):
     test_matrix = Matrix.make_from_list([[-1, 2, 3, 4, 5, 6],
                                          [7, 0, 4, -1, 0, -3],
                                          [0, 5, -6, 0, 0, 3],
                                          [1, 0, 3, 4, 5, 6],
                                          [0, 8, 0, 1, 2, 0],
                                          [-4, 0, 6, 0, 0, -5]])
     det = test_matrix.calculate_det()
     self.assertEqual(det, -96)
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:11,代码来源:tests_for_matrix.py

示例2: __init__

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def __init__(self):
     self.matrix = Matrix.make_from_list([[0]*3]*3)
     self.rows = 3
     self.answer = ''
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:6,代码来源:viewmodel.py

示例3: update_matrix_content

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def update_matrix_content(self, content):
     self.matrix = Matrix.make_from_list(content)
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:4,代码来源:viewmodel.py

示例4: test_get_data_line

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_get_data_line(self):
     test_matrix = Matrix.make_from_list([[7, 0], [5, 8]])
     self.assertEqual(test_matrix.get_data_lines(), [[7, 0], [5, 8]])
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:5,代码来源:tests_for_matrix.py

示例5: test_check_constructor

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_check_constructor(self):
     test_matrix = Matrix.make_from_list([[1, 1]])
     self.assertTrue(test_matrix.cols == 2 and test_matrix.rows == 1 and test_matrix.data_lines[0][0] ==
                     test_matrix.data_lines[0][1] == 1)
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:6,代码来源:tests_for_matrix.py

示例6: test_can_calculate_minor_0_1

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_can_calculate_minor_0_1(self):
     test_matrix = Matrix.delete_col_and_row(
         Matrix.make_from_list([[1, 0, -3], [0, 0, 2], [-1, -2, 0]]), 0, 1)
     det = test_matrix.calculate_det()
     self.assertEqual(det, 2)
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:7,代码来源:tests_for_matrix.py

示例7: test_delete_zero_row_and_zero_col_in_matrix

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_delete_zero_row_and_zero_col_in_matrix(self):
     test_matrix = Matrix.delete_col_and_row(
         Matrix.make_from_list([[1, 3], [5, 7]]), 0, 0)
     det = test_matrix.calculate_det()
     self.assertEqual(det, 7)
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:7,代码来源:tests_for_matrix.py

示例8: test_can_calculate_determinant_of_matrix3x3

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_can_calculate_determinant_of_matrix3x3(self):
     test_matrix = Matrix.make_from_list([[7, 2, 0], [5, 8, 7], [1, 2, 3]])
     det = test_matrix.calculate_det()
     self.assertEqual(det, 54)
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:6,代码来源:tests_for_matrix.py

示例9: test_can_calculate_determinant_of_matrix2x2

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_can_calculate_determinant_of_matrix2x2(self):
     test_matrix = Matrix.make_from_list([[1, 3], [5, 7]])
     det = test_matrix.calculate_det()
     self.assertEqual(det, -8)
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:6,代码来源:tests_for_matrix.py

示例10: test_can_not_delete_incorrect_col_or_row

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_can_not_delete_incorrect_col_or_row(self):
     test_matrix = Matrix.make_from_list([[1, 3], [5, 7], [5, 7]])
     with self.assertRaises(MatrixError):
         Matrix.delete_col_and_row(test_matrix, -100, -500)
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:6,代码来源:tests_for_matrix.py

示例11: test_check_exception

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_check_exception(self):
     with self.assertRaises(MatrixError):
         test_matrix = Matrix.make_from_list([[1, 3]])
         test_matrix.calculate_det()
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:6,代码来源:tests_for_matrix.py

示例12: test_can_write_matrix_as_string

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_can_write_matrix_as_string(self):
     test_matrix = Matrix.make_from_list([[1, 3], [5, 7]])
     self.assertEqual(str(test_matrix), '1 3\n5 7\n')
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:5,代码来源:tests_for_matrix.py

示例13: test_create_matrix_with_not_full_first_string

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import make_from_list [as 别名]
 def test_create_matrix_with_not_full_first_string(self):
     with self.assertRaises(MatrixError):
         Matrix.make_from_list([[1, 1], [1, 1, 1], [1, 2, 1]])
开发者ID:timonov,项目名称:agile-course-practice-python,代码行数:5,代码来源:tests_for_matrix.py


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