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

GenericGraph.[weighted]adjacency_matrix, incidence_matrix: Accept keyword arguments for matrix constructor #33377

Closed
mkoeppe opened this issue Feb 19, 2022 · 22 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 19, 2022

Depends on #32465

CC: @dcoudert

Component: graph theory

Author: Matthias Koeppe

Branch/Commit: 0bd2930

Reviewer: David Coudert

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

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

mkoeppe commented Feb 19, 2022

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 19, 2022

Author: Matthias Koeppe

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 19, 2022

Commit: 01d5541

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 19, 2022

Last 10 new commits:

2ffb118Vector_double_dense: Factor through new class Vector_numpy_dense
5b288c3sage.modules.vector_numpy_integer_dense: New
c8eec7eMerge tag '9.5.beta6' into t/32465/refactor_matrix_double_dense_through_matrix_numpy_dense
5323b25src/sage/matrix/matrix_numpy_dense.pyx: Returns -> Return
d07cf93Merge tag '9.5' into t/32465/refactor_matrix_double_dense_through_matrix_numpy_dense
93f3925src/sage/matrix/matrix_numpy_dense.pyx: Fix doc markup, whitespace
21ed44aMerge tag '9.6.beta1' into t/32465/refactor_matrix_double_dense_through_matrix_numpy_dense
fe1da0aMerge #32465
007253dsrc/sage/matrix/matrix_space.py (get_matrix_class): Handle base_ring=ZZ, implementation='numpy'
01d5541GenericGraph.adjacency_matrix: Accept keyword arguments for matrix constructor

@mkoeppe mkoeppe changed the title Use numpy_integer_dense for adjacency matrices GenericGraph.adjacency_matrix: Accept keyword arguments for matrix constructor Feb 19, 2022
@dcoudert
Copy link
Contributor

comment:3

I'm OK with this improvement, but the same should be done for weighted_adjacency_matrix.

These methods could benefit further improvements. So far we first feed a dictionary and then build the matrix. It might be faster to directly feed the matrix.

@dcoudert
Copy link
Contributor

Reviewer: David Coudert

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 19, 2022

comment:4

Thanks for the feedback! Here's the corresponding change for weighted_adjacency_matrix.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

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

03343f7GenericGraph.adjacency_matrix: Add doctest with immutable=True
688d054GenericGraph.weighted_adjacency_matrix: Accept keyword arguments for matrix constructor

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Changed commit from 01d5541 to 688d054

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 19, 2022

comment:6

Replying to @dcoudert:

These methods could benefit further improvements. So far we first feed a dictionary and then build the matrix. It might be faster to directly feed the matrix.

Yes, but I won't work on it in this ticket

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

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

e30c7cbGenericGraph.weighted_adjacency_matrix: Make base_ring a keyword-only argument

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Changed commit from 688d054 to e30c7cb

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Changed commit from e30c7cb to 6f2185a

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

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

6f2185aGenericGraph.incidence_matrix: Accept keyword arguments for matrix constructor

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Changed commit from 6f2185a to 0bd2930

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

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

0bd2930GenericGraph._matrix_: Use the new keyword argument base_ring of GenericGraph.adjacency_matrix

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 19, 2022

comment:10

I'll stop here, but the same could be done to BipartiteGraph.reduced_adjacency_matrix and some other methods that I see in git grep ' def.*_matrix' src/sage/graphs/

For distance_matrix, kirchhoff_matrix it is trickier because these methods already accept **kwds that they pass on to some other method.

@mkoeppe mkoeppe changed the title GenericGraph.adjacency_matrix: Accept keyword arguments for matrix constructor GenericGraph.[weighted]adjacency_matrix, incidence_matrix: Accept keyword arguments for matrix constructor Feb 19, 2022
@dcoudert
Copy link
Contributor

comment:12

LGTM.

I will check the other cases.

@dcoudert
Copy link
Contributor

comment:13

For kirchhoff_matrix, all arguments in **kwds are passed to adjacency_matrix or weighted_adjacency_matrix. So it is now possible to specify the base ring.

A question is whether we should allow passing arguments for the matrix constructor to methods calling adjacency_matrix and similar methods.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 20, 2022

comment:14

Replying to @dcoudert:

For kirchhoff_matrix, all arguments in **kwds are passed to adjacency_matrix or weighted_adjacency_matrix. So it is now possible to specify the base ring.

Thanks for checking! If immutable=True is passed, the result matrix will have to be set_immutable. Could be done in #33388

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 20, 2022

comment:15

Thanks for reviewing!

@vbraun
Copy link
Member

vbraun commented Feb 21, 2022

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