Skip to content

Reindent lib/local.gi and lib/lib_local.gi for readability#29

Merged
olexandr-konovalov merged 2 commits intomasterfrom
mh/indentation
May 1, 2026
Merged

Reindent lib/local.gi and lib/lib_local.gi for readability#29
olexandr-konovalov merged 2 commits intomasterfrom
mh/indentation

Conversation

@fingolfin
Copy link
Copy Markdown
Member

The code in lib/lib_local.gi has no indentation and as a result is rather hard to read. The code in lib/local.gi is a bit better, but in the end also has problems.

So I've asked codex to reformat the code (only whitespace changes), and it did a decent job. (You can ask GitHub to "ignore whitespace changes" in the "Files" view if you'd like to verify it really only changed formatting)

Keep the contents unchanged apart from whitespace and line breaks.

Co-authored-by: Codex <codex@openai.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 96.63158% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.81%. Comparing base (c6a04d2) to head (e578596).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
lib/local.gi 96.30% 10 Missing ⚠️
lib/lib_local.gi 97.05% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #29      +/-   ##
==========================================
- Coverage   99.85%   97.81%   -2.05%     
==========================================
  Files           5        5              
  Lines         709      733      +24     
==========================================
+ Hits          708      717       +9     
- Misses          1       16      +15     
Files with missing lines Coverage Δ
lib/lib_local.gi 97.15% <97.05%> (-2.85%) ⬇️
lib/local.gi 97.05% <96.30%> (-2.64%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread lib/local.gi
Comment on lines +12 to +16
if ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) ) then
return true;
else
return false;
fi;
return ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) );

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is doing purely whitespace changes. I filed #32 recommending code changes like the one you suggest here -- but I really don't want to mix this with the code formatting, and I'd prefer if the package authors did these themselves :-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Just to be clear: I do agree with all changes suggested by James)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One final remark: should the authors wish to, of course they can apply all these change suggestions here and merge the result, that's totally cool for me; I just want to be the one to do that, nor do I want to deal with any fallout from e.g. typos that crept in from the changes. ;-)

Oh and @james-d-mitchell perhaps also change the x -> IsAbelian( x ) to just IsAbelian?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fair enough, I just noticed them, and thought I'd point them out, probably not the right place to do it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it seems like this PR without further suggested changes should be merged ASAP, and then the authors should work on further code changes, and can revisit all comments in this PR by @james-d-mitchell and @fingolfin and implement them themselves? Or can they commit James' suggestions and then merge the PR keeping several commits?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my advice to minimize work: since a bunch of good change suggestions were left here, it would be a waste to try to replicate them manually. Instead, I suggest to just use the "Add to batch" feature on all of them (or all that you agree with -- though honestly, I don't see any where I can think of a reason not to apply 'em), and commit the result. This will add a second commit to this PR. Then, assuming CI passes, merge it all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. @raemarina @IrynaRaievska let's do this tomorrow, to pave the way to the further code refactoring.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to also mention that gaplint will point out issues like this, making them easier to discover

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will revisit this suggestion later separately

Comment thread lib/local.gi
Comment on lines +94 to +98
if Size( h ) > 0 then
return true;
else
return false;
fi;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if Size( h ) > 0 then
return true;
else
return false;
fi;
return Size( h ) > 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub says "Unable to apply suggestions on deleted lines." - we will do this later separately

