@@ -538,17 +538,42 @@ def Matroid(groundset=None, data=None, **kwds):
538538 input::
539539
540540 sage: M = matroids.catalog.Fano()
541- sage: A = M.representation(order=True, labels=True); A
542- (Generic morphism:
543- From: Free module generated by {'a', 'b', 'c', 'd', 'e', 'f', 'g'} over
544- Finite Field of size 2
545- To: Free module generated by {0, 1, 2} over Finite Field of size 2,
546- ['a', 'b', 'c', 'd', 'e', 'f', 'g'])
541+ sage: A = M.representation(order=True); A
542+ Generic morphism:
543+ From: Free module generated by {'a', 'b', 'c', 'd', 'e', 'f', 'g'} over
544+ Finite Field of size 2
545+ To: Free module generated by {0, 1, 2} over Finite Field of size 2
546+ sage: A._unicode_art_matrix()
547+ a b c d e f g
548+ 0⎛1 0 0 0 1 1 1⎞
549+ 1⎜0 1 0 1 0 1 1⎟
550+ 2⎝0 0 1 1 1 0 1⎠
547551 sage: N = Matroid(A); N
548552 Binary matroid of rank 3 on 7 elements, type (3, 0)
549553 sage: N.groundset()
550554 frozenset({'a', 'b', 'c', 'd', 'e', 'f', 'g'})
551- sage: M.is_isomorphic(N)
555+ sage: M == N
556+ True
557+
558+ The keywords `morphism` and `reduced_morphism` are also available::
559+
560+ sage: M = matroids.catalog.RelaxedNonFano("abcdefg")
561+ sage: A = M.representation(order=True, reduced=True); A
562+ Generic morphism:
563+ From: Free module generated by {'d', 'e', 'f', 'g'} over
564+ Finite Field in w of size 2^2
565+ To: Free module generated by {'a', 'b', 'c'} over
566+ Finite Field in w of size 2^2
567+ sage: A._unicode_art_matrix()
568+ d e f g
569+ a⎛1 1 0 1⎞
570+ b⎜1 0 1 1⎟
571+ c⎝0 1 w 1⎠
572+ sage: N = Matroid(reduced_morphism=A); N
573+ Quaternary matroid of rank 3 on 7 elements
574+ sage: N.groundset()
575+ frozenset({'a', 'b', 'c', 'd', 'e', 'f', 'g'})
576+ sage: M == N
552577 True
553578
554579 #. Rank function:
@@ -731,8 +756,8 @@ def Matroid(groundset=None, data=None, **kwds):
731756 if data is None :
732757 for k in ['bases' , 'independent_sets' , 'circuits' ,
733758 'nonspanning_circuits' , 'flats' , 'graph' , 'matrix' ,
734- 'reduced_matrix' , 'morphism' , 'rank_function' , 'revlex ' ,
735- 'circuit_closures' , 'matroid' ]:
759+ 'reduced_matrix' , 'morphism' , 'reduced_morphism ' ,
760+ 'rank_function' , 'revlex' , ' circuit_closures' , 'matroid' ]:
736761 if k in kwds :
737762 data = kwds .pop (k )
738763 key = k
@@ -752,7 +777,9 @@ def Matroid(groundset=None, data=None, **kwds):
752777 key = 'graph'
753778 elif is_Matrix (data ):
754779 key = 'matrix'
755- elif isinstance (data , sage .modules .with_basis .morphism .ModuleMorphism ) or isinstance (data , tuple ):
780+ elif isinstance (data , sage .modules .with_basis .morphism .ModuleMorphism ) or (
781+ isinstance (data , tuple ) and
782+ isinstance (data [0 ], sage .modules .with_basis .morphism .ModuleMorphism )):
756783 key = 'morphism'
757784 elif isinstance (data , sage .matroids .matroid .Matroid ):
758785 key = 'matroid'
@@ -876,15 +903,17 @@ def Matroid(groundset=None, data=None, **kwds):
876903 M = GraphicMatroid (G , groundset = groundset )
877904
878905 # Matrices:
879- elif key in ['matrix' , 'reduced_matrix' , 'morphism' ]:
906+ elif key in ['matrix' , 'reduced_matrix' , 'morphism' , 'reduced_morphism' ]:
880907 A = data
881- is_reduced = (key == 'reduced_matrix' )
882- if key == 'morphism' :
908+ is_reduced = (key == 'reduced_matrix' or key == 'reduced_morphism' )
909+ if key == 'morphism' or key == 'reduced_morphism' :
883910 if isinstance (data , tuple ):
884911 A = data [0 ]
885- groundset = data [1 ]
886- if isinstance (A , sage .modules .with_basis .morphism .ModuleMorphism ):
887- A = A .matrix ()
912+ if groundset is None :
913+ groundset = list (A .domain ().basis ().keys ())
914+ if is_reduced :
915+ groundset = list (A .codomain ().basis ().keys ()) + groundset
916+ A = A .matrix ()
888917
889918 # Fix the representation
890919 if not is_Matrix (A ):
0 commit comments