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

refactor: rewire() now does 10 times the number of edges trials by default #787

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

szhorvat
Copy link
Member

@szhorvat szhorvat commented Jul 3, 2024

Closes #775

@ntamas, can you help with this? What should I specify as the default for n? I'm pretty sure that the way I wrote n=None is not correct.

@ntamas
Copy link
Member

ntamas commented Jul 3, 2024

PyArg_ParseTupleAndKeywords(args, kwds, "|nO", kwlist, &n, &mode_o) -- this function parses n as a Python integer int and saves it in a Py_ssize_t, that's why you cannot simply pass None for n right now (see here for more details). If you wanted to support None, you would need to change the format string to |OO, parse n into a PyObject* first, check whether it's None (with == Py_None) and if not, try to cast it into a Py_ssize_t with PyNumber_AsSsize_t (see here ).

@szhorvat
Copy link
Member Author

szhorvat commented Jul 3, 2024

What I want is that the effective default be 1000*ecount. What is the best way to do this? Should the formal default be None, which is then interpreted this way? If yes, I now understand how to do that and can update this PR. Let me know.

@ntamas
Copy link
Member

ntamas commented Jul 3, 2024

Yes, that's the way to go, that's how I would do it in pure Python as well.

@szhorvat szhorvat force-pushed the fix/rewire-count branch from 1f6a550 to 51775d8 Compare July 3, 2024 17:27
@szhorvat szhorvat force-pushed the fix/rewire-count branch from 51775d8 to 67b44e4 Compare July 3, 2024 17:27
@szhorvat szhorvat marked this pull request as ready for review July 3, 2024 17:28
@szhorvat szhorvat requested a review from ntamas July 3, 2024 17:28
@szhorvat
Copy link
Member Author

szhorvat commented Jul 3, 2024

@ntamas Have another look, I used igraphmodule_PyObject_to_integer_t() instead of PyNumber_AsSsize_t. Is this okay?

@ntamas ntamas merged commit 613d39a into main Jul 3, 2024
22 checks passed
@ntamas ntamas deleted the fix/rewire-count branch July 3, 2024 19:33
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.

The default number of trials in rewire() should be proportional to the edge count
2 participants