This commit is contained in:
wittmannzl103469 committed 2026-11-05 15:08:42 +01:00
1 parent de41a02749
commit 9af09cebd3
764 files changed
+54218 -78859

No files matched your search

@@ -1,8 +1,9 @@
import unittest
from numpy import int8, int16, uint8, uint16, float32, array, all as alltrue
import pygame
import pygame.sndarray
from numpy import all as np_all, array, float32, int8, int16, uint8, uint16
class SndarrayTest(unittest.TestCase):
@@ -27,7 +28,7 @@ class SndarrayTest(unittest.TestCase):
arr = pygame.sndarray.array(snd)
self._assert_compatible(arr, size)
self.assertTrue(
np_all(arr == srcarr),
alltrue(arr == srcarr),
"size: %i\n%s\n%s" % (size, arr, test_data),
)
finally:
@@ -40,7 +41,7 @@ class SndarrayTest(unittest.TestCase):
16, 2, [[0, 0xFFFF], [0xFFFF, 0], [0x00FF, 0xFF00], [0x0F0F, 0xF0F0]]
)
check_array(-8, 1, [0, -0x80, 0x7F, 0x64])
check_array(-8, 2, [[0, -0x80], [-0x64, 0x64], [0x25, -0x50], [0x7F, 0]])
check_array(-8, 2, [[0, -0x80], [-0x64, 0x64], [0x25, -0x50], [-1, 0]])
check_array(-16, 1, [0, 0x7FFF, -0x7FFF, -1])
check_array(-16, 2, [[0, -0x7FFF], [-0x7FFF, 0], [0x7FFF, 0], [0, 0x7FFF]])
@@ -70,20 +71,20 @@ class SndarrayTest(unittest.TestCase):
snd = pygame.sndarray.make_sound(srcarr)
arr = pygame.sndarray.samples(snd)
self.assertTrue(
np_all(arr == srcarr),
alltrue(arr == srcarr),
"size: %i\n%s\n%s" % (size, arr, test_data),
)
finally:
pygame.mixer.quit()
check_sound(8, 1, [0, 0x0F, 0xF0, 0xFF])
check_sound(8, 2, [[0, 0x80], [0x2D, 0x41], [0x64, 0xA1], [0xFF, 0x40]])
check_sound(8, 2, [[0, 0x80], [0x2D, 0x41], [0x64, 0xA1], [125, 0x40]])
check_sound(16, 1, [0, 0x00FF, 0xFF00, 0xFFFF])
check_sound(
16, 2, [[0, 0xFFFF], [0xFFFF, 0], [0x00FF, 0xFF00], [0x0F0F, 0xF0F0]]
)
check_sound(-8, 1, [0, -0x80, 0x7F, 0x64])
check_sound(-8, 2, [[0, -0x80], [-0x64, 0x64], [0x25, -0x50], [0x7F, 0]])
check_sound(-8, 2, [[0, -0x80], [-0x64, 0x64], [0x25, -0x50], [-1, 0]])
check_sound(-16, 1, [0, 0x7FFF, -0x7FFF, -1])
check_sound(-16, 2, [[0, -0x7FFF], [-0x7FFF, 0], [0x7FFF, 0], [0, 0x7FFF]])
check_sound(32, 2, [[0.0, -1.0], [-1.0, 0], [1.0, 0], [0, 1.0]])
@@ -109,7 +110,7 @@ class SndarrayTest(unittest.TestCase):
samples[...] = test_data
arr = pygame.sndarray.array(snd)
self.assertTrue(
np_all(samples == arr),
alltrue(samples == arr),
"size: %i\n%s\n%s" % (size, arr, test_data),
)
finally:
@@ -122,7 +123,7 @@ class SndarrayTest(unittest.TestCase):
16, 2, [[0, 0xFFFF], [0xFFFF, 0], [0x00FF, 0xFF00], [0x0F0F, 0xF0F0]]
)
check_sample(-8, 1, [0, -0x80, 0x7F, 0x64])
check_sample(-8, 2, [[0, -0x80], [-0x64, 0x64], [0x25, -0x50], [0x7F, 0]])
check_sample(-8, 2, [[0, -0x80], [-0x64, 0x64], [0x25, -0x50], [-1, 0]])
check_sample(-16, 1, [0, 0x7FFF, -0x7FFF, -1])
check_sample(-16, 2, [[0, -0x7FFF], [-0x7FFF, 0], [0x7FFF, 0], [0, 0x7FFF]])
check_sample(32, 2, [[0.0, -1.0], [-1.0, 0], [1.0, 0], [0, 1.0]])