Skip to content

Improve PreImages error message if object is not in range #1004

@fingolfin

Description

@fingolfin

Consider this example (originally due to @laurentbartholdi, see also http://tracker.gap-system.org/issues/391):

gap> g := SymmetricGroup(3);;
gap> f := GroupHomomorphismByImages(Group((1,2)),Group((2,3)),[(1,2)],[(2,3)]);
[ (1,2) ] -> [ (2,3) ]
gap> PreImages(f,Group((2,3)));
Group([ (1,2) ])
gap> PreImages(f,Group((2,4)));
Error, usage: PreImages(<map>), PreImages(<map>,<img>), PreImages(<map>,<coll>)

The error message is not very helpful. It would be much more helpful if we said something like "the set/object/list you provided is not contained in the range of the map" or so.

Without thinking too much about it, couldn't we achieve this by modifying e.g. the test

        if     FamRangeEqFamElm( FamilyObj( map ), FamilyObj( img ) )
           and img in Range( map ) then

            return PreImagesElm( map, img );

to this:

        if FamRangeEqFamElm( FamilyObj( map ), FamilyObj( img ) ) then
           if not img in Range( map ) then
             Error("the provided element is not contained in the range of the map"):
           fi;
           return PreImagesElm( map, img );

and so on?

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: enhancementLabel for issues suggesting enhancements; and for pull requests implementing enhancements

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions