Skip to content

Move vector_random() to free_module.py with doctests #40344

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

eslteacher902010
Copy link

This PR moves the vector_random(R, n, *args, **kwargs) function to src/sage/modules/free_module.py.

Mirrors matrix.random() for API consistency

Calls FreeModule(R, n).random_element(...) internally

Adds doctests demonstrating usage with ZZ, QQ, and GF(7)

This avoids modifying core files and addresses the enhancement proposed in #40316.
Let me know if anything should be changed!

paulkniaz added 2 commits June 30, 2025 12:16
Adds vector_random() as a wrapper for FreeModule(...).random_element(),
mirroring matrix.random() for API symmetry. Includes a basic test.
@eslteacher902010
Copy link
Author

Small note: The earlier commit mentions a test file, but that was just temporary while checking behavior. The final PR only includes doctests inside vector_random(), as discussed — no standalone test file added.

Copy link

@whoami730 whoami730 left a comment

Choose a reason for hiding this comment

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

  • As I said earlier, please reduce or avoid AI slop. It looks like everything including code, commit/PR message etc are AI generated. If you wish to do that, please do a self review of your own PR before proceeding to ask for review.
  • Fix PR title and avoid raising new PRs for each change, this loses history.
  • We already have random_vector function. Having another vector_random function is redundant. What is instead needed to have is a vector.random method akin to matrix.random method. Consider looking at the implementation of the same.
  • Both random_vector and vector.random should ideally share implementation as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants