Did I find the right examples for you? yes no

# sympy.categories.CompositeMorphism

All Samples(18)  |  Call(13)  |  Derive(0)  |  Import(5)
```Represents a morphism which is a composition of other morphisms.

Two composite morphisms are equal if the morphisms they were
obtained from (components) are the same and were listed in the
same order.

The arguments to the constructor for this class should be listed
in diagram order: to obtain the composition `g\circ f` from the
instances of :class:`Morphism` ``g`` and ``f`` use
``CompositeMorphism(f, g)``.(more...)
```

```
from sympy.core import Basic, FiniteSet, Dict, Symbol
from sympy.categories import (CompositeMorphism, IdentityMorphism,
NamedMorphism, Diagram)
from sympy.utilities import default_sort_key
```

```
from sympy.core import Basic, FiniteSet, Dict, Symbol
from sympy.categories import (CompositeMorphism, IdentityMorphism,
NamedMorphism, Diagram)
from sympy.utilities import default_sort_key
```

```from sympy.categories import (Object, Morphism, IdentityMorphism,
NamedMorphism, CompositeMorphism,
Diagram, Category)
from sympy.categories.baseclasses import Class
from sympy.utilities.pytest import XFAIL, raises
```
```
# Test composite morphisms.
assert f == CompositeMorphism(f)

k = g.compose(f)
assert k.domain == A
assert k.codomain == C
assert k.components == Tuple(f, g)
assert g * f == k
assert CompositeMorphism(f, g) == k
```
```    assert CompositeMorphism(f, g) == k

assert CompositeMorphism(g * f) == g * f

# Test the associativity of composition.
```
```    assert h * k == u
assert p * f == u
assert CompositeMorphism(f, g, h) == u

# Test flattening.
```

```from sympy.categories import (Object, Morphism, IdentityMorphism,
NamedMorphism, CompositeMorphism,
Diagram, Category)
from sympy.categories.baseclasses import Class
from sympy.utilities.pytest import XFAIL, raises
```
```
# Test composite morphisms.
assert f == CompositeMorphism(f)

k = g.compose(f)
assert k.domain == A
assert k.codomain == C
assert k.components == Tuple(f, g)
assert g * f == k
assert CompositeMorphism(f, g) == k
```
```    assert CompositeMorphism(f, g) == k

assert CompositeMorphism(g * f) == g * f

# Test the associativity of composition.
```
```    assert h * k == u
assert p * f == u
assert CompositeMorphism(f, g, h) == u

# Test flattening.
```

```def test_sympy__categories__baseclasses__CompositeMorphism():