Ask Your Question

Revision history [back]

wrapping vector class

I am trying to wrap the vector class to add some extra cases, but I am having trouble doing so. This is the code I have:

def lower_triangular_entries(dim,x,y):
return upper_triangular_entries(dim,y,x)

def upper_triangular_entries(dim,x,y):
    if y<=x:
        return 1
    else:
        return 0

class OneParamSubgroup(vector):
    #TO DO: define scalar multiplication
    def __init__(self, data, type_A=False):
        if type_A:
            BasisChange=matrix(ZZ, len(data)-1, len(data)-1,
                                lambda x,y: lower_triangular(len(data)-1,x,y))
            v=vector(data[0:len(data)-1])
            v=tuple(BasisChange*v)
        #data given in terms of basis T
        else:
            v=data
        vector.__init__(self, v)
    def __repr__(self):
        return self

wrapping vector class

I am trying to wrap the vector class to add some extra cases, but I am having trouble doing so. This is the code I have:

def lower_triangular_entries(dim,x,y):
return upper_triangular_entries(dim,y,x)

def upper_triangular_entries(dim,x,y):
    if y<=x:
        return 1
    else:
        return 0

class OneParamSubgroup(vector):
    #TO DO: define scalar multiplication
    def __init__(self, data, type_A=False):
        if type_A:
            BasisChange=matrix(ZZ, len(data)-1, len(data)-1,
                                lambda x,y: lower_triangular(len(data)-1,x,y))
            v=vector(data[0:len(data)-1])
            v=tuple(BasisChange*v)
        #data given in terms of basis T
        else:
            v=data
        vector.__init__(self, v)
    def __repr__(self):
        return self

However, I get the following error when running on terminal

Traceback (most recent call last):
  File "test.sage.py", line 7, in <module>
    load("GIT/Group.sage")
  File "sage/structure/sage_object.pyx", line 1057, in sage.structure.sage_object.load (build/cythonized/sage/structure/sage_object.c:12915)
  File "/opt/sagemath-8.1/local/lib/python2.7/site-packages/sage/repl/load.py", line 247, in load
    exec(preparse_file(open(fpath).read()) + "\n", globals)
  File "<string>", line 3, in <module>
ImportError: cannot import name vector

and the following on the Notebook

TypeError                                 Traceback (most recent call last)
<ipython-input-1-ec2394617192> in <module>()
      8         return Integer(0)
      9 
---> 10 class OneParamSubgroup(vector):
     11     #TO DO: define scalar multiplication
     12     def __init__(self, data, type_A=False):

TypeError: Error when calling the metaclass bases
    cannot create 'builtin_function_or_method' instances

Any idea of what I am doing wrong?

wrapping vector class

I am trying to wrap the vector class to add some extra cases, but I am having trouble doing so. This is the code I have:

def lower_triangular_entries(dim,x,y):
 return upper_triangular_entries(dim,y,x)

def upper_triangular_entries(dim,x,y):
    if y<=x:
        return 1
    else:
        return 0

class OneParamSubgroup(vector):
    #TO DO: define scalar multiplication
    def __init__(self, data, type_A=False):
        if type_A:
            BasisChange=matrix(ZZ, len(data)-1, len(data)-1,
                                lambda x,y: lower_triangular(len(data)-1,x,y))
            v=vector(data[0:len(data)-1])
            v=tuple(BasisChange*v)
        #data given in terms of basis T
        else:
            v=data
        vector.__init__(self, v)
    def __repr__(self):
        return self

However, I get the following error when running on terminal

Traceback (most recent call last):
  File "test.sage.py", line 7, in <module>
    load("GIT/Group.sage")
  File "sage/structure/sage_object.pyx", line 1057, in sage.structure.sage_object.load (build/cythonized/sage/structure/sage_object.c:12915)
  File "/opt/sagemath-8.1/local/lib/python2.7/site-packages/sage/repl/load.py", line 247, in load
    exec(preparse_file(open(fpath).read()) + "\n", globals)
  File "<string>", line 3, in <module>
ImportError: cannot import name vector

and the following on the Notebook

TypeError                                 Traceback (most recent call last)
<ipython-input-1-ec2394617192> in <module>()
      8         return Integer(0)
      9 
---> 10 class OneParamSubgroup(vector):
     11     #TO DO: define scalar multiplication
     12     def __init__(self, data, type_A=False):

TypeError: Error when calling the metaclass bases
    cannot create 'builtin_function_or_method' instances

Any idea of what I am doing wrong?