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

Method test_poly1d_misc

numpy/lib/tests/test_polynomial.py:74–92  ·  view source on GitHub ↗
(self, type_code: str)

Source from the content-addressed store, hash-verified

72
73 @pytest.mark.parametrize("type_code", TYPE_CODES)
74 def test_poly1d_misc(self, type_code: str) -> None:
75 dtype = np.dtype(type_code)
76 ar = np.array([1, 2, 3], dtype=dtype)
77 p = np.poly1d(ar)
78
79 # `__eq__`
80 assert_equal(np.asarray(p), ar)
81 assert_equal(np.asarray(p).dtype, dtype)
82 assert_equal(len(p), 2)
83
84 # `__getitem__`
85 comparison_dct = {-1: 0, 0: 3, 1: 2, 2: 1, 3: 0}
86 for index, ref in comparison_dct.items():
87 scalar = p[index]
88 assert_equal(scalar, ref)
89 if dtype == np.object_:
90 assert isinstance(scalar, int)
91 else:
92 assert_equal(scalar.dtype, dtype)
93
94 def test_poly1d_variable_arg(self):
95 q = np.poly1d([1., 2, 3], variable='y')

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
itemsMethod · 0.80
dtypeMethod · 0.45

Tested by

no test coverage detected