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

Graph: accept keyword arguments for matrix constructor in methods returning a matrix #33388

Closed
dcoudert opened this issue Feb 20, 2022 · 19 comments

Comments

@dcoudert
Copy link
Contributor

Following #33377, we allow methods returning a matrix in Graph to pass arguments to the matrix constructors.

We also fix 33377#comment:14.

Depends on #33377

CC: @mkoeppe

Component: graph theory

Author: David Coudert

Branch: bdf02bd

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/33388

@dcoudert dcoudert added this to the sage-9.6 milestone Feb 20, 2022
@dcoudert
Copy link
Contributor Author

Branch: public/graphs/33388

@dcoudert
Copy link
Contributor Author

Last 10 new commits:

007253dsrc/sage/matrix/matrix_space.py (get_matrix_class): Handle base_ring=ZZ, implementation='numpy'
01d5541GenericGraph.adjacency_matrix: Accept keyword arguments for matrix constructor
03343f7GenericGraph.adjacency_matrix: Add doctest with immutable=True
688d054GenericGraph.weighted_adjacency_matrix: Accept keyword arguments for matrix constructor
e30c7cbGenericGraph.weighted_adjacency_matrix: Make base_ring a keyword-only argument
6f2185aGenericGraph.incidence_matrix: Accept keyword arguments for matrix constructor
0bd2930GenericGraph._matrix_: Use the new keyword argument base_ring of GenericGraph.adjacency_matrix
39da87ctrac #33388: merge with 9.6.beta2
7e5ae03trac #33388: Graph: accept keyword arguments for matrix constructor in methods returning a matrix
90a05b2trac #33388: check parameter immutable in kirchhoff_matrix

@dcoudert

This comment has been minimized.

@dcoudert
Copy link
Contributor Author

Commit: 90a05b2

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 20, 2022

comment:2
+        if 'immutable' in kwds:
+            set_immutable = kwds['immutable']
+            del kwds['immutable']
+        else:
+            set_immutable = False

This can be replaced by set_immutable = kwds.pop('immutable', False)

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 20, 2022

comment:3

Also M can be constructed as immutable in this function because the code is not mutating M.

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 20, 2022

comment:4

Similar comment on seidel_adjacency_matrix. Perhaps you could construct C as mutable, A as immutable, and then do an in-place subtraction to construct a mutable or immutable result.

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 20, 2022

comment:5

For effective_resistance, as the result is a scalar, I'm not sure if exposing all matrix keywords is a good idea. Perhaps only base_ring?

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 20, 2022

comment:6

Replying to @mkoeppe:

Similar comment on seidel_adjacency_matrix. Perhaps you could construct C as mutable, A as immutable, and then do an in-place subtraction to construct a mutable or immutable result.

Likewise for effective_resistance_matrix

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 20, 2022

comment:7

Also in common_neighbors_matrix, handling immutable would be good

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 20, 2022

Reviewer: Matthias Koeppe

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 20, 2022

Changed commit from 90a05b2 to bdf02bd

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 20, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

bdf02bdtrac #33388: review comments

@dcoudert
Copy link
Contributor Author

comment:10

I tried to address all your comments.

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 20, 2022

comment:11

LGTM. Green patchbot => positive review

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 23, 2022

comment:12

The patchbot failure is unrelated

@vbraun
Copy link
Member

vbraun commented Feb 27, 2022

Changed branch from public/graphs/33388 to bdf02bd

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Feb 28, 2022

Changed commit from bdf02bd to none

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Feb 28, 2022

comment:14

Patchbots are locked because of some numerical noise in a doctest introduced in this ticket, follow-up : #33427

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

No branches or pull requests

3 participants