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

Immutable graphs must not be relabeled #15622

Closed
nathanncohen mannequin opened this issue Jan 2, 2014 · 33 comments
Closed

Immutable graphs must not be relabeled #15622

nathanncohen mannequin opened this issue Jan 2, 2014 · 33 comments

Comments

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jan 2, 2014

Now

sage: Graph(graphs.PetersenGraph(), immutable=True).relabel({})
...
ValueError: Thou shalt not relabel an immutable graph

Before, the following happened

sage: Graph(graphs.PetersenGraph(), data_structure="static_sparse").relabel({})
...
AttributeError: 'StaticSparseBackend' object has no attribute 'vertex_ints'

This is actually another bug, as there should be a vertex_ints variable in static sparse graphs. But that's another problem to be addressed in another ticket :-P

Nathann

Depends on #15619

CC: @simon-king-jena

Component: graph theory

Author: Nathann Cohen

Branch/Commit: u/ncohen/15622 @ 6398780

Reviewer: Simon King

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

@nathanncohen nathanncohen mannequin added this to the sage-6.1 milestone Jan 2, 2014
@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 2, 2014

Branch: u/ncohen/15622

@nathanncohen nathanncohen mannequin added the s: needs review label Jan 2, 2014
@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 2, 2014

Changed dependencies from #15603 to #15619

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 2, 2014

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

0f57805trac #15622: Immutable graphs must not be relabeled
c441178trac #15619: bug in the former definition; exception to avoid it in the future
0229348trac #15619: Pickling of immutable graphs
7860f39trac #15603: "immutable=True" for Graph/Digraph `__init__` and copy()
2525d22Trac 15278: Fix syntax error in doc test
fcf9e30Trac 15278: Only graphs that use the static backend are identical with their copy
8fc9c94Merge branch 'develop' into ticket/15278
51d6328Trac 15278: Error messages explain how to create (im)mutable graph copy
2fc8a77Make digraphs using the static backend immutable and hashable
07bad46Merge branch 'u/ncohen/15491' of git://trac.sagemath.org/sage into ticket/15278

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 2, 2014

Commit: 0f57805

@simon-king-jena
Copy link
Member

comment:4

The code looks good. Perhaps the error message should hint at how to create a mutable copy?

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 3, 2014

comment:5

OKayyyyyyyy.. What about this ?

Nathann

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 3, 2014

Changed commit from 0f57805 to 529f785

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 3, 2014

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

529f785trac #15622: More informative exception message

@simon-king-jena
Copy link
Member

comment:7

Oops:

sage -t --long src/sage/graphs/base/static_sparse_backend.pyx
**********************************************************************
File "src/sage/graphs/base/static_sparse_backend.pyx", line 422, in sage.graphs.base.static_sparse_backend.StaticSparseBackend.relabel
Failed example:
    g.relabel([],True)
Expected:
    Traceback (most recent call last):
    ...
    ValueError: Thou shalt not remove a vertex from an immutable graph
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 480, in _run
        self.execute(example, compiled, test.globs)
      File "/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 839, in execute
        exec compiled in globs
      File "<doctest sage.graphs.base.static_sparse_backend.StaticSparseBackend.relabel[2]>", line 1, in <module>
        g.relabel([],True)
    AttributeError: 'sage.graphs.base.static_sparse_backend.StaticSpars' object has no attribute 'relabel'

That is the only error, and I'll probably fix it in a review commit.

@simon-king-jena
Copy link
Member

comment:8

WTF??????

When I do the obvious and change StaticSparseCGraph into StaticSparseBackend, I get

Failed example:
    g.relabel([],True)
Expected:
    Traceback (most recent call last):
    ...
    ValueError: Thou shalt not remove a vertex from an immutable graph
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 480, in _run
        self.execute(example, compiled, test.globs)
      File "/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 839, in execute
        exec compiled in globs
      File "<doctest sage.graphs.base.static_sparse_backend.StaticSparseBackend.relabel[2]>", line 1, in <module>
        g.relabel([],True)
      File "static_sparse_backend.pyx", line 428, in sage.graphs.base.static_sparse_backend.StaticSparseBackend.relabel (sage/graphs/base/static_sparse_backend.c:4740)
    ValueError: Thou shalt not relabel an immutable graph

Where does the blankline come from? And why is there no blankline when doing the test interactively?

@simon-king-jena
Copy link
Member

comment:9

Ahaaa! You had a wrong class and a wrong error message in your test ("remove a vertex" versus "relabel").

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 3, 2014

comment:10

