MCPcopy
hub / github.com/numpy/numpy / test_shape_scalar

Method test_shape_scalar

numpy/ma/tests/test_extras.py:1773–1813  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1771 assert_equal(b.mask.shape, b.data.shape)
1772
1773 def test_shape_scalar(self):
1774 # the atleast and diagflat function should work with scalars
1775 # GitHub issue #3367
1776 # Additionally, the atleast functions should accept multiple scalars
1777 # correctly
1778 b = atleast_1d(1.0)
1779 assert_equal(b.shape, (1,))
1780 assert_equal(b.mask.shape, b.shape)
1781 assert_equal(b.data.shape, b.shape)
1782
1783 b = atleast_1d(1.0, 2.0)
1784 for a in b:
1785 assert_equal(a.shape, (1,))
1786 assert_equal(a.mask.shape, a.shape)
1787 assert_equal(a.data.shape, a.shape)
1788
1789 b = atleast_2d(1.0)
1790 assert_equal(b.shape, (1, 1))
1791 assert_equal(b.mask.shape, b.shape)
1792 assert_equal(b.data.shape, b.shape)
1793
1794 b = atleast_2d(1.0, 2.0)
1795 for a in b:
1796 assert_equal(a.shape, (1, 1))
1797 assert_equal(a.mask.shape, a.shape)
1798 assert_equal(a.data.shape, a.shape)
1799
1800 b = atleast_3d(1.0)
1801 assert_equal(b.shape, (1, 1, 1))
1802 assert_equal(b.mask.shape, b.shape)
1803 assert_equal(b.data.shape, b.shape)
1804
1805 b = atleast_3d(1.0, 2.0)
1806 for a in b:
1807 assert_equal(a.shape, (1, 1, 1))
1808 assert_equal(a.mask.shape, a.shape)
1809 assert_equal(a.data.shape, a.shape)
1810
1811 b = diagflat(1.0)
1812 assert_equal(b.shape, (1, 1))
1813 assert_equal(b.mask.shape, b.data.shape)
1814
1815 @pytest.mark.parametrize("fn", [atleast_1d, vstack, diagflat])
1816 def test_inspect_signature(self, fn):

Callers

nothing calls this directly

Calls 5

assert_equalFunction · 0.90
atleast_1dFunction · 0.85
atleast_2dFunction · 0.85
atleast_3dFunction · 0.85
diagflatFunction · 0.85

Tested by

no test coverage detected