MCPcopy Index your code
hub / github.com/numpy/numpy / test_two_values

Method test_two_values

numpy/lib/tests/test_arraypad.py:45–68  ·  view source on GitHub ↗

Test proper casting for two different values.

(self)

Source from the content-addressed store, hash-verified

43 )
44
45 def test_two_values(self):
46 """Test proper casting for two different values."""
47 # Broadcasting in the first dimension with numbers
48 expected = np.array([[3, 4]] * 10)
49 for x in ([3, 4], [[3, 4]]):
50 result = _as_pairs(x, 10)
51 assert_equal(result, expected)
52 # and with dtype=object
53 obj = object()
54 assert_equal(
55 _as_pairs(["a", obj], 10),
56 np.array([["a", obj]] * 10)
57 )
58
59 # Broadcasting in the second / last dimension with numbers
60 assert_equal(
61 _as_pairs([[3], [4]], 2),
62 np.array([[3, 3], [4, 4]])
63 )
64 # and with dtype=object
65 assert_equal(
66 _as_pairs([["a"], [obj]], 2),
67 np.array([["a", "a"], [obj, obj]])
68 )
69
70 def test_with_none(self):
71 expected = ((None, None), (None, None), (None, None))

Callers

nothing calls this directly

Calls 2

_as_pairsFunction · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected