Debian Codegraph @

hypothesis-python/tests/ghostwriter/recorded/matmul_magic.txt

raw
1 # This test code was written by the `hypothesis.extra.ghostwriter` module
2 # and is provided under the Creative Commons Zero public domain dedication.
3
4 import operator
5 from hypothesis import given, strategies as st
6
7 # TODO: replace st.nothing() with an appropriate strategy
8
9 matmul_operands = st.nothing()
10
11
12 @given(a=matmul_operands, b=matmul_operands, c=matmul_operands)
13 def test_associative_binary_operation_matmul(a, b, c):
14 left = operator.matmul(a, operator.matmul(b, c))
15 right = operator.matmul(operator.matmul(a, b), c)
16 assert left == right, (left, right)
17
18
19 @given(a=matmul_operands)
20 def test_identity_binary_operation_matmul(a):
21 identity = "identity element here"
22 assert a == operator.matmul(a, identity)
23 assert a == operator.matmul(identity, a)
24
25
26 @given(a=matmul_operands, b=matmul_operands, c=matmul_operands)
27 def test_add_distributes_over_binary_operation_matmul(a, b, c):
28 left = operator.matmul(a, operator.add(b, c))
29 ldist = operator.add(operator.matmul(a, b), operator.matmul(a, c))
30 assert ldist == left, (ldist, left)
31
32 right = operator.matmul(operator.add(a, b), c)
33 rdist = operator.add(operator.matmul(a, c), operator.matmul(b, c))
34 assert rdist == right, (rdist, right)