I don't get what the "obvious change from StaticSparseCGraph into StaticSparseBackend" could be O_o

Nathann

@simon-king-jena
Copy link
Member

comment:11

Replying to @nathanncohen:

I don't get what the "obvious change from StaticSparseCGraph into StaticSparseBackend" could be O_o

diff --git a/src/sage/graphs/base/static_sparse_backend.pyx b/src/sage/graphs/base/static_sparse_backend.pyx
index 9b5a8fe..e5b889e 100644
--- a/src/sage/graphs/base/static_sparse_backend.pyx
+++ b/src/sage/graphs/base/static_sparse_backend.pyx
@@ -417,12 +417,12 @@ class StaticSparseBackend(CGraphBackend):
 
         TEST::
 
-            sage: from sage.graphs.base.static_sparse_backend import StaticSparseCGraph
-            sage: g = StaticSparseCGraph(graphs.PetersenGraph())
+            sage: from sage.graphs.base.static_sparse_backend import StaticSparseBackend
+            sage: g = StaticSparseBackend(graphs.PetersenGraph())
             sage: g.relabel([],True)
             Traceback (most recent call last):
             ...
-            ValueError: Thou shalt not remove a vertex from an immutable graph
+            ValueError: Thou shalt not relabel an immutable graph
 
         """
         raise ValueError("Thou shalt not relabel an immutable graph")

StaticSparceCGraph simply is the wrong class.

@simon-king-jena
Copy link
Member

comment:12

For the record: It already takes 5 minutes to push my review commit.

@simon-king-jena
Copy link
Member

Changed branch from u/ncohen/15622 to u/SimonKing/ticket/15622

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 3, 2014

comment:14

Oh. Ahem. Right O_O;;;;;;

Sorryyyyyyyyyyyyyyyyyyyyyyyyyyy O_O;;;;;

Nathann

Review commit : I often Ctrl+C it before it ends. Trac sends the mails almost instantaneously, the trac ticket is updated at the same time. I just have no idea what it does afterwards.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 3, 2014

Changed branch from u/SimonKing/ticket/15622 to u/ncohen/15622

@simon-king-jena
Copy link
Member

comment:15

It seems that once more I have to manually upload the commit.

@simon-king-jena
Copy link
Member

Changed branch from u/ncohen/15622 to u/SimonKing/ticket/15622

@simon-king-jena
Copy link
Member

Changed commit from 529f785 to 2245c02

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 3, 2014

comment:16

I think it's because you should set the branch name before pushing the commit. Otherwise nothing is triggered on the trac server's side.

Nathann

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 3, 2014

comment:17

Okay. We are now in the Volker-Feared situation of a ticket which has a positive review, with a dependency which is still in needs_review :-P

Thanks for this commit !

Nathann

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 3, 2014

comment:18

By the way, isn't the trac server 99999x times faster than yesterday ? Andrew said he would do something about it and it looks like he did O_O

Nathann

@vbraun vbraun removed this from the sage-6.1 milestone Jan 4, 2014
@vbraun vbraun added the pending label Jan 4, 2014
@vbraun vbraun added this to the sage-6.1 milestone Jan 5, 2014
@vbraun vbraun removed the pending label Jan 5, 2014
@vbraun
Copy link
Member

vbraun commented Jan 5, 2014

Reviewer: Simon King

@vbraun
Copy link
Member

vbraun commented Jan 5, 2014

comment:22

Various doctests fail (see also patchbot)

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 5, 2014

comment:23

Gloops. Right.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 5, 2014

Changed branch from u/SimonKing/ticket/15622 to u/ncohen/15622

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 5, 2014

Changed commit from 2245c02 to 529f785

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 5, 2014

comment:24

That's the only way I found to make this work before #15623 is merged T_T

Nathann

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 5, 2014

Changed commit from 529f785 to 6398780

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Jan 5, 2014

comment:25

Okay, it looks like the automatic message does not work, but the branch is updated !

Nathann

@simon-king-jena
Copy link
Member

comment:26

Replying to @vbraun:

Various doctests fail (see also patchbot)

WTF? When I reviewed it, things worked. Or did I accidentally merge other tickets that aren't dependencies for this?

@simon-king-jena
Copy link
Member

comment:27

Hooray. After pulling from the ticket branch and merging with the current develop branch, make ptest results in

All tests passed!
----------------------------------------------------------------------
Total time for all tests: 3791.7 seconds
    cpu time: 6340.1 seconds
    cumulative wall time: 7304.6 seconds

Nathann's last commit looks like the right thing to do. Hence, I hope this time my positive review will persist...

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

2 participants