Comment thread lib/local.gi
Comment on lines +141 to +145
if IsSubset( U, V ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if IsSubset( U, V ) then
return true;
else
return false;
fi;
return IsSubset( U, V );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +160 to +164
if IsAdditiveGroupHomomorphism( map ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if IsAdditiveGroupHomomorphism( map ) then
return true;
else
return false;
fi;
return IsAdditiveGroupHomomorphism( map );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +184 to +190
if IsAbelian( G ) and IsLocalNearRing( R ) and
ForAll( elm, y -> IsDistributiveElementOfNearRing( R, y ) )
then
return true;
else
return false;
fi;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if IsAbelian( G ) and IsLocalNearRing( R ) and
ForAll( elm, y -> IsDistributiveElementOfNearRing( R, y ) )
then
return true;
else
return false;
fi;
return IsAbelian( G ) and IsLocalNearRing( R ) and
ForAll( elm, y -> IsDistributiveElementOfNearRing( R, y ) );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +354 to +358
if Size( U ) < Size( R ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if Size( U ) < Size( R ) then
return true;
else
return false;
fi;
return Size( U ) < Size( R );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +458 to +462
if IsSubset( Un, F ) and Size( Unique( ListX( F, F, \* ) ) ) = Size( F ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if IsSubset( Un, F ) and Size( Unique( ListX( F, F, \* ) ) ) = Size( F ) then
return true;
else
return false;
fi;
return IsSubset( Un, F ) and Size( Unique( ListX( F, F, \* ) ) ) = Size( F );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +571 to +574
if Size( H ) = Size( S ) then
return true;
fi;
return false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if Size( H ) = Size( S ) then
return true;
fi;
return false;
return Size( H ) = Size( S );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/lib_local.gi Outdated
d := GroupHomomorphismByImagesNC( G, G, gr, x );
Add( hom, d );
od;
f := function( x, y ) return x * y; end;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functions seems to be unused and could be removed in a follow-up PR (also f from the list of variables) .

Comment thread lib/lib_local.gi Outdated
Comment thread lib/lib_local.gi
Comment on lines +44 to +53
constructor := function( z ) return function( u ) return function( x, y ) return u^( PreImage( z, y ) * PreImage( z, x ) ); end; end; end;
B := Filtered( hom, x -> IsInjective( x ) );
A := GroupByGenerators( B );
k1 := Position( OrbitLengths( A, G ), Size( A ) );
Or := OrbitsDomain( A, G )[k1];
a := Or[1];
g := const( a );
Em := MagmaWithOne( hom );
ma := MappingByFunction( Em, G, g );
mul := constructor( ma )( a );
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constructor := function( z ) return function( u ) return function( x, y ) return u^( PreImage( z, y ) * PreImage( z, x ) ); end; end; end;
B := Filtered( hom, x -> IsInjective( x ) );
A := GroupByGenerators( B );
k1 := Position( OrbitLengths( A, G ), Size( A ) );
Or := OrbitsDomain( A, G )[k1];
a := Or[1];
g := const( a );
Em := MagmaWithOne( hom );
ma := MappingByFunction( Em, G, g );
mul := constructor( ma )( a );
constructor := { z, u } -> ( { x, y ) -> u^( PreImage( z, y ) * PreImage( z, x ) ) );
B := Filtered( hom, x -> IsInjective( x ) );
A := GroupByGenerators( B );
k1 := Position( OrbitLengths( A, G ), Size( A ) );
Or := OrbitsDomain( A, G )[k1];
a := Or[1];
g := const( a );
Em := MagmaWithOne( hom );
ma := MappingByFunction( Em, G, g );
mul := constructor( ma, a );

Comment thread lib/lib_local.gi Outdated
Comment thread lib/lib_local.gi Outdated
Comment thread lib/lib_local.gi Outdated
Comment thread lib/lib_local.gi Outdated
Comment thread lib/lib_local.gi Outdated
Comment thread lib/local.gi
Comment on lines +57 to +60
T := [];
for x in Or do
Add( T, Representative( x ) );
od;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
T := [];
for x in Or do
Add( T, Representative( x ) );
od;
T := List( Or, Representative );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will revisit this later separately

Comment thread lib/local.gi
od;
F := [];
repeat
M := Filtered( T, x -> Order( x ) = Maximum( List( T, Order ) ) );
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This recomputes Maximum( List( T, Order ) ) again and again, i.e., is quadratic in the length of T. Better to compute this value once, in the line before, and use that.

Comment thread lib/local.gi
Comment on lines +269 to +272
g := [];
for a in N do
Add( g, AsGroupReductElement( a ) );
od;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
g := [];
for a in N do
Add( g, AsGroupReductElement( a ) );
od;
g := List( N, AsGroupReductElement );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above (timing concerns)

Comment thread lib/local.gi
else
u := Identity( R );
a := AsSemigroup( List( R ) );
Print( "Semigroup with identity", " ", u, "\n" );
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Print( "Semigroup with identity", " ", u, "\n" );

Comment thread lib/local.gi
if Identity( R ) = fail then
a := AsSemigroup( List( R ) );
else
u := Identity( R );
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused, and so in fact the case where you have and don't have the identity are behaving exactly the same. Is that intentional?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently yes - this is related to SONATA features

Thanks for James and Max!

Co-authored-by: Max Horn <max@quendi.de>
Copy link
Copy Markdown
Member

@olexandr-konovalov olexandr-konovalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to @fingolfin and @james-d-mitchell - we have revised and added to the batch what was possible. Some suggestions were marked by GitHub as not applicable - we will redo them manually. A couple of others need further discussion.

Comment thread lib/local.gi
Comment on lines +57 to +60
T := [];
for x in Or do
Add( T, Representative( x ) );
od;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will revisit this later separately

Comment thread lib/local.gi
Comment on lines +12 to +16
if ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will revisit this suggestion later separately

Comment thread lib/local.gi
Comment on lines +94 to +98
if Size( h ) > 0 then
return true;
else
return false;
fi;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub says "Unable to apply suggestions on deleted lines." - we will do this later separately

Comment thread lib/local.gi
Comment on lines +141 to +145
if IsSubset( U, V ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +160 to +164
if IsAdditiveGroupHomomorphism( map ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +269 to +272
g := [];
for a in N do
Add( g, AsGroupReductElement( a ) );
od;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above (timing concerns)

Comment thread lib/local.gi
if Identity( R ) = fail then
a := AsSemigroup( List( R ) );
else
u := Identity( R );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently yes - this is related to SONATA features

Comment thread lib/local.gi
Comment on lines +354 to +358
if Size( U ) < Size( R ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +458 to +462
if IsSubset( Un, F ) and Size( Unique( ListX( F, F, \* ) ) ) = Size( F ) then
return true;
else
return false;
fi;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

Comment thread lib/local.gi
Comment on lines +571 to +574
if Size( H ) = Size( S ) then
return true;
fi;
return false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for later, same as above

@olexandr-konovalov olexandr-konovalov merged commit d86f3bd into master May 1, 2026
8 of 9 checks passed
@olexandr-konovalov olexandr-konovalov deleted the mh/indentation branch May 1, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants