-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Remove redundant Python2 numeric conversions #4508
Conversation
The changes caused a breakage in one of the gallery examples (see the failing circleci build). It looks like one of the |
Sorry for the delay, thank you for the hint, I ignored the comment above that snippet of code about actually converting from |
* Deprecate name kwarg from union * Change PR number on release_dev * Fix PR link as well
The vertex_cover algorithm updated the cost of u,v twice in case node v and node u are the same nodes. As a result self-edged nodes are overlooked. Here we fixed the way vertex_cover is being updated which also improve the performance compared to the old implementation
* Update core dev team * Update doc/developer/team.rst Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Reimplement union_all to take linear time * Reimplement disjoint_union_all to take linear time * Reimplement union in terms of union_all * Reimplement disjoint_union in terms of disjoint_union_all * Reimplement intersection_all to take linear time * Reimplement intersection in terms of intersection_all * Reimplement compose_all to take linear time * Reimplement compose in terms of compose_all * Refactor union_all to be more similar to compose_all * Fix formatting in algorithms/operators/all.py Co-authored-by: Kevin Berry <kevin.berry@worthix.com>
…cale_layout_dict (#5091) * changed tuple to np.array * changed return to zip * modified unittest to match rescale_layout_dict return type * modified doctest rescale_layout_dict * added import statement to doctest; test pass * Add release note about change in return type. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
A more descriptive variable name for exceptions. This reduces local var naming conflicts when \`e\` is used e.g. to represent edges as a loop variable.
* minor tweaks in assortativity docs and code docs switch adjacent to incident more readable code in node_degree_xy tuple formatting in docs * fix multigraph treatment * Capitalize Pearson Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Support sequences of linestyles for directed edges in `draw_networkx_edges`.
…5099) * Add examples and minor refactor * Fix intersection example * Fix difference example * Fix difference example take 2 * Remove example imports and update union example Co-authored-by: Dan Schult <dschult@colgate.edu> * Fix some errors * Improve union docstring * Add back union name kwarg
) * Reorganize test suite for gnp random graphs generators * Remove unnecessary outer class * Split tests in smaller functions to improve granularity and readability * Add tests parametrization for different gnp generators and their pars * Improve tests for gnp generators aliases * Test binomial_graph and erdos_renyi_graph as aliases of gnp_random_graph * Add tests parametrization for different random seeds
* Refactor linestyle test for FancyArrowPatches. Test parsing logic and cylcing for linestyles when drawing edges with FancyArrowPatch objects. * Improve test name/docstring.
* Drop Py37 * XML serialization issue * Use math.comb Co-authored-by: Simone Gasperini <simone.gasperini2@studio.unibo.it> * Run pyupgrade --py38-plus * Run black * More documentation * Deprecate euclidean Co-authored-by: Simone Gasperini <simone.gasperini2@studio.unibo.it>
* Test on Python 3.10 * Fix tests
* Paremtrize edge color default. * Simplify. * Add tests for single edge_color. * Add test of edge_color tuple interpretation. * Parametrize single-edge_color tests on edgelist. * Add tests for num ec gt or lt num edges. * Rm redundant tests. * Factor out global alpha test. * Factor out tests for edges w/ single line width. * Factor out tests of linewidth as a sequence. * Refactor edge cmap scaling test.
…5144) * Rm _init_label_matrix indirection. * Factor out _predict indirection. * Factor out _propagate one-liner. * Factor out _build_base_matrix fn. * Minor cleanups. * Fix up docstrings. * Rm internal _build_propagation_matrix internal fn. * Rm unnecessary binding of local variable.
The arrowsize param to draw_networkx_edges can now be a list of values, one value per edge. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* added example on moral graph * added raise networkxnotimplemented
* documentation * added examples * Update branchings.py * Update branchings.py * simplified
…ites (#5635) * DOC: fix up links, remove references to directed graphs, add proper cites * make black happy * Update networkx/linalg/laplacianmatrix.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* added example on complement * added example on reverse * adjusted output * added raises section
Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* added example min_edge_cover * added example is_edge_cover
…#5657) * Fix __setstate__ for OutEdgeView subclasses, read _adjdict from state * add a test to check cacheing and slots work together
* Add examples & improve documentation of voterank * Run black for autoformatting * Fix minor typo * Change example (add edges from the list instead of one by one) Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Revert to previous wording * Re-format second example * minor formatting nits. Co-authored-by: dtuncturk <dilaramemis@sabanciuniv.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* added example on closeness * docstring improvement
@eumiro while fixing up the merge conflicts and getting this ready to be merged messed up git a bit. I'll close this and move your commits to a new PR :) |
Three independent commits to remove Python2 numeric functionality.
Remove redundant float conversion
: In Python 3,a / b
of two integers always returns a float. That's why it is not necessary to convert one or both of these parts to afloat
.Remove redundant int conversion
: In Python 3,math.ceil
,math.floor
andround
(withoutndigits
) always return anint
, so there's no need to convert it.Use integer division
: In Python 3int(a / b)
for two integers can be written asa // b
.These three commits remove Python2 code to comply with Python3 rules and make the code more readable. There are also plenty of numeric literals left in the code that could be converted accordingly, such as
x / 2.0
wherex / 2
would work the same. Are you interested in another PR cleaning up those Python2 relics?