def __init__(self, parent, on_gens, cartan_type=None,
                 virtualization=None, scaling_factors=None,
                 gens=None, check=True):
        """
        Construct a crystal morphism.

        TESTS::

            sage: B = crystals.infinity.Tableaux(['B',2])
            sage: C = crystals.infinity.NakajimaMonomials(['B',2])
            sage: psi = B.crystal_morphism(C.module_generators)

            sage: B = crystals.Tableaux(['B',3], shape=[1])
            sage: C = crystals.Tableaux(['D',4], shape=[2])
            sage: H = Hom(B, C)
            sage: psi = H(C.module_generators)
        """
        if cartan_type is None:
            cartan_type = parent.domain().cartan_type()
        if isinstance(on_gens, dict):
            gens = on_gens.keys()
        I = cartan_type.index_set()
        if gens is None:
            if cartan_type == parent.domain().cartan_type():
                gens = parent.domain().highest_weight_vectors()
            else:
                gens = tuple(x for x in parent.domain() if x.is_highest_weight(I))
            self._hw_gens = True
        elif check:
            self._hw_gens = all(x.is_highest_weight(I) for x in gens)
        else:
            self._hw_gens = False
        CrystalMorphismByGenerators.__init__(self, parent, on_gens, cartan_type,
                                             virtualization, scaling_factors,
                                             gens, check)
    def __init__(self, parent, on_gens, cartan_type=None,
                 virtualization=None, scaling_factors=None,
                 gens=None, check=True):
        """
        Construct a crystal morphism.

        TESTS::

            sage: B = crystals.infinity.Tableaux(['B',2])
            sage: C = crystals.infinity.NakajimaMonomials(['B',2])
            sage: psi = B.crystal_morphism(C.module_generators)

            sage: B = crystals.Tableaux(['B',3], shape=[1])
            sage: C = crystals.Tableaux(['D',4], shape=[2])
            sage: H = Hom(B, C)
            sage: psi = H(C.module_generators)
        """
        if cartan_type is None:
            cartan_type = parent.domain().cartan_type()
        if isinstance(on_gens, dict):
            gens = on_gens.keys()
        I = cartan_type.index_set()
        if gens is None:
            if cartan_type == parent.domain().cartan_type():
                gens = parent.domain().highest_weight_vectors()
            else:
                gens = tuple(x for x in parent.domain() if x.is_highest_weight(I))
            self._hw_gens = True
        elif check:
            self._hw_gens = all(x.is_highest_weight(I) for x in gens)
        else:
            self._hw_gens = False
        CrystalMorphismByGenerators.__init__(self, parent, on_gens, cartan_type,
                                             virtualization, scaling_factors,
                                             gens, check)