MCPcopy Create free account
hub / github.com/vispy/vispy / downsample

Function downsample

vispy/testing/image_tester.py:291–314  ·  view source on GitHub ↗

Downsample by averaging points together across axis. If multiple axes are specified, runs once per axis.

(data, n, axis=0)

Source from the content-addressed store, hash-verified

289
290
291def downsample(data, n, axis=0):
292 """Downsample by averaging points together across axis.
293 If multiple axes are specified, runs once per axis.
294 """
295 if hasattr(axis, '__len__'):
296 if not hasattr(n, '__len__'):
297 n = [n]*len(axis)
298 for i in range(len(axis)):
299 data = downsample(data, n[i], axis[i])
300 return data
301
302 if n <= 1:
303 return data
304 nPts = int(data.shape[axis] / n)
305 s = list(data.shape)
306 s[axis] = nPts
307 s.insert(axis+1, n)
308 sl = [slice(None)] * data.ndim
309 sl[axis] = slice(0, nPts*n)
310 d1 = data[tuple(sl)]
311 d1.shape = tuple(s)
312 d2 = d1.mean(axis+1)
313
314 return d2
315
316
317class ImageTester(scene.SceneCanvas):

Callers 4

test_image_complexFunction · 0.90
assert_image_approvedFunction · 0.85

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…