Open jcuevas-rozo opened 4 years ago
I have added the file finite_topological_spaces.py in ~/sage/src/sage/homology. I think this is a correct place to put it because different methods dealing with homotopy types and weak homotopy types will be added in next commits, but the discussion is open and I accept other suggestions in order to put it in the correct place.
New commits:
f1045db | FiniteTopologicalSpace class and methods in general topology added |
Commit: f1045db
Branch pushed to git repo; I updated commit sha1. New commits:
1cbdd3f | Documentation added |
Description changed:
---
+++
@@ -1,3 +1,3 @@
-This ticket provides a class for finite topological spaces and methods dealing with properties in general topology. It is expected to create a second ticket to add algebraic topology properties.
+This ticket provides a class for finite topological spaces and methods dealing with properties in general topology. It is expected to create a second ticket to add algebraic topology properties (see ticket #30447).
Principal reference: [Algebraic topology of finite topological spaces and applications](https://www.maths.ed.ac.uk/~v1ranick/papers/barmak2.pdf) by [Jonathan Barmak](https://mate.dm.uba.ar/~jbarmak/).
I have changed the status to needs_review. I have created a ticket #30447 where I will continue to working about the changes made in this ticket #30400, but... how can I import such changes to the new ticket? (how to link #30447 to #30400?)
Add #30400 in the dependency field on #30447. (I've done that.)
Thank you so much, I've learned it for next tickets.
Branch pushed to git repo; I updated commit sha1. New commits:
e51800d | Failures in tests repaired |
I'm getting some doctest failures. Also, it would be nice to add this to the reference manual. Here are changes to fix some of these:
diff --git a/src/doc/en/reference/homology/index.rst b/src/doc/en/reference/homology/index.rst
index bf98e0841f..148dc4bae0 100644
--- a/src/doc/en/reference/homology/index.rst
+++ b/src/doc/en/reference/homology/index.rst
@@ -35,6 +35,7 @@ cell complexes.
sage/homology/algebraic_topological_model
sage/homology/homology_morphism
sage/homology/matrix_utils
+ sage/homology/finite_topological_spaces
sage/interfaces/chomp
.. include:: ../footer.txt
diff --git a/src/sage/homology/finite_topological_spaces.py b/src/sage/homology/finite_topological_spaces.py
index 3a43eabed4..430e2a84ad 100644
--- a/src/sage/homology/finite_topological_spaces.py
+++ b/src/sage/homology/finite_topological_spaces.py
@@ -72,6 +72,7 @@ from sage.combinat.posets.hasse_diagram import HasseDiagram
def dict_to_matrix(ordered_eltos, dictionary):
r"""
Return a matrix from the information given by ``dictionary``.
+
INPUT:
- ``ordered_eltos`` -- a list.
@@ -79,7 +80,7 @@ def dict_to_matrix(ordered_eltos, dictionary):
- ``dictionary`` -- a dict whose key list is ``ordered_eltos`` and its values
are sets of elements in ``ordered_eltos``.
- OUTPUT::
+ OUTPUT:
- A binary matrix whose `(i,j)` entry is equal to 1 if and only if ``ordered_eltos[i]``
is in ``dictionary[ordered_eltos[j]]``.
@@ -124,7 +125,7 @@ def FiniteSpace(data, elements=None, is_T0=False):
- ``elements`` -- it is ignored when data is of type 1, 2 or 4. When ``data``
is a topogenous matrix, this parameter gives the underlying set of the space.
- EXAMPLES::
+ EXAMPLES:
A dictionary as ``data``::
@@ -135,16 +136,16 @@ def FiniteSpace(data, elements=None, is_T0=False):
sage: type(T)
<class 'sage.homology.finite_topological_spaces.FiniteTopologicalSpace'>
sage: FiniteSpace({'a': {'a', 'b'}})
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
ValueError: The data does not correspond to a valid dictionary
sage: FiniteSpace({'a': {'a', 'b'}, 'b': {'a', 'b'}, 'c': {'a', 'c'}})
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
ValueError: The introduced data does not define a topology
When ``data`` is a tuple or a list, the elements are in ``range(n)`` where
- ``n`` is the lenght of ``data``::
+ ``n`` is the length of ``data``::
sage: from sage.homology.finite_topological_spaces import FiniteSpace
sage: T = FiniteSpace([{0, 3}, {1, 3}, {2, 3}, {3}]) ; T
@@ -155,7 +156,7 @@ def FiniteSpace(data, elements=None, is_T0=False):
sage: T.elements()
[3, 0, 1, 2]
sage: FiniteSpace(({0, 2}, {0, 2}))
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
ValueError: This kind of data assume the elements are in range(2)
@@ -182,7 +183,7 @@ def FiniteSpace(data, elements=None, is_T0=False):
sage: M.elements()
[5, 'e', 'h', 0, 'c']
sage: FiniteSpace(mat, elements=[5, 'e', 'h', 0, 0])
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
AssertionError: Not valid list of elements
@@ -386,6 +387,7 @@ class FiniteTopologicalSpace(Parent):
sage: from sage.homology.finite_topological_spaces import FiniteSpace
sage: T = FiniteSpace(({0}, {1}, {2, 3}, {3}))
sage: T.underlying_set()
+ {0, 1, 2, 3}
"""
return set(self._elements)
@@ -474,7 +476,7 @@ class FiniteTopologicalSpace(Parent):
sage: T.Ux(4)
{3, 4}
sage: T.Ux(5)
- Traceback (most recent call last)
+ Traceback (most recent call last):
...
ValueError: The point 5 is not an element of the space
"""
@@ -787,7 +789,7 @@ class FiniteTopologicalSpace(Parent):
True
sage: T.boundary(T.boundary(Fr)) == T.boundary(Fr)
True
- sage: X == Fr.union(T.interior(E), T.exterior(E))|||
+ sage: X == Fr.union(T.interior(E), T.exterior(E))
True
"""
X = self.underlying_set()
I get sporadic doctest failures:
sage -t --warn-long 80.8 --random-seed=0 src/sage/homology/finite_topological_spaces.py
**********************************************************************
File "src/sage/homology/finite_topological_spaces.py", line 133, in sage.homology.finite_topological_spaces.FiniteSpace
Failed example:
T = FiniteSpace({'a': {'a', 'c'}, 'b': {'b'}, 'c':{'a', 'c'}}) ; T
Expected:
Finite topological space of 3 points with minimal basis
{'a': {'c', 'a'}, 'b': {'b'}, 'c': {'c', 'a'}}
Got:
Finite topological space of 3 points with minimal basis
{'a': {'a', 'c'}, 'b': {'b'}, 'c': {'a', 'c'}}
**********************************************************************
File "src/sage/homology/finite_topological_spaces.py", line 180, in sage.homology.finite_topological_spaces.FiniteSpace
Failed example:
M = FiniteSpace(mat, elements=(5, 'e', 'h', 0, 'c')) ; M
Expected:
Finite topological space of 5 points with minimal basis
{5: {5}, 'e': {'h', 'e'}, 'h': {'h', 'e'}, 0: {0, 'c', 5}, 'c': {0, 'c', 5}}
Got:
Finite topological space of 5 points with minimal basis
{5: {5}, 'e': {'e', 'h'}, 'h': {'e', 'h'}, 0: {0, 'c', 5}, 'c': {0, 'c', 5}}
**********************************************************************
File "src/sage/homology/finite_topological_spaces.py", line 319, in sage.homology.finite_topological_spaces.FiniteTopologicalSpace.__init__
Failed example:
T = FiniteTopologicalSpace(elements, minimal_basis, matrix(mat_dict)) ; T
Expected:
Finite topological space of 4 points with minimal basis
{'a': {3, 'a'}, 3: {3, 'a'}, 2: {1, 2}, 1: {1}}
Got:
Finite topological space of 4 points with minimal basis
{'a': {'a', 3}, 3: {'a', 3}, 2: {1, 2}, 1: {1}}
**********************************************************************
2 items had failures:
2 of 24 in sage.homology.finite_topological_spaces.FiniteSpace
1 of 7 in sage.homology.finite_topological_spaces.FiniteTopologicalSpace.__init__
[231 tests, 3 failures, 0.13 s]
----------------------------------------------------------------------
sage -t --warn-long 80.8 --random-seed=0 src/sage/homology/finite_topological_spaces.py # 3 doctests failed
----------------------------------------------------------------------
The issue is that these sets may print in different orders, and I think it's more or less random.
By the way, it's better to say if E is None
instead of if E == None
.
New commits:
e51800d | Failures in tests repaired |
Branch pushed to git repo; I updated commit sha1. New commits:
7b77787 | Failure tests repaired |
Branch pushed to git repo; I updated commit sha1. New commits:
124dc44 | Repairing failures shown in comment 10 from jhpalmieri |
Replying to @jhpalmieri:
I'm getting some doctest failures. Also, it would be nice to add this to the reference manual. Here are changes to fix some of these:
Thanks for the suggestions, I have changed the files in order to include the improvements.
The issue is that these sets may print in different orders, and I think it's more or less random.
I see... I think it depends on the implementation of sets in SageMath, do I have to impose an specific order for printing or it is not necessary?
Doctests have to pass, so something has to change. Here are suggestions, but if you can think of meaningful doctests that don't rely on the ordering (one example is the test T._minimal_basis['a'] == ...
below), it's better than just marking everything # random
.
diff --git a/src/sage/homology/finite_topological_spaces.py b/src/sage/homology/finite_topological_spaces.py
index 5c40fe26ce..548322f174 100644
--- a/src/sage/homology/finite_topological_spaces.py
+++ b/src/sage/homology/finite_topological_spaces.py
@@ -127,9 +127,14 @@ def FiniteSpace(data, elements=None, is_T0=False):
A dictionary as ``data``::
sage: from sage.homology.finite_topological_spaces import FiniteSpace
- sage: T = FiniteSpace({'a': {'a', 'c'}, 'b': {'b'}, 'c':{'a', 'c'}}) ; T
+ sage: T = FiniteSpace({'a': {'a', 'c'}, 'b': {'b'}, 'c':{'a', 'c'}})
+ sage: T # random
Finite topological space of 3 points with minimal basis
{'a': {'c', 'a'}, 'b': {'b'}, 'c': {'c', 'a'}}
+ sage: T._minimal_basis # random
+ {'a': {'c', 'a'}, 'b': {'b'}, 'c': {'c', 'a'}}
+ sage: T._minimal_basis['a'] == set(['a', 'c'])
+ True
sage: type(T)
<class 'sage.homology.finite_topological_spaces.FiniteTopologicalSpace'>
sage: FiniteSpace({'a': {'a', 'b'}})
@@ -174,7 +179,8 @@ def FiniteSpace(data, elements=None, is_T0=False):
{0: {0}, 1: {1, 2}, 2: {1, 2}, 3: {0, 3, 4}, 4: {0, 3, 4}}
sage: T.elements()
[0, 1, 2, 3, 4]
- sage: M = FiniteSpace(mat, elements=(5, 'e', 'h', 0, 'c')) ; M
+ sage: M = FiniteSpace(mat, elements=(5, 'e', 'h', 0, 'c'))
+ sage: M # random
Finite topological space of 5 points with minimal basis
{5: {5}, 'e': {'h', 'e'}, 'h': {'h', 'e'}, 0: {0, 'c', 5}, 'c': {0, 'c', 5}}
sage: M.elements()
@@ -313,7 +319,8 @@ class FiniteTopologicalSpace(Parent):
sage: minimal_basis = {'a': {3, 'a'}, 3: {3, 'a'}, 2: {2, 1}, 1: {1}}
sage: mat_dict = {(0, 0): 1, (0, 1): 1, (1, 1): 1, (2, 2): 1, \
....: (2, 3): 1, (3, 2): 1, (3, 3): 1}
- sage: T = FiniteTopologicalSpace(elements, minimal_basis, matrix(mat_dict)) ; T
+ sage: T = FiniteTopologicalSpace(elements, minimal_basis, matrix(mat_dict))
+ sage: T # random
Finite topological space of 4 points with minimal basis
{'a': {3, 'a'}, 3: {3, 'a'}, 2: {1, 2}, 1: {1}}
sage: T.topogenous_matrix() == matrix(mat_dict)
@@ -325,7 +332,7 @@ class FiniteTopologicalSpace(Parent):
self._minimal_basis = minimal_basis
self._topogenous = topogenous
- def __repr__(self):
+ def _repr_(self):
r"""
Print representation.
@@ -1012,7 +1019,7 @@ class FiniteTopologicalSpace_T0(FiniteTopologicalSpace):
self._poset = poset
self._T0 = True
- def __repr__(self):
+ def _repr_(self):
r"""
Print representation.
By the way, for classes which inherit from SageObject
, like Parent
, it is better to define _repr_
rather than __repr__
. See https://doc.sagemath.org/html/en/developer/coding_in_python.html#print-representation.
More suggestions:
diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst
index c58f1acbb9..96157140c4 100644
--- a/src/doc/en/reference/references/index.rst
+++ b/src/doc/en/reference/references/index.rst
@@ -181,6 +181,8 @@ REFERENCES:
of the Slovak Academy of Sciences. Mathematica Slovaca vol 30, n 4,
pages 405--417, 1980
+.. [Ale1937] \P. Alexandroff, *Diskrete Raume*, Mat. Sb. (N.S.) 2, 501--518 (1937).
+
.. [Al1947] \A. A. Albert, *A Structure Theory for Jordan
Algebras*. Annals of Mathematics, Second Series, Vol. 48,
No. 3 (Jul., 1947), pp. 546--567.
@@ -373,6 +375,10 @@ REFERENCES:
Four Russians'. Cryptography E-Print Archive
(http://eprint.iacr.org/2006/251.pdf), 2006.
+.. [Bar2011] \J. A. Barmak,
+ *Algebraic topology of finite topological spaces and applications*.
+ Lecture Notes in Mathematics Vol. 2032 (2011).
+
.. [Bat1991] \V. V. Batyrev, *On the classification of smooth projective
toric varieties*, Tohoku Math. J. **43** (1991), 569-585
@@ -4880,6 +4886,9 @@ REFERENCES:
*Generation of random chordal graphs using subtrees of a tree*,
:arxiv:`1810.13326v1`.
+.. [Shi1968] \M. Shiraki, *On finite topological spaces*,
+ Rep. Fac. Sci. Kagoshima Univ. 1, 1--8 (1968).
+
.. [Shi2002] \M. Shimozono
*Affine type A crystal structure on tensor products of rectangles,
Demazure characters, and nilpotent varieties*,
diff --git a/src/sage/homology/finite_topological_spaces.py b/src/sage/homology/finite_topological_spaces.py
index 5c40fe26ce..c01c344ca2 100644
--- a/src/sage/homology/finite_topological_spaces.py
+++ b/src/sage/homology/finite_topological_spaces.py
@@ -7,11 +7,11 @@ A *finite topological space* is a topological space with finitely many points an
a *finite preordered set* is a finite set with a transitive and reflexive relation.
Finite spaces and finite preordered sets are basically the same objects considered
from different perspectives. Given a finite topological space `X`, for every point
-`x\in X` the *minimal open set* `U_x` as the intersection of all the open sets
+`x\in X`, define the *minimal open set* `U_x` as the intersection of all the open sets
which contain `x` (it is an open set since arbitrary intersections of open sets
in finite spaces are open). The minimal open sets constitute a basis for the topology
of `X`. Indeed, any open set `U` of `X` is the union of the sets `U_x` with `x\in U`.
-This basis is called the *minimal basis of `X`*. A preorder on `X` by `x\leqslant y`
+This basis is called the *minimal basis of* `X`. A preorder on `X` is given by `x\leqslant y`
if `x\in U_y`.
If `X` is now a finite preordered set, one can define a topology on `X` given by
@@ -20,21 +20,21 @@ then `y` is contained in every basic set containing `x`, and therefore `y\in U_x
Conversely, if `y\in U_x`, then `y\in\lbrace z\in X\vert z\leqslant x\rbrace`.
Therefore `y\leqslant x` if and only if `y\in U_x`. This shows that these two
applications, relating topologies and preorders on a finite set, are mutually
-inverse. This simple remark, made in first place by Alexandroff [1], allows us to study
+inverse. This simple remark, made in first place by Alexandroff [Ale1937]_, allows us to study
finite spaces by combining Algebraic Topology with the combinatorics arising from
their intrinsic preorder structures. The antisymmetry of a finite preorder
corresponds exactly to the `T_0` separation axiom. Recall that a topological space
-`X` is said to be *`T_0`* if for any pair of points in `X` there exists an open
+`X` is said to be `T_0` if for any pair of points in `X` there exists an open
set containing one and only one of them. Therefore finite `T_0`-spaces are in
-correspondence with finite partially ordered sets (posets) [2].
+correspondence with finite partially ordered sets (posets) [Bar2011]_.
Now, if `X = \lbrace x_1, x_2, \ldots , x_n\rbrace` is a finite space and for
each `i` the unique minimal open set containing `x_i` is denoted by `U_i`, a
-*topogenous matrix* of the space is a `n \times n` matrix `A = \left[a_{ij}\right]`
+*topogenous matrix* of the space is the `n \times n` matrix `A = \left[a_{ij}\right]`
defined by `a_{ij} = 1` if `x_i \in U_j` and `a_{ij} = 0` otherwise (this is the
-transposed matrix of the Definition 1 in [3]). A finite space `X` is `T_0` if and
+transposed matrix of the Definition 1 in [Shi1968]_). A finite space `X` is `T_0` if and
only if the topogenous matrix `A` defined above is similar (via a permutation matrix)
-to a certain upper triangular matrix [3]. This is the reason one can assume that
+to a certain upper triangular matrix [Shi1968]_. This is the reason one can assume that
the topogenous matrix of a finite `T_0`-space is upper triangular.
@@ -44,11 +44,9 @@ AUTHOR::
REFERENCES:
-- [1] Alexandroff P., *Diskrete Raume*, Mat. Sb. (N.S.) 2, 501--518 (1937).
-- [2] Barmak, J.A., *Algebraic topology of finite topological spaces and applications*.
- Lecture Notes in Mathematics Vol. 2032 (2011).
-- [3] Shiraki M., *On finite topological spaces*, Rep. Fac. Sci. Kagoshima Univ.
- 1, 1--8 (1968).
+- [Ale1937]_
+- [Bar2011]_
+- [Shi1968]_
"""
# ****************************************************************************
@@ -559,12 +564,12 @@ class FiniteTopologicalSpace(Parent):
...
ValueError: Parameter 'points' is not a valid set of representatives
"""
- if self._T0==True:
+ if self._T0 is True:
return self
else:
if points is None:
points = [list(A)[0] for A in self._T0]
- elif check==True:
+ elif check:
assert isinstance(points, (tuple, list, set)), \
"Parameter 'points' must be of type tuple, list or set"
assert len(points)==len(self._T0), \
Branch pushed to git repo; I updated commit sha1. New commits:
6efd9ed | Reparing failures shown in comments 14 and 15 ticket 30400 |
I have fixed some failures shown in comments 14 and 15. I have added a method space_sorting
, which allows to sort the print representation of finite spaces (I have learned to run doctests and I had not got failures after defining such method).
maybe you could get rid of dict_to_matrix, used only once
Branch pushed to git repo; I updated commit sha1. New commits:
38c2e84 | dict_to_matrix function removed |
Replying to @fchapoton:
maybe you could get rid of dict_to_matrix, used only once
Thanks for the suggestion.
What could be the reason why this ticket passed the tests on October 18 but not on October 22? It has not been modified in recent weeks...
Replying to @jcuevas-rozo:
What could be the reason why this ticket passed the tests on October 18 but not on October 22? It has not been modified in recent weeks...
Because sage itself is moving, and the patchbots always use the latest develop branch, which sometimes does not pass all the tests.
By the way, you should pul your real full name in the "Authors" fields here above.
Changed author from gh-jcuevas-rozo to Julián Cuevas-Rozo
Branch pushed to git repo; I updated commit sha1. New commits:
538a6ab | beat points and weak points added |
Branch pushed to git repo; I updated commit sha1. New commits:
3bbc6e2 | Fixing tests |
Branch pushed to git repo; I updated commit sha1. New commits:
5dfbe89 | Merge branch 'u/gh-jcuevas-rozo/add_finite_topological_spaces' of git://trac.sagemath.org/sage into t/30862/dvf_and_homology_of_h_regular_finite_topological_spaces |
d860bee | hregular homology added (missing documentation) |
6fc8b08 | kenzo.py restored and some methods added to finite_topological_spaces.py |
Branch pushed to git repo; I updated commit sha1. New commits:
a6face5 | Non-ascii character deleted |
Branch pushed to git repo; I updated commit sha1. New commits:
8a123d6 | Fixing 'blocks' warnings |
What's the SAGE etiquette for review? I'm interested to understand what's going on here, but don't know anything in particular about finite topologies. Am I expected to be an expert in the subject matter? Do comments on the code/general structure help?
I think that any feedback would be good. General comments are good, and if you can delve at all into the mathematics, that would also be good. I hope I can get back to this to help with the review myself, but I haven't had the time yet.
Maybe a stupid comment, but isn't the singular of matrices "matrix"? Or is this something special about Kenzo.
Replying to @kliem:
Maybe a stupid comment, but isn't the singular of matrices "matrix"? Or is this something special about Kenzo.
Don´t worry, it is a good question. The term 'matrice', used in Kenzo, comes from French and it means matrix (as you noticed). In Kenzo, the type 'matrice' is used for sparse matrices.
My apologies for the delay, I am going to try working on this ticket. Some style comments:
assert
statements for error checking, because they can be ignored when Python is run with optimization flags turned on. The Python documentation says that assert
statements should be used for debugging. (I think these statements are currently used throughout the Sage library, and maybe we should start a campaign to eliminate them. In the meantime, we shouldn't add more.)cannot import name '__convertarray__' from ...
. I do not have Kenzo installed; I think those doctests should be marked optional - kenzo
. See below for some fixes, although I may have been too aggressive in applying the tags.E = random.sample(X, k)
with a deprecation warning: DeprecationWarning: Sampling from a set deprecated
since Python 3.9 and will be removed in a subsequent version.
diff --git a/src/sage/homology/finite_topological_spaces.py b/src/sage/homology/finite_topological_spaces.py
index 5307dbbad1..61285a8e06 100644
--- a/src/sage/homology/finite_topological_spaces.py
+++ b/src/sage/homology/finite_topological_spaces.py
@@ -127,25 +127,25 @@ def quotient_group_matrices(*matrices, left_null=False, right_null=False, check=
EXAMPLES::
- sage: from sage.homology.finite_topological_spaces import quotient_group_matrices, __convertarray__
- sage: from sage.interfaces.kenzo import s2k_matrix
- sage: quotient_group_matrices()
+ sage: from sage.homology.finite_topological_spaces import quotient_group_matrices, __convertarray__ # optional - kenzo
+ sage: from sage.interfaces.kenzo import s2k_matrix # optional - kenzo
+ sage: quotient_group_matrices() # optional - kenzo
0
- sage: s_M1 = matrix(2, 3, [1, 2, 3, 4, 5, 6])
- sage: M1 = __convertarray__(s2k_matrix(s_M1))
- sage: quotient_group_matrices(M1, left_null=True)
+ sage: s_M1 = matrix(2, 3, [1, 2, 3, 4, 5, 6]) # optional - kenzo
+ sage: M1 = __convertarray__(s2k_matrix(s_M1)) # optional - kenzo
+ sage: quotient_group_matrices(M1, left_null=True) # optional - kenzo
C3
- sage: quotient_group_matrices(M1, right_null=True)
+ sage: quotient_group_matrices(M1, right_null=True) # optional - kenzo
Z
- sage: s_M2 = matrix(2, 2, [1, -1, 1, -1])
- sage: M2 = __convertarray__(s2k_matrix(s_M2))
- sage: s_M3 = matrix(2, 2, [1, 0, 1, 0])
- sage: M3 = __convertarray__(s2k_matrix(s_M3))
- sage: quotient_group_matrices(M2, M3)
+ sage: s_M2 = matrix(2, 2, [1, -1, 1, -1]) # optional - kenzo
+ sage: M2 = __convertarray__(s2k_matrix(s_M2)) # optional - kenzo
+ sage: s_M3 = matrix(2, 2, [1, 0, 1, 0]) # optional - kenzo
+ sage: M3 = __convertarray__(s2k_matrix(s_M3)) # optional - kenzo
+ sage: quotient_group_matrices(M2, M3) # optional - kenzo
0
- sage: s_M4 = matrix(2, 2, [0, 0, 1, 0])
- sage: M4 = __convertarray__(s2k_matrix(s_M4))
- sage: quotient_group_matrices(M2, M4)
+ sage: s_M4 = matrix(2, 2, [0, 0, 1, 0]) # optional - kenzo
+ sage: M4 = __convertarray__(s2k_matrix(s_M4)) # optional - kenzo
+ sage: quotient_group_matrices(M2, M4) # optional - kenzo
Traceback (most recent call last):
...
AssertionError: m1*m2 must be zero
@@ -192,18 +192,18 @@ def k2s_binary_matrix_sparse(kmatrix):
EXAMPLES::
sage: from sage.homology.finite_topological_spaces import k2s_binary_matrix_sparse, \
- s2k_binary_matrix_sparse, __randomtop__
- sage: KM2 = __randomtop__(6,1)
- sage: k2s_binary_matrix_sparse(KM2)
+ s2k_binary_matrix_sparse, __randomtop__ # optional - kenzo
+ sage: KM2 = __randomtop__(6,1) # optional - kenzo
+ sage: k2s_binary_matrix_sparse(KM2) # optional - kenzo
[1 1 1 1 1 1]
[0 1 1 1 1 1]
[0 0 1 1 1 1]
[0 0 0 1 1 1]
[0 0 0 0 1 1]
[0 0 0 0 0 1]
- sage: KM = __randomtop__(100, float(0.8))
- sage: SM = k2s_binary_matrix_sparse(KM)
- sage: SM == k2s_binary_matrix_sparse(s2k_binary_matrix_sparse(SM))
+ sage: KM = __randomtop__(100, float(0.8)) # optional - kenzo
+ sage: SM = k2s_binary_matrix_sparse(KM) # optional - kenzo
+ sage: SM == k2s_binary_matrix_sparse(s2k_binary_matrix_sparse(SM)) # optional - kenzo
True
"""
data = __vector_to_list__(__matrice_to_lmtrx__(kmatrix)).python()
@@ -226,9 +226,9 @@ def s2k_binary_matrix_sparse(smatrix):
EXAMPLES::
sage: from sage.homology.finite_topological_spaces import k2s_binary_matrix_sparse, \
- s2k_binary_matrix_sparse
- sage: SM2 = matrix.ones(5)
- sage: s2k_binary_matrix_sparse(SM2)
+ s2k_binary_matrix_sparse # optional - kenzo
+ sage: SM2 = matrix.ones(5) # optional - kenzo
+ sage: s2k_binary_matrix_sparse(SM2) # optional - kenzo
<ECL:
========== MATRIX 5 lines + 5 columns =====
L1=[C1=1][C2=1][C3=1][C4=1][C5=1]
@@ -273,7 +273,7 @@ def FiniteSpace(data, elements=None, is_T0=False):
underlying set of the space.
- ``is_T0`` -- (default ``False``) it is a boolean that indicates, when it is
- previously known, if the finite space is `T_0.
+ previously known, if the finite space is `T_0`.
EXAMPLES:
@@ -444,8 +444,8 @@ def RandomFiniteT0Space(*args):
INPUT:
- ``args`` -- A tuple of two arguments. The first argument must be an integer
- number, while the second argument must be either a number between 0 and 1, or
- ``True``.
+ number, while the second argument must be either a number between 0 and 1, or
+ ``True``.
OUTPUT:
@@ -458,18 +458,18 @@ def RandomFiniteT0Space(*args):
EXAMPLES::
sage: from sage.homology.finite_topological_spaces import RandomFiniteT0Space
- sage: RandomFiniteT0Space(5, 0)
+ sage: RandomFiniteT0Space(5, 0) # optional - kenzo
Finite T0 topological space of 5 points with minimal basis
{0: {0}, 1: {1}, 2: {2}, 3: {3}, 4: {4}}
- sage: RandomFiniteT0Space(5, 2)
+ sage: RandomFiniteT0Space(5, 2) # optional - kenzo
Finite T0 topological space of 5 points with minimal basis
{0: {0}, 1: {0, 1}, 2: {0, 1, 2}, 3: {0, 1, 2, 3}, 4: {0, 1, 2, 3, 4}}
- sage: RandomFiniteT0Space(6, True)
+ sage: RandomFiniteT0Space(6, True) # optional - kenzo
Finite T0 topological space of 6 points with minimal basis
{0: {0}, 1: {1}, 2: {0, 1, 2}, 3: {0, 1, 3}, 4: {0, 1, 2, 3, 4}, 5: {0, 1, 2, 3, 5}}
- sage: RandomFiniteT0Space(150, 0.2)
+ sage: RandomFiniteT0Space(150, 0.2) # optional - kenzo
Finite T0 topological space of 150 points
- sage: RandomFiniteT0Space(5, True)
+ sage: RandomFiniteT0Space(5, True) # optional - kenzo
Traceback (most recent call last):
...
AssertionError: The first argument must be an integer number greater than 5
@@ -1875,16 +1875,16 @@ class FiniteTopologicalSpace_T0(FiniteTopologicalSpace):
....: [11, 16], [15, 17], [2, 19], [6, 20], [18, 20]]
sage: P = Poset((list(range(1,21)), Pcovers), cover_relations=True)
sage: X = FiniteSpace(P)
- sage: dvf = X.discrete_vector_field(); dvf
+ sage: dvf = X.discrete_vector_field(); dvf # optional - kenzo
[(2, 3), (4, 6), (8, 9), (7, 12), (15, 17), (18, 20), (10, 13), (11, 16)]
- sage: X.show(dvf)
+ sage: X.show(dvf) # optional - kenzo
Graphics object consisting of 45 graphics primitives
sage: Qcovers = [[1, 2], [2, 3], [3, 4], [3, 5]]
sage: Q = Poset((list(range(1,6)), Qcovers), cover_relations=True)
sage: Y = FiniteSpace(Q)
sage: Z = Y.barycentric_subdivision()
- sage: dvf = Z.discrete_vector_field(h_admissible=True)
- sage: Z.show(dvf)
+ sage: dvf = Z.discrete_vector_field(h_admissible=True) # optional - kenzo
+ sage: Z.show(dvf) # optional - kenzo
Graphics object consisting of 71 graphics primitives
"""
kenzo_top = s2k_binary_matrix_sparse(self._topogenous)
@@ -1919,12 +1919,12 @@ class FiniteTopologicalSpace_T0(FiniteTopologicalSpace):
....: [2, 4], [1, 4]]
sage: P = Poset((list(range(1,14)), covers), cover_relations = True)
sage: X = FiniteSpace(P)
- sage: X.hregular_homology()
+ sage: X.hregular_homology() # optional - kenzo
{0: Z, 1: C2, 2: 0}
- sage: dvf = X.discrete_vector_field()
- sage: X.show(dvf)
+ sage: dvf = X.discrete_vector_field() # optional - kenzo
+ sage: X.show(dvf) # optional - kenzo
Graphics object consisting of 38 graphics primitives
- sage: X.hregular_homology(dvfield = dvf)
+ sage: X.hregular_homology(dvfield = dvf) # optional - kenzo
{0: Z, 1: C2, 2: 0}
"""
assert deg==None or deg.is_integer(), "The degree must be an integer number or None"
Two more things about the documentation: \minus
and \im
are not standard LaTeX commands and they do not render properly. Should \minus
be replaced by -
or \setminus
? I'm not sure what to do about \im
: replace it every time by \mathrm{im}
or similar?
Maybe \mathop{\mathrm{im}}
or \mathrm{im}\,
.
Replying to @jhpalmieri:
- Preferred Sage style is to keep lines under 80 characters when possible. One place that violates this is in the docstrings. Don't work too hard to get the doctests under 80 characters, but the paragraphs of text should satisfy this.
I tried my best to do it, I have shortened the lines that didn't satisfy the rule.
- I don't know if it's officially a Sage style, but it is in general better to not use
assert
statements for error checking, because they can be ignored when Python is run with optimization flags turned on. The Python documentation says thatassert
statements should be used for debugging. (I think these statements are currently used throughout the Sage library, and maybe we should start a campaign to eliminate them. In the meantime, we shouldn't add more.)
The assert
statements have been completely changed to conditional statements.
- I'm getting doctest failures of the form
cannot import name '__convertarray__' from ...
. I do not have Kenzo installed; I think those doctests should be markedoptional - kenzo
. See below for some fixes, although I may have been too aggressive in applying the tags.
The optional - kenzo
mark has been added to the required lines. Also, some functions have been added directly to src/sage/interfaces.kenzo.py
.
- I'm getting other doctest failures from
E = random.sample(X, k)
with a deprecation warning:DeprecationWarning: Sampling from a set deprecated since Python 3.9 and will be removed in a subsequent version.
I have changed "sampling from a set X
" by "sampling from a list(X)
" in order to fix these warnings.
Replying to @jhpalmieri:
Two more things about the documentation:
\minus
and\im
are not standard LaTeX commands and they do not render properly. Should\minus
be replaced by-
or\setminus
? I'm not sure what to do about\im
: replace it every time by\mathrm{im}
or similar?
I have replaced \minus
by -
and \im
by \mathrm{im}\
.
This ticket provides a class for finite topological spaces and methods dealing with properties in general topology. It is expected to create a second ticket to add algebraic topology properties (see ticket #30447).
Principal reference: Algebraic topology of finite topological spaces and applications by Jonathan Barmak.
Depends on #31925
CC: @jhpalmieri
Component: algebraic topology
Keywords: Finite topological spaces
Work Issues: Rework on top of #31925
Author: Julián Cuevas-Rozo
Branch/Commit: u/gh-jcuevas-rozo/add_finite_topological_spaces @
3c2e0d4
Issue created by migration from https://trac.sagemath.org/ticket/30400