# Buggy code
def subdiagram_from_objects(self, objects):
    """
    If ``objects`` is a subset of the objects of ``self``, returns
    a diagram which has as premises all those premises of ``self``
    which have a domains and codomains in ``objects``, likewise
    for conclusions.  Properties are preserved.

    Examples
    ========

    >>> from sympy.categories import Object, NamedMorphism, Diagram
    >>> from sympy import FiniteSet
    >>> A = Object("A")
    >>> B = Object("B")
    >>> C = Object("C")
    >>> f = NamedMorphism(A, B, "f")
    >>> g = NamedMorphism(B, C, "g")
    >>> d = Diagram([f, g], {f: "unique", g*f: "veryunique"})
    >>> d1 = d.subdiagram_from_objects(FiniteSet(A, B))
    >>> d1 == Diagram([f], {f: "unique"})
    True
    """
    if not objects.is_subset(self.objects):
        raise ValueError("Supplied objects should all belong to the diagram.")

    new_premises = {}
    for morphism, props in self.premises.items():
        if (morphism.domain in objects) and (morphism.codomain in objects):
            new_premises[morphism] = props

    new_conclusions = {}
    for morphism, props in self.conclusions.items():
        if (morphism.domain in objects) and (morphism.codomain in objects):
            new_conclusions[morphism] = props

    return Diagram(new_premises, new_conclusions)


# Traceback (TypeError)
In [5]: b in FiniteSet(-a)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-66c50e010c80> in <module>()
----> 1 b in FiniteSet(-a)

/home/hargup/210fs/sympy/sympy/sets/sets.py in __contains__(self, other)
495         symb = self.contains(other)
496         if symb not in (true, false):
--> 497             raise TypeError('contains did not evaluate to a bool: %r' % symb)
498         return bool(symb)
499

TypeError: contains did not evaluate to a bool: Contains(b, {-a})

# Fixed code
def subdiagram_from_objects(self, objects):
    """
    If ``objects`` is a subset of the objects of ``self``, returns
    a diagram which has as premises all those premises of ``self``
    which have a domains and codomains in ``objects``, likewise
    for conclusions.  Properties are preserved.

    Examples
    ========

    >>> from sympy.categories import Object, NamedMorphism, Diagram
    >>> from sympy import FiniteSet
    >>> A = Object("A")
    >>> B = Object("B")
    >>> C = Object("C")
    >>> f = NamedMorphism(A, B, "f")
    >>> g = NamedMorphism(B, C, "g")
    >>> d = Diagram([f, g], {f: "unique", g*f: "veryunique"})
    >>> d1 = d.subdiagram_from_objects(FiniteSet(A, B))
    >>> d1 == Diagram([f], {f: "unique"})
    True
    """
    if not objects.is_subset(self.objects):
        raise ValueError("Supplied objects should all belong to the diagram.")

    new_premises = {}
    for morphism, props in self.premises.items():
        if (objects.contains(morphism.domain) == S.true) and (
            objects.contains(morphism.codomain) == S.true
        ):
            new_premises[morphism] = props

    new_conclusions = {}
    for morphism, props in self.conclusions.items():
        if (objects.contains(morphism.domain) == S.true) and (
            objects.contains(morphism.codomain) == S.true
        ):
            new_conclusions[morphism] = props

    return Diagram(new_premises, new_conclusions)