Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_iadd_matrix(self):
"""Test in place add a matrix"""
m5 = Matrix(copy.deepcopy(self.data))
m6 = Matrix(copy.deepcopy(self.data))
m7 = m5.column + m6
result2 = [
[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],
[1, 2, 3, 4, "", "", 1, 2, 3, 4, "", ""],
[1, "", "", "", "", "", 1, "", "", "", "", ""],
]
eq_(result2, m7.get_internal_array())
def test_add(self):
r3 = Matrix(self.data)
r3 = r3.row + self.content
assert r3.row[3] == ["r", "s", "t", "o", ""]
assert r3.row[4] == [1, 2, 3, 4, ""]
assert r3.row[5] == [True, "", "", "", ""]
assert r3.row[6] == [1.1, 2.2, 3.3, 4.4, 5.5]
def test_iadd_matrix(self):
"""Test in place add"""
r2 = Matrix(self.data)
r3 = Matrix(self.content)
r2.row += r3
assert r2.row[3] == ["r", "s", "t", "o", ""]
assert r2.row[4] == [1, 2, 3, 4, ""]
assert r2.row[5] == [True, "", "", "", ""]
assert r2.row[6] == [1.1, 2.2, 3.3, 4.4, 5.5]
def test_get_with_a_wrong_column_index(self):
"""Get with a wrong index"""
m = Matrix(self.data)
m.column[1.11] # bang, string type index
def test_set_columns(self):
matrix = Matrix(self.data)
content = ["r", "s", "t", "o"]
matrix.column[1] = content
assert matrix.column[1] == content
assert matrix.column[0] == [1, 1, 1, ""]
matrix.column["B"] = ["p", "q", "r"]
eq_(matrix.column["B"], ["p", "q", "r", "o"])
def test_set_column_at(self):
r = Matrix(self.data)
try:
r.set_column_at(1, [11, 1], 1000)
assert 1 == 2
except IndexError:
assert 1 == 1
def test_extend_columns(self):
"""Test extend columns"""
m = Matrix(self.data)
m.extend_columns(self.data3)
eq_(self.result, m.get_internal_array())
def test_set_a_special_slice(self):
r = Matrix(self.data)
content3 = [True, False, True, False]
r.column[0:0] = content3
assert r.column[0] == content3
def test_delete_a_slice(self):
m = Matrix(self.data)
del m.column[0:2]
assert m.row[0] == [3, 4, 5, 6]
def test_set_an_invalid_slice(self):
m = Matrix(self.data)
try:
m.column[2:1] = ["e", "r", "r", "o"]
assert 1 == 2
except ValueError:
assert 1 == 1