ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 25 Jan 2023 00:27:51 +0100turn the simplex type into symbol typehttps://ask.sagemath.org/question/66072/turn-the-simplex-type-into-symbol-type/ I have a list of elements of type simplex. I need them as symbols. I wrote the following:
import sympy as sym
S = SimplicialComplex([[0,1], [1,2], [0,2]])
Chain = S._n_cells_sorted(1)
print(type(Chain[0]))
Chain2 = []
for i in Chain:
Chain2.append(str(i))
print(Chain2[0], type(Chain2[0]))
Chain3 = [sym.symbols(v) for v in Chain2]
print(Chain3[0],type(Chain3[0]))
The program prints:
(0, 1) <class 'sage.topology.simplicial_complex.Simplex'>
(0, 1) <class 'str'>
((0, 1)) <class 'tuple'>
I want to turn the type elements of the initial list `Chain` into symbols but this program turns them into tuples.
I would appreciate any help!Wed, 25 Jan 2023 00:02:46 +0100https://ask.sagemath.org/question/66072/turn-the-simplex-type-into-symbol-type/Comment by John Palmieri for <p>I have a list of elements of type simplex. I need them as symbols. I wrote the following:</p>
<pre><code>import sympy as sym
S = SimplicialComplex([[0,1], [1,2], [0,2]])
Chain = S._n_cells_sorted(1)
print(type(Chain[0]))
Chain2 = []
for i in Chain:
Chain2.append(str(i))
print(Chain2[0], type(Chain2[0]))
Chain3 = [sym.symbols(v) for v in Chain2]
print(Chain3[0],type(Chain3[0]))
</code></pre>
<p>The program prints:</p>
<pre><code>(0, 1) <class 'sage.topology.simplicial_complex.Simplex'>
(0, 1) <class 'str'>
((0, 1)) <class 'tuple'>
</code></pre>
<p>I want to turn the type elements of the initial list <code>Chain</code> into symbols but this program turns them into tuples. </p>
<p>I would appreciate any help!</p>
https://ask.sagemath.org/question/66072/turn-the-simplex-type-into-symbol-type/?comment=66073#post-id-66073According to the documentation at https://docs.sympy.org/latest/modules/core.html#symbols, if you pass a tuple to `sym.symbols`, it will return a tuple. This seems more like a `sympy` question than a Sage one.Wed, 25 Jan 2023 00:27:51 +0100https://ask.sagemath.org/question/66072/turn-the-simplex-type-into-symbol-type/?comment=66073#post-id-66073