#20758: Simplicial complexes: keep the __enlarged cache in add_face
-------------------------------------+-------------------------------------
Reporter: jhpalmieri | Owner:
Type: enhancement | Status: needs_work
Priority: minor | Milestone: sage-7.3
Component: algebraic | Resolution:
topology | Merged in:
Keywords: days74 | Reviewers: Travis Scrimshaw
Authors: John Palmieri | Work issues:
Report Upstream: N/A | Commit:
Branch: | 00fce35fba80180814ebf3557e27491ee15082d2
u/tscrim/simplicial_add_face-20758 | Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Changes (by jhpalmieri):
* status: positive_review => needs_work
Comment:
This is fallout from #20718: in that ticket, we changed from using
`self.n_faces(dim)` to using `self.faces()[dim]`, but the former allows
values of `dim` greater than the dimension of the complex: it just returns
the empty set in that case. So we can continue with the philosophy in
#20718, that we want to avoid `n_faces`, or we can restore its use in some
cases. The fix is easy either way, we just need to decide what to do. For
example, in keeping with the philosophy there:
{{{
#!diff
diff --git a/src/sage/homology/simplicial_complex.py
b/src/sage/homology/simplicial_complex.py
index fefc90e..1a6cca7 100644
--- a/src/sage/homology/simplicial_complex.py
+++ b/src/sage/homology/simplicial_complex.py
@@ -1199,7 +1199,7 @@ class SimplicialComplex(Parent, GenericCellComplex):
if not isinstance(x, Simplex):
return False
dim = x.dimension()
- return x in self.faces()[dim]
+ return dim in self.faces() and x in self.faces()[dim]
def __call__(self, simplex):
"""
@@ -1527,9 +1527,11 @@ class SimplicialComplex(Parent,
GenericCellComplex):
...
ValueError: this simplex is not in this simplicial complex
"""
- if not simplex in self.faces()[simplex.dimension()]:
+ d = simplex.dimension()
+ if d in self.faces() and simplex in self.faces()[d]:
+ return simplex.face(i)
+ else:
raise ValueError('this simplex is not in this simplicial
complex')
- return simplex.face(i)
def flip_graph(self):
"""
@@ -3220,7 +3222,11 @@ class SimplicialComplex(Parent,
GenericCellComplex):
sage: X.set_immutable()
sage: X.n_skeleton(2)
Simplicial complex with vertex set (0, 1, 2, 3) and facets
{(0, 2, 3), (1, 2, 3), (0, 1)}
+ sage: X.n_skeleton(4)
+ Simplicial complex with vertex set (0, 1, 2, 3) and facets
{(0, 2, 3), (1, 2, 3), (0, 1)}
"""
+ if n >= self.dimension():
+ return self
# make sure it's a list (it will be a tuple if immutable)
facets = [f for f in self._facets if f.dimension() < n]
facets.extend(self.faces()[n])
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/20758#comment:6>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.