MCPcopy
hub / github.com/numpy/numpy / test_3d

Method test_3d

numpy/_core/tests/test_shape_base.py:745–798  ·  view source on GitHub ↗
(self, block)

Source from the content-addressed store, hash-verified

743 assert_equal(result, expected)
744
745 def test_3d(self, block):
746 a000 = np.ones((2, 2, 2), int) * 1
747
748 a100 = np.ones((3, 2, 2), int) * 2
749 a010 = np.ones((2, 3, 2), int) * 3
750 a001 = np.ones((2, 2, 3), int) * 4
751
752 a011 = np.ones((2, 3, 3), int) * 5
753 a101 = np.ones((3, 2, 3), int) * 6
754 a110 = np.ones((3, 3, 2), int) * 7
755
756 a111 = np.ones((3, 3, 3), int) * 8
757
758 result = block([
759 [
760 [a000, a001],
761 [a010, a011],
762 ],
763 [
764 [a100, a101],
765 [a110, a111],
766 ]
767 ])
768 expected = array([[[1, 1, 4, 4, 4],
769 [1, 1, 4, 4, 4],
770 [3, 3, 5, 5, 5],
771 [3, 3, 5, 5, 5],
772 [3, 3, 5, 5, 5]],
773
774 [[1, 1, 4, 4, 4],
775 [1, 1, 4, 4, 4],
776 [3, 3, 5, 5, 5],
777 [3, 3, 5, 5, 5],
778 [3, 3, 5, 5, 5]],
779
780 [[2, 2, 6, 6, 6],
781 [2, 2, 6, 6, 6],
782 [7, 7, 8, 8, 8],
783 [7, 7, 8, 8, 8],
784 [7, 7, 8, 8, 8]],
785
786 [[2, 2, 6, 6, 6],
787 [2, 2, 6, 6, 6],
788 [7, 7, 8, 8, 8],
789 [7, 7, 8, 8, 8],
790 [7, 7, 8, 8, 8]],
791
792 [[2, 2, 6, 6, 6],
793 [2, 2, 6, 6, 6],
794 [7, 7, 8, 8, 8],
795 [7, 7, 8, 8, 8],
796 [7, 7, 8, 8, 8]]])
797
798 assert_array_equal(result, expected)
799
800 def test_block_with_mismatched_shape(self, block):
801 a = np.array([0, 0])

Callers

nothing calls this directly

Calls 3

blockFunction · 0.90
arrayFunction · 0.90
assert_array_equalFunction · 0.90

Tested by

no test coverage detected