Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fast_random_hypergraph #655

Merged
merged 13 commits into from
Feb 7, 2025
Merged

Fix fast_random_hypergraph #655

merged 13 commits into from
Feb 7, 2025

Conversation

nwlandry
Copy link
Collaborator

@nwlandry nwlandry commented Feb 3, 2025

fast_random_hypergraph suffers from the same errors that were pointed out in issue #652. This attempts to fix these errors. As a side note, this now converts sampling using the log method into np.random.geometric(). Not sure how it compares performance-wise, but would be interesting to see.

@nwlandry nwlandry marked this pull request as draft February 3, 2025 15:37
@nwlandry
Copy link
Collaborator Author

nwlandry commented Feb 3, 2025

The only thing that doesn't work is the seed argument for numpy.random.geometric. Any ideas @leotrs @tlarock @maximelucas?

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@nwlandry nwlandry requested review from maximelucas and tlarock and removed request for maximelucas February 4, 2025 22:53
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.50%. Comparing base (69ff425) to head (e5bd37f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #655      +/-   ##
==========================================
+ Coverage   93.44%   93.50%   +0.06%     
==========================================
  Files          64       64              
  Lines        5004     5005       +1     
==========================================
+ Hits         4676     4680       +4     
+ Misses        328      325       -3     

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

@nwlandry nwlandry marked this pull request as ready for review February 4, 2025 22:53
@maximelucas
Copy link
Collaborator

Thanks! Maybe add a test to check that (i) the seed works now (the reproducibility part) and (ii) fast_random_hypergraph doesn't crash with seed=5 anymore.

@nwlandry
Copy link
Collaborator Author

nwlandry commented Feb 6, 2025

@maximelucas, I added documentation to the new method I made and I added a test. (I verified that the test fails on the main branch)

@nwlandry nwlandry force-pushed the fix-fast-random-hypergraph branch from b191d54 to a18e6a1 Compare February 6, 2025 18:18
@nwlandry
Copy link
Collaborator Author

nwlandry commented Feb 6, 2025

Quick aside is that comparing np.random.geometric vs. xgi.geometric, the new xgi version version is 4x faster.

@nwlandry
Copy link
Collaborator Author

nwlandry commented Feb 6, 2025

Okay, I fixed a bunch of random errors and should be good to go @maximelucas!

@nwlandry nwlandry merged commit 1a728ee into main Feb 7, 2025
20 checks passed
@nwlandry nwlandry deleted the fix-fast-random-hypergraph branch February 7, 2025 12:03
@maximelucas
Copy link
Collaborator

Quick aside is that comparing np.random.geometric vs. xgi.geometric, the new xgi version version is 4x faster.

Yea often numpy functions are much faster when generating a bunch of random numbers but slower for just one.

@tlarock
Copy link
Collaborator

tlarock commented Feb 7, 2025

Quick aside is that comparing np.random.geometric vs. xgi.geometric, the new xgi version version is 4x faster.

Faster is great! Do they give the same distribution?

@nwlandry
Copy link
Collaborator Author

nwlandry commented Feb 7, 2025

I can do a KS test at some point!

@nwlandry
Copy link
Collaborator Author

nwlandry commented Feb 7, 2025

Okay, the distributions look similar, and the methods are the same (almost), but I think the difference that the KS test picked up on is due to numerical errors in the evaluation of the log function.

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