Unpickling methods¶
Python saves objects by providing a pair (f, data) such that f(data)
reconstructs the object. This module collects the loading (_unpickling_ in
Python terminology) functions for Sage’s matroids.
Note
The reason this code was separated out from the classes was to make it
play nice with lazy importing of the Matroid() and matroids
keywords.
AUTHORS:
Rudi Pendavingh, Stefan van Zwam (2013-07-01): initial version
- sage.matroids.unpickling.unpickle_basis_matroid(version, data)¶
Unpickle a BasisMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer, expected to be 0data– a tuple(E, R, name, BB)in whichEis the groundset of the matroid,Ris the rank,nameis a custom name, andBBis the bitpacked list of bases, as pickled by Sage’sbitset_pickle.
OUTPUT:
A matroid.
Warning
Users should never call this function directly.
EXAMPLES:
sage: from sage.matroids.advanced import * sage: M = BasisMatroid(matroids.named_matroids.Vamos()) sage: M == loads(dumps(M)) # indirect doctest True
- sage.matroids.unpickling.unpickle_binary_matrix(version, data)¶
Reconstruct a
BinaryMatrixobject (internal Sage data structure).Warning
Users should not call this method directly.
EXAMPLES:
sage: from sage.matroids.lean_matrix import * sage: A = BinaryMatrix(2, 5) sage: A == loads(dumps(A)) # indirect doctest True sage: C = BinaryMatrix(2, 2, Matrix(GF(2), [[1, 1], [0, 1]])) sage: C == loads(dumps(C)) True
- sage.matroids.unpickling.unpickle_binary_matroid(version, data)¶
Unpickle a BinaryMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer (currently 0).data– a tuple(A, E, B, name)whereAis the representation matrix,Eis the groundset of the matroid,Bis the currently displayed basis, andnameis a custom name.OUTPUT:
A
BinaryMatroidinstance.
Warning
Users should never call this function directly.
EXAMPLES:
sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1], [0, 1, 0, 1], ....: [0, 0, 1, 1]])) sage: M == loads(dumps(M)) # indirect doctest True sage: M.rename("U34") sage: loads(dumps(M)) U34
- sage.matroids.unpickling.unpickle_circuit_closures_matroid(version, data)¶
Unpickle a CircuitClosuresMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer, expected to be 0data– a tuple(E, CC, name)in whichEis the groundset of the matroid,CCis the dictionary of circuit closures, andnameis a custom name.
OUTPUT:
A matroid.
Warning
Users should never call this function directly.
EXAMPLES:
sage: M = matroids.named_matroids.Vamos() sage: M == loads(dumps(M)) # indirect doctest True
- sage.matroids.unpickling.unpickle_dual_matroid(version, data)¶
Unpickle a DualMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer, expected to be 0data– a tuple(M, name)in whichMis the internal matroid, andnameis a custom name.
OUTPUT:
A matroid.
Warning
Users should not call this function directly. Instead, use load/save.
EXAMPLES:
sage: M = matroids.named_matroids.Vamos().dual() sage: M == loads(dumps(M)) # indirect doctest True
- sage.matroids.unpickling.unpickle_generic_matrix(version, data)¶
Reconstruct a
GenericMatrixobject (internal Sage data structure).Warning
Users should not call this method directly.
EXAMPLES:
sage: from sage.matroids.lean_matrix import * sage: A = GenericMatrix(2, 5, ring=QQ) sage: A == loads(dumps(A)) # indirect doctest True
- sage.matroids.unpickling.unpickle_graphic_matroid(version, data)¶
Unpickle a GraphicMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer (currently 0).data– a tuple consisting of a SageMath graph and a name.
OUTPUT:
A
GraphicMatroidinstance.Warning
Users should never call this function directly.
EXAMPLES:
sage: M = Matroid(graphs.DiamondGraph()) sage: M == loads(dumps(M)) True
- sage.matroids.unpickling.unpickle_linear_matroid(version, data)¶
Unpickle a LinearMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer (currently 0).data– a tuple(A, E, reduced, name)whereAis the representation matrix,Eis the groundset of the matroid,reducedis a boolean indicating whetherAis a reduced matrix, andnameis a custom name.
OUTPUT:
A
LinearMatroidinstance.Warning
Users should never call this function directly.
EXAMPLES:
sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], ....: [0, 1, 1, 1, 3]])) sage: M == loads(dumps(M)) # indirect doctest True sage: M.rename("U35") sage: loads(dumps(M)) U35
- sage.matroids.unpickling.unpickle_minor_matroid(version, data)¶
Unpickle a MinorMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer, currently \(0\).data– a tuple(M, C, D, name), whereMis the original matroid of which the output is a minor,Cis the set of contractions,Dis the set of deletions, andnameis a custom name.
OUTPUT:
A
MinorMatroidinstance.Warning
Users should never call this function directly.
EXAMPLES:
sage: M = matroids.named_matroids.Vamos().minor('abc', 'g') sage: M == loads(dumps(M)) # indirect doctest True
- sage.matroids.unpickling.unpickle_plus_minus_one_matrix(version, data)¶
Reconstruct an
PlusMinusOneMatrixobject (internal Sage data structure).Warning
Users should not call this method directly.
EXAMPLES:
sage: from sage.matroids.lean_matrix import * sage: A = PlusMinusOneMatrix(2, 5) sage: A == loads(dumps(A)) # indirect doctest True
- sage.matroids.unpickling.unpickle_quaternary_matrix(version, data)¶
Reconstruct a
QuaternaryMatrixobject (internal Sage data structure).Warning
Users should not call this method directly.
EXAMPLES:
sage: from sage.matroids.lean_matrix import * sage: A = QuaternaryMatrix(2, 5, ring=GF(4, 'x')) sage: A == loads(dumps(A)) # indirect doctest True sage: C = QuaternaryMatrix(2, 2, Matrix(GF(4, 'x'), [[1, 1], [0, 1]])) sage: C == loads(dumps(C)) True
- sage.matroids.unpickling.unpickle_quaternary_matroid(version, data)¶
Unpickle a QuaternaryMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer (currently 0).data– a tuple(A, E, B, name)whereAis the representation matrix,Eis the groundset of the matroid,Bis the currently displayed basis, andnameis a custom name.
OUTPUT:
A
TernaryMatroidinstance.Warning
Users should never call this function directly.
EXAMPLES:
sage: from sage.matroids.advanced import * sage: M = QuaternaryMatroid(Matrix(GF(3), [[1, 0, 0, 1], [0, 1, 0, 1], ....: [0, 0, 1, 1]])) sage: M == loads(dumps(M)) # indirect doctest True sage: M.rename("U34") sage: loads(dumps(M)) U34 sage: M = QuaternaryMatroid(Matrix(GF(4, 'x'), [[1, 0, 1], ....: [1, 0, 1]])) sage: loads(dumps(M)).representation() [1 0 1] [1 0 1]
- sage.matroids.unpickling.unpickle_rational_matrix(version, data)¶
Reconstruct a
sage.matroids.lean_matrix.RationalMatrixobject (internal Sage data structure).Warning
Users should not call this method directly.
EXAMPLES:
sage: from sage.matroids.lean_matrix import RationalMatrix sage: A = RationalMatrix(2, 5) sage: A == loads(dumps(A)) # indirect doctest True
- sage.matroids.unpickling.unpickle_regular_matroid(version, data)¶
Unpickle a RegularMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer (currently 0).data– a tuple(A, E, reduced, name)whereAis the representation matrix,Eis the groundset of the matroid,reducedis a boolean indicating whetherAis a reduced matrix, andnameis a custom name.
OUTPUT:
A
RegularMatroidinstance.Warning
Users should never call this function directly.
EXAMPLES:
sage: M = matroids.named_matroids.R10() sage: M == loads(dumps(M)) # indirect doctest True sage: M.rename("R_{10}") sage: loads(dumps(M)) R_{10}
- sage.matroids.unpickling.unpickle_ternary_matrix(version, data)¶
Reconstruct a
TernaryMatrixobject (internal Sage data structure).Warning
Users should not call this method directly.
EXAMPLES:
sage: from sage.matroids.lean_matrix import * sage: A = TernaryMatrix(2, 5) sage: A == loads(dumps(A)) # indirect doctest True sage: C = TernaryMatrix(2, 2, Matrix(GF(3), [[1, 1], [0, 1]])) sage: C == loads(dumps(C)) True
- sage.matroids.unpickling.unpickle_ternary_matroid(version, data)¶
Unpickle a TernaryMatroid.
Pickling is Python’s term for the loading and saving of objects. Functions like these serve to reconstruct a saved object. This all happens transparently through the
loadandsavecommands, and you should never have to call this function directly.INPUT:
version– an integer (currently 0).data– a tuple(A, E, B, name)whereAis the representation matrix,Eis the groundset of the matroid,Bis the currently displayed basis, andnameis a custom name.
OUTPUT:
A
TernaryMatroidinstance.Warning
Users should never call this function directly.
EXAMPLES:
sage: from sage.matroids.advanced import * sage: M = TernaryMatroid(Matrix(GF(3), [[1, 0, 0, 1], [0, 1, 0, 1], ....: [0, 0, 1, 1]])) sage: M == loads(dumps(M)) # indirect doctest True sage: M.rename("U34") sage: loads(dumps(M)) U34