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

add support for immutable=True/False parameter in .canonical_label() and other functions that create a new graph #39177

Open
1 task done
maxale opened this issue Dec 20, 2024 · 0 comments

Comments

@maxale
Copy link
Contributor

maxale commented Dec 20, 2024

Problem Description

Since Graph().canonical_label(immutable=True) gives

TypeError: GenericGraph.canonical_label() got an unexpected keyword argument 'immutable'

one is forced to use an additional .copy() call like Graph().canonical_label().copy(immutable=True) to get an immutable canonical label of a given graph.

Proposed Solution

It will be more straightforward to have immutable= keyword argument supported by any function that creates and returns a new graph (like .canonical_copy()) to save on an extra call to .copy(immutable=True) when the returned graph is needed to be immutable.

Alternatives Considered

N/A

Additional Information

No response

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 5, 2025
…hs/digraph_generators.py` (part 1)

    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 7, 2025
…hs/digraph_generators.py` (part 1)

    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 9, 2025
…hs/digraph_generators.py` (part 1)

    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 10, 2025
…hs/digraph_generators.py` (part 1)

    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 12, 2025
…hs/digraph_generators.py` (part 1)

    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 16, 2025
…hs/digraph_generators.py` (part 1)

    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 17, 2025
…hs/digraph_generators.py` (part 1)

    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 20, 2025
…graphs/graph_generators.py`

    
We add parameter `immutable` to all generators in
`src/sage/graphs/graph_generators.py`.

As suggested in sagemath#39177, all methods creating and returning a graph
should offer the option to get an immutable graph.


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39247
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 20, 2025
…phs/generators/basic.py`

    
Following discussions in sagemath#39177, we add parameter `immutable` to all
methods in `sage/graphs/generators/basic.py`.
We also add parameter `name` to some methods to ease constructions.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39317
Reported by: David Coudert
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 23, 2025
…graphs/graph_generators.py`

    
We add parameter `immutable` to all generators in
`src/sage/graphs/graph_generators.py`.

As suggested in sagemath#39177, all methods creating and returning a graph
should offer the option to get an immutable graph.


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39247
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 23, 2025
…phs/generators/basic.py`

    
Following discussions in sagemath#39177, we add parameter `immutable` to all
methods in `sage/graphs/generators/basic.py`.
We also add parameter `name` to some methods to ease constructions.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39317
Reported by: David Coudert
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 25, 2025
…graphs/graph_generators.py`

    
We add parameter `immutable` to all generators in
`src/sage/graphs/graph_generators.py`.

As suggested in sagemath#39177, all methods creating and returning a graph
should offer the option to get an immutable graph.


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39247
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 25, 2025
…phs/generators/basic.py`

    
Following discussions in sagemath#39177, we add parameter `immutable` to all
methods in `sage/graphs/generators/basic.py`.
We also add parameter `name` to some methods to ease constructions.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39317
Reported by: David Coudert
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 26, 2025
…graphs/graph_generators.py`

    
We add parameter `immutable` to all generators in
`src/sage/graphs/graph_generators.py`.

As suggested in sagemath#39177, all methods creating and returning a graph
should offer the option to get an immutable graph.


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39247
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 26, 2025
…phs/generators/basic.py`

    
Following discussions in sagemath#39177, we add parameter `immutable` to all
methods in `sage/graphs/generators/basic.py`.
We also add parameter `name` to some methods to ease constructions.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39317
Reported by: David Coudert
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 28, 2025
… `sage/graphs/generic_graph.py`

    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 29, 2025
… `sage/graphs/generic_graph.py`

    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 30, 2025
… `sage/graphs/generic_graph.py`

    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 31, 2025
… `sage/graphs/generic_graph.py`

    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants