Hi Greg!
On Thu, Jan 28, 2010 at 08:27:30PM -0800, Greg McWhirter wrote:
> I've been working on upgrading networkx to 1.0.1 for the past couple
> days and have things passing almost all the tests (modulo some answer
> correction for changed format of networkx representations)
Thanks for your work: +1 on staying synchronized with networkx!
> The other big block of tests that don't pass are unpickling tests from
> sage/structure/sage_object.pyx
> I am wondering how big a problem this really is?
>
> Looking at some of the classes for some of the things it fails on
> (detailed at the bottom), it seems they use a graph object somewhere
> in the internals. I am guessing that since networkx removed the XGraph
> and XDiGraph objects somewhere between 0.36 (which is the version
> currently shipping with sage) and 1.0.1, the pickled objects can't
> find those classes and fail to unpickle. However, I don't know how to
> test that exactly, nor what to do about it (possibly patching networkx
> to do something when asked for those classes, loading up the up-to-
> date ones instead?)
A confirmation: dynkin diagrams inherit from DiGraph, and all crystals
point to a dynkin diagram. Similarly for posets. So if some type of
graphs don't unpickle, I am not surprised for all of this to fail.
The following command (to be run with Sage with the old networkx)
tells you what will happens upon later unpickling, say, a poset:
sage: P = Poset()
sage: explain_pickle(dumps(P))
pg_FinitePoset = unpickle_global('sage.combinat.posets.posets',
'FinitePoset')
si1 = unpickle_newobj(pg_FinitePoset, ())
pg_HasseDiagram = unpickle_global('sage.combinat.posets.hasse_diagram',
'HasseDiagram')
si2 = unpickle_newobj(pg_HasseDiagram, ())
pg_SparseGraphBackend = unpickle_global('sage.graphs.base.sparse_graph',
'SparseGraphBackend')
si3 = unpickle_newobj(pg_SparseGraphBackend, ())
pg_SparseGraph = unpickle_global('sage.graphs.base.sparse_graph',
'SparseGraph')
unpickle_build(si3, {'_cg_rev':pg_SparseGraph(0r, 16r, 10r, [], []),
'directed':True, 'vertex_labels':{}, '_multiple_edges':False, '_directed':True,
'_name':'', 'vertex_ints':{}, '_loops':False, 'edge_labels':{0r:None},
'_cg':pg_SparseGraph(0r, 16r, 10r, [], [])})
unpickle_build(si2, {'_weighted':False, '_pos':None, '_boundary':[],
'_latex_opts':None, '_backend':si3})
unpickle_build(si1, {'_hasse_diagram':si2, '_embedding':None,
'_convert_method_name':None, '_cdata':None, '_category':None, '_names':None,
'_generators':None, '_elements':[], '_hash':None, '_pickle_version':1r,
'_element_constructor':None, '_initial_convert_list':[],
'_element_init_pass_parent':False, '_initial_action_list':[],
'_initial_coerce_list':[], '_base':None})
si1
Then, you can just copy paste the commands in a Sage with the new
networkx, and see what breaks. Most likely it is the
SparseGraphBackend thing. If it's just a question of renamed class,
then you can add something along the following lines somewhere in the
graph code:
from sage.structure.sage_object import register_unpickle_override
register_unpickle_override('sage.graphs.base.sparse_graph','SparseGraphBackend',
<some function or class that will emulate
the previous thing>)
Cheers,
Nicolas
--
Nicolas M. ThiƩry "Isil" <[email protected]>
http://Nicolas.Thiery.name/
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org