Skip to content

Add a random source argument to the RandomDigraph function - #963

Draft
heloiseconolly wants to merge 13 commits into
digraphs:mainfrom
heloiseconolly:random-source
Draft

heloiseconolly wants to merge 13 commits into
digraphs:mainfrom
heloiseconolly:random-source

Conversation

@heloiseconolly

Copy link
Copy Markdown

I rewrote the original C code for RANDOM_DIGRAPH into GAP to avoid the use of the non-reproducible rand() function in C. Additionally, I added an optional random source argument to RandomDigraph.

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.95082% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.93%. Comparing base (8771b99) to head (1a4e1e7).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
gap/digraph.gi 97.82% 5 Missing ⚠️

❌ Your patch check has failed because the patch coverage (97.95%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #963      +/-   ##
==========================================
- Coverage   97.47%   96.93%   -0.55%     
==========================================
  Files          51       53       +2     
  Lines       21349    21723     +374     
  Branches      639      638       -1     
==========================================
+ Hits        20811    21057     +246     
- Misses        473      602     +129     
+ Partials       65       64       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@heloiseconolly heloiseconolly changed the title Added a random source argument to the RandomDigraph function Add a random source argument to the RandomDigraph function Nov 5, 2026
@heloiseconolly
heloiseconolly marked this pull request as ready for review November 11, 2026 16:46
@reiniscirpons

Copy link
Copy Markdown
Collaborator

Thanks for the PR, @heloiseconolly . There are some issues with the CI which should be resolved:

  1. The linter is failing because some lines are not formatted like James likes them to be, you can see which ones from the output of the CI job: https://github.com/digraphs/Digraphs/actions/runs/44765713881/job/136389651731?pr=963
    You can also check this locally by installing and running gaplint (https://github.com/james-d-mitchell/gaplint) on your computer. If you are a VSCode user, there is also the VSCode gaplint plugin ( https://marketplace.visualstudio.com/items?itemName=reiniscirpons.gaplint ), though it sometimes does not work (let me know if so).

  2. It looks like some tests are failing (https://github.com/digraphs/Digraphs/actions/runs/44765713701/job/136389649401?pr=963) because some Random methods that dont take a random source don't exist, e.g. RandomTournament now fails:

gap> RandomTournament(10);
Error, no method found! For debugging hints type ?Recovery from NoMe\

It seems from the changes you made that now every random digraph function requires a second random source argument. I think it should rather be that the random source should be optional, and in case no random source is found, the function falls back to the prior C implementation with RANDOM_DIGRAPH, this way it is also backwards-compatible. To fix you just want to make a new InstallMethod call with the random source arguments, and leave the existing InstallMethod calls as they are. Or maybe its worth writing some sort of wrapper that automatically installs both versions of the method, with and without random source? What does @james-d-mitchell think?

There are some other things I noticed, I'll give a proper review when the CI is passing. Thanks again for the contribution, making it easier to use the GAP random source machinery is a nice feature!

@heloiseconolly
heloiseconolly marked this pull request as draft November 21, 2026 16:35
@heloiseconolly

Copy link
Copy Markdown
Author

Thank you for the feedback, @reiniscirpons . I am aware of these issues and currently sorting them out; I initially tried using InstallMethodWithRandomSource, but it turns out this doesn't work for constructors. I was then advised to install a method with a random source only for RandomDigraphCons and use GlobalMersenneTwister as an argument in cases with no rs argument, but it seems like a lot of code relies on RandomDigraphCons without a random source argument which is causing tests to fail. I've decided to just install methods with and without a random source separately for each filter, which isn't as neat but will probably work. I forgot to switch this back to a draft PR when I noticed these issues, so apologies for that.

This branch has not been deployed

No deployments
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.

2 participants