Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #36 +/- ##
=======================================
Coverage ? 49.82%
=======================================
Files ? 10
Lines ? 570
Branches ? 0
=======================================
Hits ? 284
Misses ? 286
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
note that position, current_position conflicts with Julia Base.*, so we need to reference Semigroups.position, etc. directly
| @testset "FroidurePin inherited FroidurePinBase methods" begin | ||
| LS = Semigroups.LibSemigroups | ||
|
|
||
| t1 = LS.Transf1(StdVector{UInt8}(UInt8[1, 0, 2])) |
There was a problem hiding this comment.
I think we shouldn't be testing the lower-level stuff, only its higher level equivalents (it is these after all that we want to be used and working). I.e. I think here you are testing the implementation, which might change even if the API doesn't.
There was a problem hiding this comment.
oops didn't mean to commit these tests. I was going to work on porting test suite from C++/Python tomorrow which will replace this file
| # ============================================================================ | ||
|
|
||
| """ | ||
| length(S::FroidurePin) -> Int |
There was a problem hiding this comment.
This should be called size the name length conflicts with something else. Was there a reason to call it length?
There was a problem hiding this comment.
Only because overloading Base.length is the standard convention for data structures, but I just looked at Python and saw that there is no overload for len - so I'm assuming you'd rather use size?
| # Display | ||
| # ============================================================================ | ||
|
|
||
| function Base.show(io::IO, S::FroidurePin{E}) where {E} |
There was a problem hiding this comment.
This shouldn't be necessary, use to_human_readable_repr from libsemigroups itself, to avoid code duplication.
| Return the 1-based position of `x` in `S`, or `nothing` if not found. | ||
| Triggers full enumeration. | ||
| """ | ||
| function position(S::FroidurePin{E}, x::E) where {E} |
There was a problem hiding this comment.
This doesn't seem to work as expected:
S = FroidurePin([Transf([1, 1, 2]), Transf([2, 1, 3]), Transf([2, 3, 1])])
julia> position(S, S[10])
ERROR: MethodError: no method matching position(::FroidurePin{Transf{UInt8}}, ::Transf{UInt8})
The function `position` exists, but no method is defined for this combination of argument types.
Closest candidates are:
position(::Base.JuliaSyntax.ParseState, ::Any...)
@ Base /private/tmp/julia-20260101-8411-jav5tg/julia-1.12.3/base/JuliaSyntax/src/parser.jl:116
position(::Base.JuliaSyntax.ParseStream)
@ Base /private/tmp/julia-20260101-8411-jav5tg/julia-1.12.3/base/JuliaSyntax/src/parse_stream.jl:956
position(::Base.Filesystem.File)
@ Base filesystem.jl:348
...
Stacktrace:
[1] top-level scope
@ REPL[19]:1
not sure why
There was a problem hiding this comment.
Ah yeah I wasn't sure what to do about this so I just left it TBD; should've made a note.
So position is defined in Julia's Base (Base.position) which is designated for IO streams, exporting this function directly causes a conflict. We can overload Base.position so this functionality works, but I was going to do some research first and make sure there aren't any underlying problems since it was designed for separate purpose. I'm assuming this is fine and what I'll end up doing, but wanted to look at some similar packages first.
Right now you can use it by calling Semigroups.position. Or if you want to use it directly you can run:
import Semigroups: position
position(args)in your repl.
| _to_word_0based(word) = StdVector{CxxULong}(CxxULong[w - 1 for w in word]) | ||
|
|
||
| # Check if C++ returned UNDEFINED and convert to nothing (with +1 shift) | ||
| _maybe_undefined(val::UInt32) = is_undefined(val, UInt32) ? nothing : Int(val) + 1 |
There was a problem hiding this comment.
In the python bindings we generally returned UNDEFINED instead of the perhaps more canonical None, this was to make it more similar to the C++ bindings, and to simplify some of the code. If you want to use nothing here instead of UNDEFINED I don't object, just wanted to point out that it should be consistently used everywhere, and that this convention should be recorded somewhere in the CONTRIBUTING.md file.
There was a problem hiding this comment.
We should discuss tmr and weigh pros/cons. My justification was to keep it as close to Julian convention as possible for easier integration into other libraries, but I'm not attached to it.
| """ | ||
| FroidurePin(gens::AbstractVector{E}) where {E} | ||
|
|
||
| Construct a FroidurePin semigroup from a vector of generators. |
There was a problem hiding this comment.
I'd really prefer the doc to be copied/generated from the C++ doc rather than partially (and not completely accurately, sorry!) paraphrased here. This will increasingly become an issue the more stuff we add/change/etc.
There was a problem hiding this comment.
Sorry I should've made a note that the docs are not ready. I'm going to delete and rebuild this after #33 and #35 get merged and write up the full docstrings and update docs site.
Re: generating docs automatically, I looked at it briefly and it seemed it was going to be easier to just copy/paste/edit manually but we can discuss tmr if doing that programmatically would be better for LTS.
james-d-mitchell
left a comment
There was a problem hiding this comment.
This generally looks amazing, there are one or two persistent issues though:
- reimplementing things that already exist in libsemigroups in this instance
show - it'd be good if we could start copying/generating the doc from libsemigroups itself.
|
@james-d-mitchell sounds good, will make these changes tmr. Does the WordGraph/Runner functionality look okay to you? |
|
Todo list for final PR:
|
Addresses #32. Opening for visibility, final PR will be rebased when #33 and #35 are merged.
FroidurePinBasebindingFroidurePin<E>template instantiationsFroidurePinjulia API