Ask Your Question

Revision history [back]

hi any help with TypeError: unable to convert b to an integer

I have the following segment: M=matrix([[-3,1,1,1],[1,-3,1,1],[1,1,-3,1],[1,1,1,-3]])

b=var("b"); v = vector([1,b,b2,b3]); AUG=M.augment(v,subdivide=true)


AttributeError Traceback (most recent call last) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix0.pyx in sage.matrix.matrix0.Matrix.change_ring (build/cythonized/sage/matrix/matrix0.c:11306)() 1644 try: -> 1645 return self._change_ring(ring) 1646 except (AttributeError, NotImplementedError):

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4709)() 492 """ --> 493 return self.getattr_from_category(name) 494

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4821)() 505 cls = P._abstract_element_class --> 506 return getattr_from_other_class(self, cls, name) 507

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/cpython/getattr.pyx in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2618)() 371 dummy_error_message.name = name --> 372 raise AttributeError(dummy_error_message) 373 attribute = <object>attr

AttributeError: 'sage.symbolic.expression.Expression' object has no attribute '__custom_name'

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8805)() 1298 try: -> 1299 n = self.pyobject() 1300 except TypeError:

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.pyobject (build/cythonized/sage/symbolic/expression.cpp:6140)() 586 if not is_a_numeric(self._gobj): --> 587 raise TypeError("self must be a numeric expression") 588 return py_object_from_numeric(self._gobj)

TypeError: self must be a numeric expression

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last) <ipython-input-11-142d4172e4a7> in <module> ----> 1 AUG=M.augment(v,subdivide=true)

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense.augment (build/cythonized/sage/matrix/matrix_integer_dense.cpp:44235)() 5294 raise TypeError('number of rows must be the same, not {0} != {1}'.format(self._nrows, right.nrows())) 5295 if not (self._base_ring is right.base_ring()): -> 5296 right = right.change_ring(self._base_ring) 5297 5298 cdef Matrix_integer_dense other = right.dense_matrix()

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix0.pyx in sage.matrix.matrix0.Matrix.change_ring (build/cythonized/sage/matrix/matrix0.c:11450)() 1646 except (AttributeError, NotImplementedError): 1647 M = sage.matrix.matrix_space.MatrixSpace(ring, self._nrows, self._ncols, sparse=self.is_sparse()) -> 1648 mat = M(self.list(), coerce=True, copy=False) 1649 if self._subdivisions is not None: 1650 mat.subdivide(self.subdivisions())

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_space.py in __call__(self, entries, coerce, copy) 848 [t] 849 """ --> 850 return self.element_class(self, entries, copy, coerce) 851 852 def change_ring(self, R):

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense.__init__ (build/cythonized/sage/matrix/matrix_integer_dense.cpp:7129)() 309 ma = MatrixArgs_init(parent, entries) 310 cdef Integer z --> 311 for t in ma.iter(coerce, True): 312 se = <sparseentry>t 313 z = <integer>se.entry

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/args.pyx in iter (build/cythonized/sage/matrix/args.c:6733)() 529 x = next(it) 530 if convert and self.need_to_convert(x): --> 531 x = self.base(x) 532 if sparse: 533 yield make_SparseEntry(i, j, x)

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9336)() 896 if mor is not None: 897 if no_extra_args: --> 898 return mor._call_(x) 899 else: 900 return mor._call_with_args(x, args, kwds)

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)() 285 raise TypeError("Cannot coerce {} to {}".format(x, C)) 286 cdef Map m --> 287 cdef Element e = method(C) 288 if e is None: 289 raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x)))

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8854)() 1299 n = self.pyobject() 1300 except TypeError: -> 1301 raise TypeError("unable to convert %r to an integer" % self) 1302 if isinstance(n, sage.rings.integer.Integer): 1303 return n

TypeError: unable to convert b to an integer

hi any help with TypeError: unable to convert b to an integer

I have the following segment: M=matrix([[-3,1,1,1],[1,-3,1,1],[1,1,-3,1],[1,1,1,-3]])segment:

M=matrix([[-3,1,1,1],[1,-3,1,1],[1,1,-3,1],[1,1,1,-3]])

b=var("b");
v = vector([1,b,b2,b3]);
AUG=M.augment(v,subdivide=true)


vector([1,b,b**2,b**3]); AUG=M.augment(v,subdivide=true) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix0.pyx in sage.matrix.matrix0.Matrix.change_ring (build/cythonized/sage/matrix/matrix0.c:11306)() 1644 try: -> 1645 return self._change_ring(ring) 1646 except (AttributeError, NotImplementedError):

NotImplementedError): /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4709)() 492 """ --> 493 return self.getattr_from_category(name) 494

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4821)() 505 cls = P._abstract_element_class --> 506 return getattr_from_other_class(self, cls, name) 507

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/cpython/getattr.pyx in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2618)() 371 dummy_error_message.name = name --> 372 raise AttributeError(dummy_error_message) 373 attribute = <object>attr

<object>attr AttributeError: 'sage.symbolic.expression.Expression' object has no attribute '__custom_name'

'__custom_name' During handling of the above exception, another exception occurred:

occurred: TypeError Traceback (most recent call last) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8805)() 1298 try: -> 1299 n = self.pyobject() 1300 except TypeError:

TypeError: /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.pyobject (build/cythonized/sage/symbolic/expression.cpp:6140)() 586 if not is_a_numeric(self._gobj): --> 587 raise TypeError("self must be a numeric expression") 588 return py_object_from_numeric(self._gobj)

py_object_from_numeric(self._gobj) TypeError: self must be a numeric expression

expression During handling of the above exception, another exception occurred:

occurred: TypeError Traceback (most recent call last) <ipython-input-11-142d4172e4a7> in <module> ----> 1 AUG=M.augment(v,subdivide=true)

AUG=M.augment(v,subdivide=true) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense.augment (build/cythonized/sage/matrix/matrix_integer_dense.cpp:44235)() 5294 raise TypeError('number of rows must be the same, not {0} != {1}'.format(self._nrows, right.nrows())) 5295 if not (self._base_ring is right.base_ring()): -> 5296 right = right.change_ring(self._base_ring) 5297 5298 cdef Matrix_integer_dense other = right.dense_matrix()

right.dense_matrix() /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix0.pyx in sage.matrix.matrix0.Matrix.change_ring (build/cythonized/sage/matrix/matrix0.c:11450)() 1646 except (AttributeError, NotImplementedError): 1647 M = sage.matrix.matrix_space.MatrixSpace(ring, self._nrows, self._ncols, sparse=self.is_sparse()) -> 1648 mat = M(self.list(), coerce=True, copy=False) 1649 if self._subdivisions is not None: 1650 mat.subdivide(self.subdivisions())

mat.subdivide(self.subdivisions()) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_space.py in __call__(self, entries, coerce, copy) 848 [t] 849 """ --> 850 return self.element_class(self, entries, copy, coerce) 851 852 def change_ring(self, R):

R): /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense.__init__ (build/cythonized/sage/matrix/matrix_integer_dense.cpp:7129)() 309 ma = MatrixArgs_init(parent, entries) 310 cdef Integer z --> 311 for t in ma.iter(coerce, True): 312 se = <sparseentry>t <SparseEntry>t 313 z = <integer>se.entry

<Integer>se.entry /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/args.pyx in iter (build/cythonized/sage/matrix/args.c:6733)() 529 x = next(it) 530 if convert and self.need_to_convert(x): --> 531 x = self.base(x) 532 if sparse: 533 yield make_SparseEntry(i, j, x)

x) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9336)() 896 if mor is not None: 897 if no_extra_args: --> 898 return mor._call_(x) 899 else: 900 return mor._call_with_args(x, args, kwds)

kwds) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)() 285 raise TypeError("Cannot coerce {} to {}".format(x, C)) 286 cdef Map m --> 287 cdef Element e = method(C) 288 if e is None: 289 raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x)))

type(x))) /opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8854)() 1299 n = self.pyobject() 1300 except TypeError: -> 1301 raise TypeError("unable to convert %r to an integer" % self) 1302 if isinstance(n, sage.rings.integer.Integer): 1303 return n

n TypeError: unable to convert b to an integer

integer

hi any help with TypeError: unable to convert b to an integer

I have the following segment:

M=matrix([[-3,1,1,1],[1,-3,1,1],[1,1,-3,1],[1,1,1,-3]])

b=var("b");
v = vector([1,b,b**2,b**3]);
AUG=M.augment(v,subdivide=true)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix0.pyx in sage.matrix.matrix0.Matrix.change_ring (build/cythonized/sage/matrix/matrix0.c:11306)()
   1644         try:
-> 1645             return self._change_ring(ring)
   1646         except (AttributeError, NotImplementedError):

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4709)()
    492         """
--> 493         return self.getattr_from_category(name)
    494 

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4821)()
    505             cls = P._abstract_element_class
--> 506         return getattr_from_other_class(self, cls, name)
    507 

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/cpython/getattr.pyx in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2618)()
    371         dummy_error_message.name = name
--> 372         raise AttributeError(dummy_error_message)
    373     attribute = <object>attr

AttributeError: 'sage.symbolic.expression.Expression' object has no attribute '__custom_name'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8805)()
   1298         try:
-> 1299             n = self.pyobject()
   1300         except TypeError:

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.pyobject (build/cythonized/sage/symbolic/expression.cpp:6140)()
    586         if not is_a_numeric(self._gobj):
--> 587             raise TypeError("self must be a numeric expression")
    588         return py_object_from_numeric(self._gobj)

TypeError: self must be a numeric expression

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-11-142d4172e4a7> in <module>
----> 1 AUG=M.augment(v,subdivide=true)

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense.augment (build/cythonized/sage/matrix/matrix_integer_dense.cpp:44235)()
   5294             raise TypeError('number of rows must be the same, not {0} != {1}'.format(self._nrows, right.nrows()))
   5295         if not (self._base_ring is right.base_ring()):
-> 5296             right = right.change_ring(self._base_ring)
   5297 
   5298         cdef Matrix_integer_dense other = right.dense_matrix()

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix0.pyx in sage.matrix.matrix0.Matrix.change_ring (build/cythonized/sage/matrix/matrix0.c:11450)()
   1646         except (AttributeError, NotImplementedError):
   1647             M = sage.matrix.matrix_space.MatrixSpace(ring, self._nrows, self._ncols, sparse=self.is_sparse())
-> 1648             mat = M(self.list(), coerce=True, copy=False)
   1649             if self._subdivisions is not None:
   1650                 mat.subdivide(self.subdivisions())

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_space.py in __call__(self, entries, coerce, copy)
    848             [t]
    849         """
--> 850         return self.element_class(self, entries, copy, coerce)
    851 
    852     def change_ring(self, R):

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense.__init__ (build/cythonized/sage/matrix/matrix_integer_dense.cpp:7129)()
    309         ma = MatrixArgs_init(parent, entries)
    310         cdef Integer z
--> 311         for t in ma.iter(coerce, True):
    312             se = <SparseEntry>t
    313             z = <Integer>se.entry

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/matrix/args.pyx in iter (build/cythonized/sage/matrix/args.c:6733)()
    529                     x = next(it)
    530                     if convert and self.need_to_convert(x):
--> 531                         x = self.base(x)
    532                     if sparse:
    533                         yield make_SparseEntry(i, j, x)

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9336)()
    896         if mor is not None:
    897             if no_extra_args:
--> 898                 return mor._call_(x)
    899             else:
    900                 return mor._call_with_args(x, args, kwds)

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)()
    285             raise TypeError("Cannot coerce {} to {}".format(x, C))
    286         cdef Map m
--> 287         cdef Element e = method(C)
    288         if e is None:
    289             raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x)))

/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8854)()
   1299             n = self.pyobject()
   1300         except TypeError:
-> 1301             raise TypeError("unable to convert %r to an integer" % self)
   1302         if isinstance(n, sage.rings.integer.Integer):
   1303             return n

TypeError: unable to convert b to an integer