-
-
Notifications
You must be signed in to change notification settings - Fork 489
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
Pickling of immutable graphs #15619
Comments
Branch: u/ncohen/15619 |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Commit: |
comment:3
I am not convinced that creating a graph in order to pickle a backend is the best possible solution. So, I'll do some further experiments with a reduce method for graphs---no need for you to worry about it at this point... |
comment:4
Of course not, it is indeed ugly code, and my point is that I write ugly code because I am forced by a machine to write code for which I have no personal use Yet it passes those stupid tests, and for this I am grateful. Right now I am fighting with "Poset.promotion", and I have noooooooo idea on earth of where the broken doctests are coming from Nathann |
comment:5
It does minimize the amount of code necessary for such a function, though. And clear code is good by itself Nathann |
comment:6
Replying to @nathanncohen:
Sage is a community project after all. |
comment:7
I don't see the relationship |
comment:8
What do you think about the following way to pickle generic graphs?
Is this elegant enough for you? Additional bait: We may even remove the existing |
comment:9
PS: With the above
|
comment:10
Some little timing: Your way of pickling:
My way of pickling:
|
comment:11
On the other hand, I think I did something severely wrong:
Bad. So, it doesn't work in the way I thought... |
comment:12
Would it be possible to let the static graph backend |
comment:13
Hm. I tried to understand what happens when one creates a static sparse backend. I always thought that one needs a backend to implement a graph. But in fact |
comment:14
Well, that can be changed too at some point if it is really needed (I would personally hate to change all this code just because the guy who implemented TestSuite decide for everybody that all the graphs classes HE tested should be picklable), but building a graph is not such a trivial matter. Because you have labels of not, because you have multiple edges or not, because the labels can be integers, have labels, because you can have loops, because they can be oriented or not. I mean, that's actually a lot of stuff, and it's not funny to implement it so many times in the code. It's already VERY messy in the Honestly, I don't think pickling really needs any amount of efficient code. So as we are just implementing it to make the testsuite happy, and unless you want to mess with all this code just because of that, let's use it. It's short and it works. It's bad code of course, because pickling is bad work. It's a generic way to store data, that should work regardless of what the data is. It's like XML. Saving data is not something that should be done without knowing what the data is. If you want to write generic code for this, it will end up being bad code. Anyway. The only problem I would like to see solved is to have Posets use a static data structure. That would make them both faster and lighter. And I think something should be done about the time complexity of the Let's move on. Can you help me with this promotion bug ? I have no idea of how it should be solved, and it seems to be the last step before having the Posets use a static backend. Nathann |
comment:15
Replying to @nathanncohen:
Right. This is in fact a strong argument for implementing the pickling in the way you did. All these optional arguments of
That's a valid point, too. Efficient pickling mainly plays a role if copying is implemented by pickling, since this may happen interactively and frequently. But we have a separate and hopefully efficient implementation of
Careful! You are just arguing that the person who knows the data structure best (i.e., you) is responsible for making pickling work
Correct. Sometimes generic code just works, but in some cases
Here or on a different ticket?
OK. So, I'll review your pickling approach, and in the meantime you point me to your branch for "making posets use immutable graphs", so that I can test the promotion bug. |
comment:16
Just for completeness: It would also be possible to say "graphs do not want being pickled", which would force all structures that use graphs to implement their own pickling by storing the defining data of the graphs they use, rather than storing these graphs directly. Hence, one could provide Poset with a custom |
comment:17
Well. So what do we do with this commit ? Is it good for you ? And more importantly, what do we do with this bug in Nathann |
comment:18
This one seems to be the underlying reason for the problems with posets:
|
comment:19
The pickling result is in fact seriously wrong:
|
comment:20
Indeed the error occurs when constructing the graph used to pickle the graph backend:
Bug in |
comment:21
In pure form, the failing example is
|
comment:22
Ahahah. You are oversimplying things. It's good that we found a bug. But that does not justify all at once the principle of testsuites and its use. I'm trying to fix that. It's weird, if you use Nathann |
comment:23
(by the way, |
comment:24
Oh. Well, it is not really a bug. It's just that Nathann |
comment:55
Annnnnnnnnd with this all tests pass.. WUUUUUHUUUUUUUUUUUUUUUUUUUUUUUU !! Nathann |
comment:56
#15623 makes Posets use immutable graphs. Cool, isn't it ? Nathann |
comment:57
Replying to @nathanncohen:
Ouch. But you take care of this in #15622, right? Apart from this: All doctests pass, and the code looks fine to me. In a review commit, I'll add some tests for issues we discussed here. |
comment:58
Indeed, indeed ! Nathann |
comment:59
Right now I am testing whether everything keeps working after merging my review patch from #15603. |
Changed branch from u/ncohen/15619 to u/SimonKing/ticket/15619 |
comment:61
I am not sure if pushing my changes properly worked (apparently I needed to manually set the commit I added). Anyway, if you like my review commit, then it is a positive review. |
Reviewer: Simon King |
comment:62
Argggggggg sorry. I just noticed that there is a problem with this code. It does not handle multiple edges and loops correctly. I HAAAAAAAAAAAAAAAAAAAAATE THESE THINGS.
I will add a commit to this one within 10 minutes. Need to write it first Nathann |
Changed commit from |
Changed branch from u/SimonKing/ticket/15619 to public/15619 |
Commit: |
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
|
comment:66
Done. tested on the most ugly graphs I could build. I hate multigraphs. I hate loops. I hate labels. Nathann |
comment:67
Helloooo Simon ! Is this one good for you ? It depends on a patch with Nathann |
comment:68
The solution seems logical to me (to the extent that multigraphs with labels and loops can be "logical"...), and the example is carefully chosen to cover all cases (including isolated vertices). Hence, if the doctests pass (I'll know in about one hour) then I'll give it a positive review. |
comment:69
OK, a bit more than an hour. According to the previous comment, this is a positive review. |
* develop: (59 commits) Updated Sage version to 6.1.beta4 trac sagemath#15572: DiGraph.is_directed_acyclic handles loops pretty well Fixed bug in uniform matroid. trac sagemath#15619: Pickling multigraphs with loops and labels Trac 15619: Review commit Trac 15603: More doctests, nicer error message No need to specify caller_name in verbose() Add comments, small cosmetic changes Make q monic before computing cubic resolvent Implement splitting fields for number fields trac sagemath#15619: bug in the former definition; exception to avoid it in the future trac 8723: fix one line in isogeny_small_degree Use "in" instead of PyDict_Contains() test for membership with `x in self`; minor doc formatting change trac sagemath#15619: Pickling of immutable graphs Rebased on sage-6.1.beta2 # User Thomas Feulner <thomas.feulner@uni-bayreuth.de> Implemented IntegerVectors_nk.rank(). Fixes sagemath#15609 Trac sagemath#5153: small change in documentation. Trac 7695: Variable name for all subfields where the name ends with a digit ...
Before
After
Depends on #15603
CC: @simon-king-jena
Component: graph theory
Author: Nathann Cohen
Branch/Commit: public/15619 @
e761346
Reviewer: Simon King
Issue created by migration from https://trac.sagemath.org/ticket/15619
The text was updated successfully, but these errors were encountered: