-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Add Oriented Matroids Package #38024
base: develop
Are you sure you want to change the base?
Conversation
The |
Documentation preview for this PR (built with commit 46c149c; changes) is ready! 🎉 |
Don't worry about that, it is some error of the tester. |
SageMath version 10.4.beta7, Release Date: 2024-05-25
""" | ||
if hasattr(self, "_circuits"): | ||
return self._circuits | ||
raise NotImplementedError("Circuits not implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend all Error
messages to start uncapitalized and end without a dot.
\mathcal{C} / A = \left\{ X\mid_{E \backslash A} : X \in \mathcal{C} \text{ and} A \subseteq X^0 \right\} | ||
|
||
""" | ||
# sage: from sage.matroids.oriented_matroids.oriented_matroid import OrientedMatroid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do something with this commented code?
|
||
AUTHORS: | ||
|
||
- Aram Dermenjian (): initial version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add date or complete/delete file.
@gmou3 I've gone ahead and fixed the things you wanted. |
Thanks. I had opened a PR a while ago with some formatting recommendations. Please have a look and merge or close it please. |
Some formatting recommendations
I hadn't noticed the pull request for some reason. I've added your changes as well and double checked things work nicely. Thanks for that. |
Ok, I've gone ahead and altered the code to use a class instead of a constructor. We'll make a different PR for doing the same to Matroids (Which I believe should be done as well) |
I can implement the corresponding changes for |
Have the desired changes been implemented according to @tscrim? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then, it also looks good to me.
Let's leave further work for future PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many things that need to be done before this can be included. Some of them are very important (all methods need doctests, even hidden and abstract ones); some of them are more minor (doc formatting I saw from checking the compiled doc); some are not necessary but trying to make the code within Sage more uniform.
""" | ||
Return the dual oriented matroid. | ||
EXAMPLES:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | |
Return the dual oriented matroid. | |
EXAMPLES:: | |
""" | |
Return the dual oriented matroid. | |
EXAMPLES:: |
You should add an example for the case when there is no dual. If no such case exists, then this should be an @abstract_method
(perhaps with optional=True
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that dual is not actually implemented yet. I had missed that an (incorrect) doctest was written by one of my mentees. I'll go ahead and fix this and see about adding code for making a dual.
r""" | ||
Return the underlying matroid. | ||
""" | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass |
Abstract methods also still need a doctest (from one of the concrete implementations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we're removing pass
here? I guess I'm not understanding when it should be used if it's not used in these circumstances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring actually does the same job as pass
, but by not having it, it suggests there is no implementation (rather than pass
which would simply do nothing).
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 sagemath#38024. URL: sagemath#38711 Reported by: gmou3 Reviewer(s): Travis Scrimshaw
Co-authored-by: Travis Scrimshaw <[email protected]>
Co-authored-by: Travis Scrimshaw <[email protected]>
Co-authored-by: Travis Scrimshaw <[email protected]>
Co-authored-by: Travis Scrimshaw <[email protected]>
Co-authored-by: Travis Scrimshaw <[email protected]>
Forgot to add a few code suggestions. Co-authored-by: Travis Scrimshaw <[email protected]>
@tscrim I'm trying to do sage: from sage.matroids.oriented_matroids.oriented_matroid import OrientedMatroid
sage: from sage.matroids.oriented_matroids.signed_subset_element import SignedSubsetElement
sage: from sage.cpython.type import can_assign_class
sage: M = OrientedMatroid([[1],[-1]], key='circuit');
sage: E = SignedSubsetElement(M,data = (0,))
sage: can_assign_class(E)
True
sage: TestSuite(E).run()
Failure in _test_category:
Traceback (most recent call last):
File "/sage/sagedev/src/sage/misc/sage_unittest.py", line 298, in run
test_method(tester=tester)
File "sage/structure/element.pyx", line 720, in sage.structure.element.Element._test_category
tester.assertTrue(isinstance(self, self.parent().category().element_class))
File "/usr/lib/python3.10/unittest/case.py", line 687, in assertTrue
raise self.failureException(msg)
AssertionError: False is not true
------------------------------------------------------------
The following tests failed: _test_category The To make life easier, here's the source for cpdef bint can_assign_class(obj) noexcept:
"""
Can we assign ``obj.__class__``?
Note that Python 3.5 has experimented with allowing assigning
``__class__`` in more cases but this was mostly reverted. In this
function, we apply the Python 2.7 semantics.
EXAMPLES::
sage: class X: pass
sage: from sage.cpython.type import can_assign_class
sage: can_assign_class(X())
True
sage: class Y(int): pass
sage: from sage.cpython.type import can_assign_class
sage: can_assign_class(Y())
True
sage: can_assign_class(1)
False
"""
cdef PyTypeObject* tp = Py_TYPE(obj)
if tp is PyInstance_Type:
return True
return (tp.tp_flags & Py_TPFLAGS_HEAPTYPE) != 0 |
It’s failing as it should because it doesn’t have a proper parent set. From what I can quickly see, it isn’t being used as an element in a set but a more generic helper object. So I would remove the inheritance from |
This pull request merges the Oriented Matroids package that I developed (see https://github.com/thecaligarmo/oriented_matroids) into Sage so that others may develop directly into it rather than relying solely on myself.
This package should resolve ticket #18703 and in addition, my package should be removed from #31164 as this pull request will put Oriented Matroids directly into Sage rather than requiring a package.
If there are any changes needing to be made, just let me know and we can go from there.
📝 Checklist
⌛ Dependencies