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
load
andsave
commands, 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 whichE
is the groundset of the matroid,R
is the rank,name
is a custom name, andBB
is 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
BinaryMatrix
object (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
load
andsave
commands, and you should never have to call this function directly.INPUT:
version
– an integer (currently 0).data
– a tuple(A, E, B, name)
whereA
is the representation matrix,E
is the groundset of the matroid,B
is the currently displayed basis, andname
is a custom name.OUTPUT:
A
BinaryMatroid
instance.
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
load
andsave
commands, and you should never have to call this function directly.INPUT:
version
– an integer, expected to be 0data
– a tuple(E, CC, name)
in whichE
is the groundset of the matroid,CC
is the dictionary of circuit closures, andname
is 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
load
andsave
commands, and you should never have to call this function directly.INPUT:
version
– an integer, expected to be 0data
– a tuple(M, name)
in whichM
is the internal matroid, andname
is 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
GenericMatrix
object (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
load
andsave
commands, 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
GraphicMatroid
instance.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
load
andsave
commands, and you should never have to call this function directly.INPUT:
version
– an integer (currently 0).data
– a tuple(A, E, reduced, name)
whereA
is the representation matrix,E
is the groundset of the matroid,reduced
is a boolean indicating whetherA
is a reduced matrix, andname
is a custom name.
OUTPUT:
A
LinearMatroid
instance.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
load
andsave
commands, and you should never have to call this function directly.INPUT:
version
– an integer, currently \(0\).data
– a tuple(M, C, D, name)
, whereM
is the original matroid of which the output is a minor,C
is the set of contractions,D
is the set of deletions, andname
is a custom name.
OUTPUT:
A
MinorMatroid
instance.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
PlusMinusOneMatrix
object (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
QuaternaryMatrix
object (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
load
andsave
commands, and you should never have to call this function directly.INPUT:
version
– an integer (currently 0).data
– a tuple(A, E, B, name)
whereA
is the representation matrix,E
is the groundset of the matroid,B
is the currently displayed basis, andname
is a custom name.
OUTPUT:
A
TernaryMatroid
instance.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_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
load
andsave
commands, and you should never have to call this function directly.INPUT:
version
– an integer (currently 0).data
– a tuple(A, E, reduced, name)
whereA
is the representation matrix,E
is the groundset of the matroid,reduced
is a boolean indicating whetherA
is a reduced matrix, andname
is a custom name.
OUTPUT:
A
RegularMatroid
instance.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
TernaryMatrix
object (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
load
andsave
commands, and you should never have to call this function directly.INPUT:
version
– an integer (currently 0).data
– a tuple(A, E, B, name)
whereA
is the representation matrix,E
is the groundset of the matroid,B
is the currently displayed basis, andname
is a custom name.
OUTPUT:
A
TernaryMatroid
instance.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