MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_memoryview

Function test_memoryview

tests/test_pixmap.py:110–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

108 assert pm.color_count() == 40624
109
110def test_memoryview():
111 pm = pymupdf.Pixmap(imgfile)
112 samples = pm.samples_mv
113 assert isinstance( samples, memoryview)
114 print( f'samples={samples} samples.itemsize={samples.itemsize} samples.nbytes={samples.nbytes} samples.ndim={samples.ndim} samples.shape={samples.shape} samples.strides={samples.strides}')
115 assert samples.itemsize == 1
116 assert samples.nbytes == 659817
117 assert samples.ndim == 1
118 assert samples.shape == (659817,)
119 assert samples.strides == (1,)
120
121 color = pm.pixel( 100, 100)
122 print( f'color={color}')
123 assert color == (83, 66, 40)
124
125def test_samples_ptr():
126 pm = pymupdf.Pixmap(imgfile)

Callers

nothing calls this directly

Calls 1

pixelMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…