Skip to content

Conversation

@gmou3
Copy link
Contributor

@gmou3 gmou3 commented May 5, 2024

This follows the merging of #37692 and it enables the (re-)feeding of a linear matroid's morphism representation into the Matroid constructor.

Example:

sage: M = matroids.catalog.Fano()
sage: A = M.representation(order=True); A
Generic morphism:
  From: Free module generated by {'a', 'b', 'c', 'd', 'e', 'f', 'g'} over Finite Field of size 2
  To:   Free module generated by {0, 1, 2} over Finite Field of size 2
sage: Matroid(A)
Binary matroid of rank 3 on 7 elements, type (3, 0)

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@gmou3
Copy link
Contributor Author

gmou3 commented May 6, 2024

Thanks!

@mkoeppe you may wish to have a look.

@gmou3 gmou3 force-pushed the matroid_morphism branch from e6e9bab to 796dd16 Compare May 6, 2024 23:43
elif is_Matrix(data):
key = 'matrix'
elif isinstance(data, sage.modules.with_basis.morphism.ModuleMorphism) or (
isinstance(data, tuple) and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I find "tuple" input very convincing.
Does it have a clear benefit over just passing the groundset via the groundset parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I did this is so that the following works:

sage: M = matroids.catalog.Fano()
sage: A = M.representation(order=True, labels=True)
sage: Matroid(A)
...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to do something similar for matrices though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it so that this also works and retains the groundset labels:

sage: M = matroids.catalog.Fano()
sage: A = M.representation(labels=True)
sage: Matroid(A)
...

key = 'graph'
elif is_Matrix(data):
key = 'matrix'
elif isinstance(data, sage.modules.with_basis.morphism.ModuleMorphism) or (
Copy link
Contributor

@mkoeppe mkoeppe May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of using isinstance with this class, I think it's better to use isinstance(data, Morphism) and data.category_for().is_subcategory(Modules(data.base_ring()).WithBasis())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's best but the above doesn't seem to work.

@gmou3 gmou3 force-pushed the matroid_morphism branch from 49ad4fb to 0ca6cd8 Compare May 7, 2024 01:07
@gmou3 gmou3 force-pushed the matroid_morphism branch from 0ca6cd8 to 13e499a Compare May 7, 2024 01:15
@mkoeppe
Copy link
Contributor

mkoeppe commented May 7, 2024

LGTM, thanks!

@github-actions
Copy link

github-actions bot commented May 8, 2024

Documentation preview for this PR (built with commit 13e499a; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

vbraun pushed a commit to vbraun/sage that referenced this pull request May 9, 2024
sagemathgh-37940: Support morphisms in `Matroid` constructor
    
This follows the merging of sagemath#37692 and it enables the (re-)feeding of a
linear matroid's morphism representation into the `Matroid` constructor.

Example:
```
sage: M = matroids.catalog.Fano()
sage: A = M.representation(order=True); A
Generic morphism:
  From: Free module generated by {'a', 'b', 'c', 'd', 'e', 'f', 'g'}
over Finite Field of size 2
  To:   Free module generated by {0, 1, 2} over Finite Field of size 2
sage: Matroid(A)
Binary matroid of rank 3 on 7 elements, type (3, 0)
```
    
URL: sagemath#37940
Reported by: gmou3
Reviewer(s): gmou3, Matthias Köppe, Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request May 11, 2024
sagemathgh-37940: Support morphisms in `Matroid` constructor
    
This follows the merging of sagemath#37692 and it enables the (re-)feeding of a
linear matroid's morphism representation into the `Matroid` constructor.

Example:
```
sage: M = matroids.catalog.Fano()
sage: A = M.representation(order=True); A
Generic morphism:
  From: Free module generated by {'a', 'b', 'c', 'd', 'e', 'f', 'g'}
over Finite Field of size 2
  To:   Free module generated by {0, 1, 2} over Finite Field of size 2
sage: Matroid(A)
Binary matroid of rank 3 on 7 elements, type (3, 0)
```
    
URL: sagemath#37940
Reported by: gmou3
Reviewer(s): gmou3, Matthias Köppe, Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request May 12, 2024
sagemathgh-37940: Support morphisms in `Matroid` constructor
    
This follows the merging of sagemath#37692 and it enables the (re-)feeding of a
linear matroid's morphism representation into the `Matroid` constructor.

Example:
```
sage: M = matroids.catalog.Fano()
sage: A = M.representation(order=True); A
Generic morphism:
  From: Free module generated by {'a', 'b', 'c', 'd', 'e', 'f', 'g'}
over Finite Field of size 2
  To:   Free module generated by {0, 1, 2} over Finite Field of size 2
sage: Matroid(A)
Binary matroid of rank 3 on 7 elements, type (3, 0)
```
    
URL: sagemath#37940
Reported by: gmou3
Reviewer(s): gmou3, Matthias Köppe, Travis Scrimshaw
@vbraun vbraun merged commit 3fdc4d2 into sagemath:develop May 12, 2024
@gmou3 gmou3 deleted the matroid_morphism branch May 25, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants