Skip to content

Conversation

@gmou3
Copy link
Contributor

@gmou3 gmou3 commented Sep 25, 2024

When certificate is set to True, the method is_valid returns a tuple of a boolean and a dictionary.
The dictionary provides some more information in case the matroid is not valid.

Examples:

sage: M = matroids.catalog.Fano()
sage: M.is_valid()
True
sage: M.is_valid(certificate=True)
(True, {})

sage: C = [[1, 2, 3], [3, 4, 5]]
sage: M = Matroid(circuits=C)
sage: M.is_valid()
False
sage: M.is_valid(certificate=True)
(False,
 {'circuit 1': frozenset({3, 4, 5}),
  'circuit 2': frozenset({1, 2, 3}),
  'element': 3,
  'error': 'elimination axiom failed'})

To be done constistently with #38024.

@github-actions
Copy link

github-actions bot commented Sep 25, 2024

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

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 2, 2024

That's a nice addition, thanks.

Could it be a good idea to have an iterator that provides the errors?

@gmou3
Copy link
Contributor Author

gmou3 commented Oct 2, 2024

From my experience, one usually needs only one failure in order to unravel the invalidity and fix it.

Although it is possible that having all errors provides some utility, I think that would be marginal; one not worth the code complication.

@gmou3 gmou3 requested a review from tscrim October 28, 2024 13:24
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 Oct 30, 2024

Thanks!

@vbraun vbraun merged commit f4a1171 into sagemath:develop Nov 3, 2024
17 of 22 checks passed
@gmou3 gmou3 deleted the is_valid_certificate branch November 3, 2024 23:54
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