Skip to content

Commit

Permalink
Merge remote-tracking branch 'vbraun/develop' into docstrings_input_f…
Browse files Browse the repository at this point in the history
…ormatting
  • Loading branch information
gmou3 committed Jun 6, 2024
2 parents 5716b4e + 1f3b284 commit 3249f5b
Show file tree
Hide file tree
Showing 107 changed files with 3,871 additions and 2,155 deletions.
4 changes: 2 additions & 2 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
sha1=38544fd9c970e824cdcc0bad29ecfe3d25eddeea
sha256=10755d40bd1f6a8846b5afe5b49483b7131ba531c65da914325f50bfd831218d
sha1=14af118d49c9381989e4ea2409817248d34ebf19
sha256=860c9d730e6bd766be52c304e3fc5bef30e022ba35c0a3eb227c0930255426b0
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
aad52428be28be7e3454d702b8b1d9cb2b5fd67e
be566915755fbfad85571c4a82e25404b43d10cb
3 changes: 2 additions & 1 deletion src/sage/algebras/lie_algebras/lie_algebra_element.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
cpdef bracket(self, right)
cpdef _bracket_(self, right)
cpdef to_vector(self, bint sparse=*)
cpdef _vector_(self, bint sparse=*, order=*)
cpdef to_vector(self, bint sparse=*, order=*)
cpdef dict monomial_coefficients(self, bint copy=*)
# cpdef lift(self)

Expand Down
25 changes: 20 additions & 5 deletions src/sage/algebras/lie_algebras/lie_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
x_lift = (<LieSubalgebraElementWrapper> x).value
return type(self)(self._parent, self.value._bracket_(x_lift))

def to_vector(self, order=None, sparse=False):
def _vector_(self, sparse=False, order=None):
r"""
Return the vector in ``g.module()`` corresponding to the
element ``self`` of ``g`` (where ``g`` is the parent of ``self``).
Expand Down Expand Up @@ -573,6 +573,8 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
"""
return self._parent.module()(self.value.to_vector(sparse=sparse))

to_vector = _vector_

cpdef dict monomial_coefficients(self, bint copy=True):
r"""
Return a dictionary whose keys are indices of basis elements
Expand Down Expand Up @@ -833,21 +835,34 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
if v != zero:
yield (I[i], v)

cpdef to_vector(self, bint sparse=False):
cpdef _vector_(self, bint sparse=False, order=None):
"""
Return ``self`` as a vector.
EXAMPLES::
sage: L.<x,y,z> = LieAlgebra(QQ, {('x','y'): {'z':1}})
sage: a = x + 3*y - z/2
sage: a.to_vector()
(1, 3, -1/2)
sage: a = x + 3*y - z/5
sage: vector(a)
(1, 3, -1/5)
"""
if sparse:
return self.value.sparse_vector()
return self.value

cpdef to_vector(self, bint sparse=False, order=None):
"""
Return ``self`` as a vector.
EXAMPLES::
sage: L.<x,y,z> = LieAlgebra(QQ, {('x','y'): {'z':1}})
sage: a = x + 3*y - z/2
sage: a.to_vector()
(1, 3, -1/2)
"""
return self._vector_(sparse=sparse)

def lift(self):
"""
Return the lift of ``self`` to the universal enveloping algebra.
Expand Down
23 changes: 18 additions & 5 deletions src/sage/algebras/lie_algebras/quotient.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,14 @@ def __classcall_private__(cls, I, ambient=None, names=None,
index_set = [i for i in sorted_indices if i not in I_supp]

if names is None:
if ambient._names is not None:
# ambient has assigned variable names, so use those
try:
amb_names = dict(zip(sorted_indices, ambient.variable_names()))
names = [amb_names[i] for i in index_set]
elif isinstance(names, str):
except (ValueError, KeyError):
# ambient has not assigned variable names
# or the names are for the generators rather than the basis
names = 'e'
if isinstance(names, str):
if len(index_set) == 1:
names = [names]
else:
Expand Down Expand Up @@ -271,6 +274,7 @@ def __init__(self, I, L, names, index_set, category=None):
self._ambient = L
self._I = I
self._sm = sm
self._triv_ideal = bool(I.dimension() == 0)

LieAlgebraWithStructureCoefficients.__init__(
self, L.base_ring(), s_coeff, names, index_set, category=category)
Expand Down Expand Up @@ -423,14 +427,23 @@ def from_vector(self, v, order=None, coerce=False):
sage: el.parent() == Q
True
An element from a vector of the ambient module
An element from a vector of the ambient module::
sage: el = Q.from_vector([1, 2, 3]); el
-2*X - Y
sage: el.parent() == Q
True
Check for the trivial ideal::
sage: L.<x,y,z> = LieAlgebra(GF(3), {('x','z'): {'x':1, 'y':1}, ('y','z'): {'y':1}})
sage: I = L.ideal([])
sage: Q = L.quotient(I)
sage: v = Q.an_element().to_vector()
sage: Q.from_vector(v)
x + y + z
"""
if len(v) == self.ambient().dimension():
if not self._triv_ideal and len(v) == self.ambient().dimension():
return self.retract(self.ambient().from_vector(v))

return super().from_vector(v)
18 changes: 9 additions & 9 deletions src/sage/algebras/lie_algebras/subalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from sage.sets.family import Family
from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
from sage.structure.parent import Parent
from sage.structure.element import parent
from sage.structure.unique_representation import UniqueRepresentation


Expand Down Expand Up @@ -388,7 +389,7 @@ def _an_element_(self):
sage: S._an_element_()
X
"""
return self.element_class(self, self.lie_algebra_generators()[0])
return self.lie_algebra_generators()[0]

def _element_constructor_(self, x):
"""
Expand Down Expand Up @@ -425,14 +426,13 @@ def _element_constructor_(self, x):
sage: S([S(x), S(y)]) == S(L[x, y])
True
"""
try:
P = x.parent()
if P is self:
return x
if P == self._ambient:
return self.retract(x)
except AttributeError:
pass
P = parent(x)
if P is self:
return x

Check warning on line 431 in src/sage/algebras/lie_algebras/subalgebra.py

View check run for this annotation

Codecov / codecov/patch

src/sage/algebras/lie_algebras/subalgebra.py#L431

Added line #L431 was not covered by tests
if P == self._ambient:
return self.retract(x)
if isinstance(P, type(self)) and P._ambient == self._ambient:
return self.retract(x.value)

if x in self.module():
return self.from_vector(x)
Expand Down
4 changes: 3 additions & 1 deletion src/sage/algebras/orlik_solomon.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class OrlikSolomonAlgebra(CombinatorialFreeModule):
14
sage: G = OS.algebra_generators()
sage: M.broken_circuits()
frozenset({frozenset({1, 2, 3})})
SetSystem of 1 sets over 4 elements
sage: M.broken_circuits()[0]
frozenset({1, 2, 3})
sage: G[1] * G[2] * G[3]
OS{0, 1, 2} - OS{0, 1, 3} + OS{0, 2, 3}
Expand Down
Loading

0 comments on commit 3249f5b

Please sign in to comment.