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

Remove redundant Python2 numeric conversions #4508

Closed
wants to merge 420 commits into from
Closed

Remove redundant Python2 numeric conversions #4508

wants to merge 420 commits into from

Conversation

eumiro
Copy link
Contributor

@eumiro eumiro commented Jan 2, 2021

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 a float.

Remove redundant int conversion: In Python 3, math.ceil, math.floor and round (without ndigits) always return an int, so there's no need to convert it.

Use integer division: In Python 3 int(a / b) for two integers can be written as a // 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 where x / 2 would work the same. Are you interested in another PR cleaning up those Python2 relics?

@rossbar
Copy link
Contributor

rossbar commented Jan 18, 2021

The changes caused a breakage in one of the gallery examples (see the failing circleci build). It looks like one of the float() conversions was for strings, rather than numeric types.

@eumiro
Copy link
Contributor Author

eumiro commented Jan 18, 2021

The changes caused a breakage in one of the gallery examples (see the failing circleci build). It looks like one of the float() conversions was for strings, rather than numeric types.

Sorry for the delay, thank you for the hint, I ignored the comment above that snippet of code about actually converting from str. Fixed, repushed. No conflicts with new master commits.

Base automatically changed from master to main March 4, 2021 18:20
jarrodmillman and others added 27 commits October 5, 2021 11:17
* 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>
Lukong123 and others added 26 commits May 13, 2022 16:29
* 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
@MridulS
Copy link
Member

MridulS commented May 24, 2022

@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 :)
Thanks for the PR!

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

Successfully merging this pull request may close these issues.

None yet