Я пишу модуль Python, используя SageMath9.4. По сути, я хочу импортировать этот модуль в блокноты Jupyterlab (под управлением ядра SageMath 9.4) для выполнения вычислений и т. д.
Вот его начало:
class Coxeter_System:
'''This class defines the standard root system associated to an abstract Coxeter group.'''
def __init__(self, coxeter_matrix):
'''Sets up a Coxeter system and root system. At this stage, limited to up to rank 7.
'''
def set_up_coefficient_space(coxeter_matrix):
'''Sets up a polynomial ring a Free module over a polynomial ring quotiented by the minimal polynomials of the
non-rational cos(pi/m_ij) values.
This is so roots can be compared using an abstract free module rather than over reals'''
A = coxeter_matrix
k = len(A.rows())
# Get the cos(pi/m_ij) which are irrational
non_rational_angles = [x for x in [cos(pi/x) for x in set(A[i,j] for i in range(0,k) for j in range(0,k))] if x not in QQ]
Однако, когда я открываю другой сеанс Jupyterlab, импортирую модуль Python и пытаюсь создать экземпляр объекта «Coxeter_System», я получаю следующую ошибку (я пытался сделать из математических вычислений import cos как из записной книжки, в которую я хочу импортировать модуль, так и из самого модуля, но я все равно получаю ту же ошибку.
Буду очень признателен за любую помощь !):
NameError Traceback (most recent call last)
in
----> 1 W = c.Coxeter_System(Matrix([[Integer(1),Integer(3),Integer(4)],[Integer(3),Integer(1),Integer(3)],[Integer(4),Integer(3),Integer(1)]]))
~/coxeter_groups.py in __init__(self, coxeter_matrix)
60 return matrix(R,k,B)
61
---> 62 R = set_up_coefficient_space(coxeter_matrix)
63 A = coxeter_matrix
64 k = len(A.rows())
~/coxeter_groups.py in set_up_coefficient_space(coxeter_matrix)
17
18 # Get the cos(pi/m_ij) which are irrational
---> 19 non_rational_angles = [x for x in [cos(pi/x) for x in set(A[i,j] for i in range(0,k) for j in range(0,k))] if x not in QQ]
20
21 # sort the irrational values of cos(pi/m_ij) in ascending order
~/coxeter_groups.py in (.0)
17
18 # Get the cos(pi/m_ij) which are irrational
---> 19 non_rational_angles = [x for x in [cos(pi/x) for x in set(A[i,j] for i in range(0,k) for j in range(0,k))] if x not in QQ]
20
21 # sort the irrational values of cos(pi/m_ij) in ascending order
NameError: name 'cos' is not defined
Подробнее здесь: https://stackoverflow.com/questions/702 ... agemath9-4