MCPcopy Create free account
hub / github.com/numpy/numpy / test_3d

Method test_3d

numpy/core/tests/test_shape_base.py:672–725  ·  view source on GitHub ↗
(self, block)

Source from the content-addressed store, hash-verified

670 assert_equal(result, expected)
671
672 def test_3d(self, block):
673 a000 = np.ones((2, 2, 2), int) * 1
674
675 a100 = np.ones((3, 2, 2), int) * 2
676 a010 = np.ones((2, 3, 2), int) * 3
677 a001 = np.ones((2, 2, 3), int) * 4
678
679 a011 = np.ones((2, 3, 3), int) * 5
680 a101 = np.ones((3, 2, 3), int) * 6
681 a110 = np.ones((3, 3, 2), int) * 7
682
683 a111 = np.ones((3, 3, 3), int) * 8
684
685 result = block([
686 [
687 [a000, a001],
688 [a010, a011],
689 ],
690 [
691 [a100, a101],
692 [a110, a111],
693 ]
694 ])
695 expected = array([[[1, 1, 4, 4, 4],
696 [1, 1, 4, 4, 4],
697 [3, 3, 5, 5, 5],
698 [3, 3, 5, 5, 5],
699 [3, 3, 5, 5, 5]],
700
701 [[1, 1, 4, 4, 4],
702 [1, 1, 4, 4, 4],
703 [3, 3, 5, 5, 5],
704 [3, 3, 5, 5, 5],
705 [3, 3, 5, 5, 5]],
706
707 [[2, 2, 6, 6, 6],
708 [2, 2, 6, 6, 6],
709 [7, 7, 8, 8, 8],
710 [7, 7, 8, 8, 8],
711 [7, 7, 8, 8, 8]],
712
713 [[2, 2, 6, 6, 6],
714 [2, 2, 6, 6, 6],
715 [7, 7, 8, 8, 8],
716 [7, 7, 8, 8, 8],
717 [7, 7, 8, 8, 8]],
718
719 [[2, 2, 6, 6, 6],
720 [2, 2, 6, 6, 6],
721 [7, 7, 8, 8, 8],
722 [7, 7, 8, 8, 8],
723 [7, 7, 8, 8, 8]]])
724
725 assert_array_equal(result, expected)
726
727 def test_block_with_mismatched_shape(self, block):
728 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