PyDoc: include buffer access in examples, cleanup

Note that buffer access is possible, also minor mathutils test cleanup.
This commit is contained in:
Campbell Barton
2025-08-16 17:38:20 +10:00
parent e297fb4f14
commit 990f0863e8
6 changed files with 22 additions and 6 deletions

View File

@@ -64,12 +64,18 @@ def _test_flat_buffer_protocol(self, ty, n):
vec = ty(expected)
vec.freeze()
view = memoryview(vec)
with self.assertRaises(TypeError):
view = memoryview(vec)
view[0] = 1
class MatrixTesting(unittest.TestCase):
def assertAlmostEqualMatrix(self, first, second, size, *, places=6, msg=None, delta=None):
for i in range(size):
for j in range(size):
self.assertAlmostEqual(first[i][j], second[i][j], places=places, msg=msg, delta=delta)
def test_matrix_column_access(self):
# mat =
# [ 1 2 3 4 ]
@@ -302,11 +308,6 @@ class MatrixTesting(unittest.TestCase):
self.assertEqual(view.format, "f")
self.assertEqual(view.tolist(), expected)
def assertAlmostEqualMatrix(self, first, second, size, *, places=6, msg=None, delta=None):
for i in range(size):
for j in range(size):
self.assertAlmostEqual(first[i][j], second[i][j], places=places, msg=msg, delta=delta)
class VectorTesting(unittest.TestCase):