Skip to content

Commit

Permalink
Merge pull request #1401 from zickgraf/master
Browse files Browse the repository at this point in the history
Simplify AttributeCategory
  • Loading branch information
zickgraf authored Jul 31, 2023
2 parents f564ae0 + a184115 commit a5c4bb7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion AttributeCategoryForCAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "AttributeCategoryForCAP",
Subtitle := "Automatic enhancement with attributes of a CAP category",
Version := "2023.05-01",
Version := "2023.07-01",
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
License := "GPL-2.0-or-later",

Expand Down
67 changes: 31 additions & 36 deletions AttributeCategoryForCAP/gap/AttributeCategory.gi
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,24 @@ InstallGlobalFunction( CAP_INTERNAL_INSTALL_ADDS_FOR_CATEGORY_WITH_ATTRIBUTES,

create_function_morphism_no_new_object :=
function( operation_name )
local operation, type;
local operation, output_source_getter, output_range_getter;

operation := ValueGlobal( operation_name );

type := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).io_type;
output_source_getter := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).output_source_getter;
output_range_getter := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).output_range_getter;

return
function( arg )
local underlying_arg, underlying_return, source_range_pair, source, range;
local underlying_arg, underlying_return, source, range;

underlying_arg:= List( arg, UnderlyingCell );

underlying_return := CallFuncList( operation, underlying_arg );

source_range_pair := CAP_INTERNAL_GET_CORRESPONDING_OUTPUT_OBJECTS( type, arg );
source := CallFuncList( output_source_getter, Concatenation( [ category_with_attributes ], arg ) );

source := source_range_pair[1];

range := source_range_pair[2];
range := CallFuncList( output_range_getter, Concatenation( [ category_with_attributes ], arg ) );

return CallFuncList( morphism_constructor, [ source, underlying_return, range ] );

Expand All @@ -228,15 +227,16 @@ InstallGlobalFunction( CAP_INTERNAL_INSTALL_ADDS_FOR_CATEGORY_WITH_ATTRIBUTES,
## assumes that no new object is created
create_function_morphism_or_fail :=
function( operation_name )
local operation, type;
local operation, output_source_getter, output_range_getter;

operation := ValueGlobal( operation_name );

type := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).io_type;
output_source_getter := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).output_source_getter;
output_range_getter := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).output_range_getter;

return
function( arg )
local underlying_arg, underlying_return, source_range_pair, source, range;
local underlying_arg, underlying_return, source, range;

underlying_arg:= List( arg, UnderlyingCell );

Expand All @@ -248,11 +248,9 @@ InstallGlobalFunction( CAP_INTERNAL_INSTALL_ADDS_FOR_CATEGORY_WITH_ATTRIBUTES,

fi;

source_range_pair := CAP_INTERNAL_GET_CORRESPONDING_OUTPUT_OBJECTS( type, arg );

source := source_range_pair[1];
source := CallFuncList( output_source_getter, Concatenation( [ category_with_attributes ], arg ) );

range := source_range_pair[2];
range := CallFuncList( output_range_getter, Concatenation( [ category_with_attributes ], arg ) );

return CallFuncList( morphism_constructor, [ source, underlying_return, range ] );

Expand All @@ -262,23 +260,21 @@ InstallGlobalFunction( CAP_INTERNAL_INSTALL_ADDS_FOR_CATEGORY_WITH_ATTRIBUTES,

create_function_morphism_new_source :=
function( operation_name, attributes_function )
local operation, type;
local operation, output_range_getter;

operation := ValueGlobal( operation_name );

type := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).io_type;
output_range_getter := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).output_range_getter;

return
function( arg )
local underlying_arg, underlying_return, source_range_pair, source, range;
local underlying_arg, underlying_return, range, attributes, source;

underlying_arg:= List( arg, UnderlyingCell );

underlying_return := CallFuncList( operation, underlying_arg );

source_range_pair := CAP_INTERNAL_GET_CORRESPONDING_OUTPUT_OBJECTS( type, arg );

range := source_range_pair[2];
range := CallFuncList( output_range_getter, Concatenation( [ category_with_attributes ], arg ) );

attributes := CallFuncList( attributes_function, Concatenation( arg, [ Source( underlying_return ) ] ) );

Expand All @@ -292,23 +288,21 @@ InstallGlobalFunction( CAP_INTERNAL_INSTALL_ADDS_FOR_CATEGORY_WITH_ATTRIBUTES,

create_function_morphism_new_range :=
function( operation_name, attributes_function )
local operation, type;
local operation, output_source_getter;

operation := ValueGlobal( operation_name );

type := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).io_type;
output_source_getter := CAP_INTERNAL_METHOD_NAME_RECORD.(operation_name).output_source_getter;

return
function( arg )
local underlying_arg, underlying_return, source_range_pair, source, range;
local underlying_arg, underlying_return, source, attributes, range;

underlying_arg:= List( arg, UnderlyingCell );

underlying_return := CallFuncList( operation, underlying_arg );

source_range_pair := CAP_INTERNAL_GET_CORRESPONDING_OUTPUT_OBJECTS( type, arg );

source := source_range_pair[1];
source := CallFuncList( output_source_getter, Concatenation( [ category_with_attributes ], arg ) );

attributes := CallFuncList( attributes_function, Concatenation( arg, [ Range( underlying_return ) ] ) );

Expand All @@ -332,7 +326,15 @@ InstallGlobalFunction( CAP_INTERNAL_INSTALL_ADDS_FOR_CATEGORY_WITH_ATTRIBUTES,
"IsEqualForMorphisms",
"IsCongruentForMorphisms",
"IsEqualForCacheForObjects",
"IsEqualForCacheForMorphisms"
"IsEqualForCacheForMorphisms",
# homomorphism structure
"DistinguishedObjectOfHomomorphismStructure",
"HomomorphismStructureOnObjects",
"HomomorphismStructureOnMorphisms",
"HomomorphismStructureOnMorphismsWithGivenObjects",
"InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure",
"InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructureWithGivenObjects",
"InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism",
];

if IsBound( structure_record.NoInstallList ) then
Expand Down Expand Up @@ -444,15 +446,8 @@ InstallGlobalFunction( CAP_INTERNAL_INSTALL_ADDS_FOR_CATEGORY_WITH_ATTRIBUTES,

elif entry.return_type = "morphism" then

if not IsBound( entry.io_type ) then

## if there is no io_type we cannot do anything
continue;

fi;

if IsBound( entry.output_source_getter_string ) and entry.can_always_compute_output_source_getter and
IsBound( entry.output_range_getter_string ) and entry.can_always_compute_output_range_getter then
if IsBound( entry.output_source_getter ) and entry.can_always_compute_output_source_getter and
IsBound( entry.output_range_getter ) and entry.can_always_compute_output_range_getter then

function_to_add := create_function_morphism_no_new_object( name );

Expand Down

0 comments on commit a5c4bb7

Please sign in to comment.