Reindent lib/local.gi and lib/lib_local.gi for readability#29
Reindent lib/local.gi and lib/lib_local.gi for readability#29olexandr-konovalov merged 2 commits intomasterfrom
Conversation
Keep the contents unchanged apart from whitespace and line breaks. Co-authored-by: Codex <codex@openai.com>
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
| if ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
| if ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) ) then | |
| return true; | |
| else | |
| return false; | |
| fi; | |
| return ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) ); |
There was a problem hiding this comment.
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 :-)
There was a problem hiding this comment.
(Just to be clear: I do agree with all changes suggested by James)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Yeah fair enough, I just noticed them, and thought I'd point them out, probably not the right place to do it.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Agree. @raemarina @IrynaRaievska let's do this tomorrow, to pave the way to the further code refactoring.
There was a problem hiding this comment.
Just to also mention that gaplint will point out issues like this, making them easier to discover
There was a problem hiding this comment.
We will revisit this suggestion later separately
| if Size( h ) > 0 then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
| if Size( h ) > 0 then | |
| return true; | |
| else | |
| return false; | |
| fi; | |
| return Size( h ) > 0; |
There was a problem hiding this comment.
GitHub says "Unable to apply suggestions on deleted lines." - we will do this later separately
| if IsSubset( U, V ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
| if IsSubset( U, V ) then | |
| return true; | |
| else | |
| return false; | |
| fi; | |
| return IsSubset( U, V ); |
There was a problem hiding this comment.
TODO for later, same as above
| if IsAdditiveGroupHomomorphism( map ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
| if IsAdditiveGroupHomomorphism( map ) then | |
| return true; | |
| else | |
| return false; | |
| fi; | |
| return IsAdditiveGroupHomomorphism( map ); |
There was a problem hiding this comment.
TODO for later, same as above
| if IsAbelian( G ) and IsLocalNearRing( R ) and | ||
| ForAll( elm, y -> IsDistributiveElementOfNearRing( R, y ) ) | ||
| then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
| 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 ) ); |
There was a problem hiding this comment.
TODO for later, same as above
| if Size( U ) < Size( R ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
| if Size( U ) < Size( R ) then | |
| return true; | |
| else | |
| return false; | |
| fi; | |
| return Size( U ) < Size( R ); |
There was a problem hiding this comment.
TODO for later, same as above
| if IsSubset( Un, F ) and Size( Unique( ListX( F, F, \* ) ) ) = Size( F ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
| 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 ); |
There was a problem hiding this comment.
TODO for later, same as above
| if Size( H ) = Size( S ) then | ||
| return true; | ||
| fi; | ||
| return false; |
There was a problem hiding this comment.
| if Size( H ) = Size( S ) then | |
| return true; | |
| fi; | |
| return false; | |
| return Size( H ) = Size( S ); |
There was a problem hiding this comment.
TODO for later, same as above
| d := GroupHomomorphismByImagesNC( G, G, gr, x ); | ||
| Add( hom, d ); | ||
| od; | ||
| f := function( x, y ) return x * y; end; |
There was a problem hiding this comment.
This functions seems to be unused and could be removed in a follow-up PR (also f from the list of variables) .
| 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 ); |
There was a problem hiding this comment.
| 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 ); |
| T := []; | ||
| for x in Or do | ||
| Add( T, Representative( x ) ); | ||
| od; |
There was a problem hiding this comment.
| T := []; | |
| for x in Or do | |
| Add( T, Representative( x ) ); | |
| od; | |
| T := List( Or, Representative ); |
There was a problem hiding this comment.
We will revisit this later separately
| od; | ||
| F := []; | ||
| repeat | ||
| M := Filtered( T, x -> Order( x ) = Maximum( List( T, Order ) ) ); |
There was a problem hiding this comment.
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.
| g := []; | ||
| for a in N do | ||
| Add( g, AsGroupReductElement( a ) ); | ||
| od; |
There was a problem hiding this comment.
| g := []; | |
| for a in N do | |
| Add( g, AsGroupReductElement( a ) ); | |
| od; | |
| g := List( N, AsGroupReductElement ); |
There was a problem hiding this comment.
TODO for later, same as above (timing concerns)
| else | ||
| u := Identity( R ); | ||
| a := AsSemigroup( List( R ) ); | ||
| Print( "Semigroup with identity", " ", u, "\n" ); |
There was a problem hiding this comment.
| Print( "Semigroup with identity", " ", u, "\n" ); |
| if Identity( R ) = fail then | ||
| a := AsSemigroup( List( R ) ); | ||
| else | ||
| u := Identity( R ); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Apparently yes - this is related to SONATA features
Thanks for James and Max! Co-authored-by: Max Horn <max@quendi.de>
olexandr-konovalov
left a comment
There was a problem hiding this comment.
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.
| T := []; | ||
| for x in Or do | ||
| Add( T, Representative( x ) ); | ||
| od; |
There was a problem hiding this comment.
We will revisit this later separately
| if ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
We will revisit this suggestion later separately
| if Size( h ) > 0 then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
GitHub says "Unable to apply suggestions on deleted lines." - we will do this later separately
| if IsSubset( U, V ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
TODO for later, same as above
| if IsAdditiveGroupHomomorphism( map ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
TODO for later, same as above
| g := []; | ||
| for a in N do | ||
| Add( g, AsGroupReductElement( a ) ); | ||
| od; |
There was a problem hiding this comment.
TODO for later, same as above (timing concerns)
| if Identity( R ) = fail then | ||
| a := AsSemigroup( List( R ) ); | ||
| else | ||
| u := Identity( R ); |
There was a problem hiding this comment.
Apparently yes - this is related to SONATA features
| if Size( U ) < Size( R ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
TODO for later, same as above
| if IsSubset( Un, F ) and Size( Unique( ListX( F, F, \* ) ) ) = Size( F ) then | ||
| return true; | ||
| else | ||
| return false; | ||
| fi; |
There was a problem hiding this comment.
TODO for later, same as above
| if Size( H ) = Size( S ) then | ||
| return true; | ||
| fi; | ||
| return false; |
There was a problem hiding this comment.
TODO for later, same as above
The code in
lib/lib_local.gihas no indentation and as a result is rather hard to read. The code inlib/local.giis 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)