Skip to content

FlatsMatroid: improve validity check #39563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 25, 2025
Merged

Conversation

gmou3
Copy link
Contributor

@gmou3 gmou3 commented Feb 22, 2025

More robust and faster is_valid method. Also, more efficient initialization when an iterable of flats is given.

A speed test with ~25% speedup:

sage: from sage.matroids.flats_matroid import FlatsMatroid
sage: M = FlatsMatroid(matroids.CompleteGraphic(8))
sage: %timeit M.is_valid()

Includes minor refactoring in CircuitsMatroid class.

Copy link

github-actions bot commented Feb 22, 2025

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

@gmou3 gmou3 requested a review from tscrim June 13, 2025 11:15
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 modulo the one possible improvement.

Use `len`.

Co-authored-by: Travis Scrimshaw <clfrngrown@aol.com>
@gmou3
Copy link
Contributor Author

gmou3 commented Jun 16, 2025

Change applied. Thank you for the review!

vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 18, 2025
sagemathgh-39563: `FlatsMatroid`: improve validity check
    
More robust and faster `is_valid` method. Also, more efficient
initialization when an iterable of flats is given.

A speed test with ~25% speedup:
```
sage: from sage.matroids.flats_matroid import FlatsMatroid
sage: M = FlatsMatroid(matroids.CompleteGraphic(8))
sage: %timeit M.is_valid()
```

Includes minor refactoring in `CircuitsMatroid` class.
    
URL: sagemath#39563
Reported by: gmou3
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 21, 2025
sagemathgh-39563: `FlatsMatroid`: improve validity check
    
More robust and faster `is_valid` method. Also, more efficient
initialization when an iterable of flats is given.

A speed test with ~25% speedup:
```
sage: from sage.matroids.flats_matroid import FlatsMatroid
sage: M = FlatsMatroid(matroids.CompleteGraphic(8))
sage: %timeit M.is_valid()
```

Includes minor refactoring in `CircuitsMatroid` class.
    
URL: sagemath#39563
Reported by: gmou3
Reviewer(s): Travis Scrimshaw
@vbraun vbraun merged commit e647b9a into sagemath:develop Jun 25, 2025
20 of 24 checks passed
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.

3 participants