|
19 | 19 |
|
20 | 20 |
|
21 | 21 | class CPUProcessorTest(unittest.TestCase): |
22 | | - FLOAT_DELTA = 1e+5 |
| 22 | + FLOAT_DELTA = 1e-5 |
23 | 23 | UINT_DELTA = 1 |
24 | 24 |
|
25 | 25 | @classmethod |
@@ -385,6 +385,28 @@ def test_apply_rgb_list(self): |
385 | 385 | delta=self.FLOAT_DELTA |
386 | 386 | ) |
387 | 387 |
|
| 388 | + def test_apply_rgb_buffer_column_major(self): |
| 389 | + if not np: |
| 390 | + logger.warning("NumPy not found. Skipping test!") |
| 391 | + return |
| 392 | + |
| 393 | + for arr, cpu_proc_fwd in [ |
| 394 | + (self.float_rgb_2d, self.default_cpu_proc_fwd), |
| 395 | + (self.float_rgb_3d, self.default_cpu_proc_fwd), |
| 396 | + (self.half_rgb_2d, self.half_cpu_proc_fwd), |
| 397 | + (self.half_rgb_3d, self.half_cpu_proc_fwd), |
| 398 | + (self.uint16_rgb_2d, self.uint16_cpu_proc_fwd), |
| 399 | + (self.uint16_rgb_3d, self.uint16_cpu_proc_fwd), |
| 400 | + (self.uint8_rgb_2d, self.uint8_cpu_proc_fwd), |
| 401 | + (self.uint8_rgb_3d, self.uint8_cpu_proc_fwd), |
| 402 | + ]: |
| 403 | + # Transpose to F-order (column-major) |
| 404 | + arr_copy = arr.copy().T |
| 405 | + |
| 406 | + # Expect runtime error for non-C-contiguous array |
| 407 | + with self.assertRaises(RuntimeError): |
| 408 | + cpu_proc_fwd.applyRGB(arr_copy) |
| 409 | + |
388 | 410 | def test_apply_rgb_buffer(self): |
389 | 411 | if not np: |
390 | 412 | logger.warning("NumPy not found. Skipping test!") |
@@ -627,3 +649,48 @@ def test_apply_rgba_buffer(self): |
627 | 649 | arr.flat[i], |
628 | 650 | delta=self.UINT_DELTA |
629 | 651 | ) |
| 652 | + |
| 653 | + def test_apply_rgba_buffer_column_major(self): |
| 654 | + if not np: |
| 655 | + logger.warning("NumPy not found. Skipping test!") |
| 656 | + return |
| 657 | + |
| 658 | + for arr, cpu_proc_fwd in [ |
| 659 | + ( |
| 660 | + self.float_rgba_2d, |
| 661 | + self.default_cpu_proc_fwd |
| 662 | + ), |
| 663 | + ( |
| 664 | + self.float_rgba_3d, |
| 665 | + self.default_cpu_proc_fwd |
| 666 | + ), |
| 667 | + ( |
| 668 | + self.half_rgba_2d, |
| 669 | + self.half_cpu_proc_fwd |
| 670 | + ), |
| 671 | + ( |
| 672 | + self.half_rgba_3d, |
| 673 | + self.half_cpu_proc_fwd |
| 674 | + ), |
| 675 | + ( |
| 676 | + self.uint16_rgba_2d, |
| 677 | + self.uint16_cpu_proc_fwd |
| 678 | + ), |
| 679 | + ( |
| 680 | + self.uint16_rgba_3d, |
| 681 | + self.uint16_cpu_proc_fwd |
| 682 | + ), |
| 683 | + ( |
| 684 | + self.uint8_rgba_2d, |
| 685 | + self.uint8_cpu_proc_fwd |
| 686 | + ), |
| 687 | + ( |
| 688 | + self.uint8_rgba_3d, |
| 689 | + self.uint8_cpu_proc_fwd, |
| 690 | + ), |
| 691 | + ]: |
| 692 | + # Transpose to F-order (column-major) |
| 693 | + arr_copy = arr.copy().T |
| 694 | + # Expect runtime error for non-C-contiguous array |
| 695 | + with self.assertRaises(RuntimeError): |
| 696 | + cpu_proc_fwd.applyRGBA(arr_copy) |
0 commit comments