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

Method test_substitute

numpy/f2py/tests/test_symbolic.py:276–292  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

274 assert c * c == as_expr((1 + 2j)**2)
275
276 def test_substitute(self):
277 x = as_symbol("x")
278 y = as_symbol("y")
279 z = as_symbol("z")
280 a = as_array((x, y))
281
282 assert x.substitute({x: y}) == y
283 assert (x + y).substitute({x: z}) == y + z
284 assert (x * y).substitute({x: z}) == y * z
285 assert (x**4).substitute({x: z}) == z**4
286 assert (x / y).substitute({x: z}) == z / y
287 assert x.substitute({x: y + z}) == y + z
288 assert a.substitute({x: y + z}) == as_array((y + z, y))
289
290 assert as_ternary(x, y,
291 z).substitute({x: y + z}) == as_ternary(y + z, y, z)
292 assert as_eq(x, y).substitute({x: y + z}) == as_eq(y + z, y)
293
294 def test_fromstring(self):
295

Callers

nothing calls this directly

Calls 5

as_symbolFunction · 0.90
as_arrayFunction · 0.90
as_ternaryFunction · 0.90
as_eqFunction · 0.90
substituteMethod · 0.45

Tested by

no test coverage detected