ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 24 Apr 2020 16:58:54 -0500Attribute error: "'Graphics' object has no attribute 'get_pos'" with plotting Hasse diagram of posethttps://ask.sagemath.org/question/50995/attribute-error-graphics-object-has-no-attribute-get_pos-with-plotting-hasse-diagram-of-poset/So I am trying to obtain the position dictionary used for displaying a poset P that can be used in the plotting of the Hasse diagram of P through the hasse_diagram() function.
To clarify, if I run the following code:
P = posets.BooleanLattice(3)
P.plot()
G = P.hasse_diagram().to_undirected()
G.plot()
The locations of the vertices of G do not line up with where the corresponding elements of the poset were. I know that we can save the position dictionary for graphs, but for whatever reason, I'm struggling with obtaining the position dictionary of elements in a poset. (With the specific posets I am working with, maintaining the position when obtaining the undirected Hasse diagram is important because I need a particular planar embedding which is not being preserved if I simply use the hasse_diagram() function in its canned form).
In the finite posets SageMath documentation, the `plot()` function says that it also accepts all options of `GenericGraph.plot` which should include the `save_pos` option and `get_pos()`. However, when I run
P = posets.BooleanLattice(3)
Pplot = P.plot(save_pos=True)
G = P.hasse_diagram().to_undirected()
position = Pplot.get_pos()
G.plot(pos = position)
I get an attribute error:
Error in lines 4-4
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1234, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
AttributeError: 'Graphics' object has no attribute 'get_pos'
Is there any way to extract a position dictionary of a graphics object corresponding to the Hasse diagram of a poset?DerekHFri, 24 Apr 2020 16:58:54 -0500https://ask.sagemath.org/question/50995/Has attribute “hex” been removed to “Integer” type?https://ask.sagemath.org/question/50433/has-attribute-hex-been-removed-to-integer-type/I wanted to check out a github implementation, but after launching their script I got the error:
AttributeError: 'sage.rings.integer.Integer' object has no attribute 'hex'
I verified the code, checked on doc sagemath that the attribute hex was existing, I even removed sagemath, reinstalled it, checked for upgrades, without anything changing. I currently have `SageMath version 8.1, Release Date: 2017-12-07`.
When I am creating an integer on the sage terminal and looking for hex, I can see every attributes listed on the sagemath Integer documentation, except the wanted hex().
I couldn't find any information online about a potential withdrawal of this attribute in recent versions of sagemath, and granted that the github code I'm interested in has been updated recently, I assume having a bug here that I don't know how to deal with...
NashtareSun, 29 Mar 2020 22:18:26 -0500https://ask.sagemath.org/question/50433/AttributeError when defining a metric on a differentiable manifoldhttps://ask.sagemath.org/question/49889/attributeerror-when-defining-a-metric-on-a-differentiable-manifold/ Hello everyone,
I am getting started with SageMath and try to define a metric on a differential manifold. Despite tutorials, search online and asking questions to colleagues, I cannot understand the following error.
Here is the code, with Kernel SageMath 9.0
FM = Manifold(2,'FM', structure='Riemannian', start_index=1)
K = FM.metric('K')
K[1,1]=1
which generates the following error
AttributeError Traceback (most recent call last)
<ipython-input-17-f83570b8b1cf> in <module>()
1 K = FM.metric('K')
----> 2 K[Integer(1),Integer(1)]=Integer(1)
/ext/sage/sage-9.0/local/lib/python3.7/site-packages/sage/tensor/modules/free_module_tensor.py in __setitem__(self, args, value)
1629 else:
1630 basis = self._fmodule._def_basis
-> 1631 self.set_comp(basis)[args] = value
1632
1633 def copy_from(self, other):
/ext/sage/sage-9.0/local/lib/python3.7/site-packages/sage/manifolds/differentiable/tensorfield_paral.py in set_comp(self, basis)
883 self._is_zero = False # a priori
884
--> 885 if basis._domain == self._domain:
886 # Setting components on the tensor field domain:
887 return FreeModuleTensor.set_comp(self, basis=basis)
AttributeError: 'One' object has no attribute '_domain'
It seems that the index type in the metric is wrong. Is that the problem? Have you some ideas to solve the problem?
Thanks
A.Wed, 12 Feb 2020 08:36:37 -0600https://ask.sagemath.org/question/49889/AttributeError using metric on differential manifoldhttps://ask.sagemath.org/question/49888/attributeerror-using-metric-on-differential-manifold/ Hello everyone,
I am getting started with SageMath and try to define a metric on a differential manifold. Despite tutorials, search online and asking questions to colleagues, I cannot understand the following error.
Here is the code, with Kernel SageMath 9.0
FM = Manifold(2,'FM', structure='Riemannian', start_index=1)
K = FM.metric('K')
K[1,1]=1
which generates the following error
AttributeError Traceback (most recent call last)
<ipython-input-17-f83570b8b1cf> in <module>()
1 K = FM.metric('K')
----> 2 K[Integer(1),Integer(1)]=Integer(1)
/ext/sage/sage-9.0/local/lib/python3.7/site-packages/sage/tensor/modules/free_module_tensor.py in __setitem__(self, args, value)
1629 else:
1630 basis = self._fmodule._def_basis
-> 1631 self.set_comp(basis)[args] = value
1632
1633 def copy_from(self, other):
/ext/sage/sage-9.0/local/lib/python3.7/site-packages/sage/manifolds/differentiable/tensorfield_paral.py in set_comp(self, basis)
883 self._is_zero = False # a priori
884
--> 885 if basis._domain == self._domain:
886 # Setting components on the tensor field domain:
887 return FreeModuleTensor.set_comp(self, basis=basis)
AttributeError: 'One' object has no attribute '_domain'
It seems that the index type in the metric is wrong. Is that the problem? Have you some ideas to solve the problem?
Thanks
A.Wed, 12 Feb 2020 08:35:10 -0600https://ask.sagemath.org/question/49888/Error: 'Object has no attribute 'intersection''https://ask.sagemath.org/question/43799/error-object-has-no-attribute-intersection/Hi, I am pretty new to SAGE and and am not understanding why my code keeps giving me the error **'RelativeOrder_with_category' object has no attribute 'intersection'**. Here is my code:
sage: P1=x^3-x^2-4*x-1
sage: P2=x^3+x^2-2*x-1
sage: K1.<p>=NumberField(P1)
sage: K2.<d>=NumberField(P2)
sage: K.<p,d>=ExtensionField(K1,P2)
sage: O_K=K.ring_of_integers()
sage: A_K1=O_K.intersection(K1)
AttributeError: 'RelativeOrder_with_category' object has no attribute 'intersection'
I have looked at a lot of examples from other questions, but I can't seem to find a solution.
northcity4Mon, 01 Oct 2018 01:51:51 -0500https://ask.sagemath.org/question/43799/Computing polyhedron from MIPhttps://ask.sagemath.org/question/33782/computing-polyhedron-from-mip/ I want to run the following code (I'm using SAGE v6.10 release version 2015-12-18):
P = MixedIntegerLinearProgram()
x = P.new_variable()
A = random_matrix(RR, 3, 2);
P.add_constraint(A*x <= [2.1,1.5,0.4])
P.polyhedron()
However, it outputs the error message:
> AttributeError: type object 'float'
> has no attribute 'fraction_field'
I noticed that if instead of using real variables I use only integer variables, then it works fine. For instance:
P = MixedIntegerLinearProgram()
x = P.new_variable()
A = random_matrix(ZZ, 3, 2);
P.add_constraint(A*x <= [2,1,0])
P.polyhedron()
outputs:
> A 2-dimensional polyhedron in QQ^2
> defined as the convex hull of 1 vertex
> and 2 rays
What do you suggest to overcome this problem?
ThanksmforetsTue, 14 Jun 2016 07:09:09 -0500https://ask.sagemath.org/question/33782/Help to understand an AttributeError in a polynomial ringhttps://ask.sagemath.org/question/36387/help-to-understand-an-attributeerror-in-a-polynomial-ring/ F. Chapoton recently wrote a program
the behaviour of which I do not understand.
def fermat(n):
q = polygen(ZZ, 'q')
return sum(n ** j * binomial(n, j) * (-1) ** (i + n + j) *
binomial(n - 2 - j + 1, i + 1) * q ** i
for j in range(n - 1)
for i in range(n - 1 - j))
Now consider:
v = fermat(5)
print v.parent()
print v.list()
This outputs
Univariate Polynomial Ring in q over Integer Ring
[821, 181, 21, 1]
which is fine. However the loop
for n in (1..9):
v = fermat(n)
print v.parent()
print v.list()
gives the errors:
AttributeError: 'int' object has no attribute 'parent'
AttributeError: 'int' object has no attribute 'list'
What happens here?
Peter LuschnyWed, 25 Jan 2017 16:33:10 -0600https://ask.sagemath.org/question/36387/Limit evaluatation from user input not workinghttps://ask.sagemath.org/question/33297/limit-evaluatation-from-user-input-not-working/ My code is:
t = raw_input()
#n = var('x')
u2 = raw_input()
(t).limit(x=u2)
(t).limit(x=u2+0.001)
(t).limit(x=u2+0.0001)
It gives me this error:
Error in lines 4-4
Traceback (most recent call last):
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
AttributeError: 'unicode' object has no attribute 'limit'
What am I doing wrong? I want to ask the user the function to be evaluated and the number that x approaches.user6502Mon, 02 May 2016 19:31:05 -0500https://ask.sagemath.org/question/33297/Error in rising_factorialhttps://ask.sagemath.org/question/32565/error-in-rising_factorial/ print [rising_factorial(n,n) for n in (0..5)]
print [rising_factorial(n,n) for n in range(6)]
I think both forms should give the same result. But the output is:
[1, 1, 6, 60, 840, 15120]
AttributeError: 'int' object has no attribute 'parent'
Edit: The same error is thrown for falling_factorial. Note that the factorial function does not
assume Sage-integers. This is a confusing inconsistency in the interface, at least.Peter LuschnyTue, 16 Feb 2016 03:59:07 -0600https://ask.sagemath.org/question/32565/Strange AttributeErrorhttps://ask.sagemath.org/question/10493/strange-attributeerror/In:
bool(-1/2*csc(3/8*pi + x)^2/cot(3/8*pi + x) + 1/cos(1/4*pi + 2*x) == 0)
Out:
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sin'
?petropolisSun, 01 Sep 2013 00:21:20 -0500https://ask.sagemath.org/question/10493/Error intersecting polyhedrahttps://ask.sagemath.org/question/10202/error-intersecting-polyhedra/I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:
v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
I get a very nasty error:
AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
(The traceback for the error is quite long. I can include it if needed.)
Manually computing
poly[1] & poly[2] & poly[3] & poly[4]
gives the same error. HOWEVER, if instead I compute
(poly[1] & poly[2]) & (poly[3] & poly[4])
I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like
poly[1].intersection(poly[2]) # etc.
doesn't help either. Any thoughts?BillThu, 06 Jun 2013 10:13:30 -0500https://ask.sagemath.org/question/10202/AttributeError on Oneiric Ocelothttps://ask.sagemath.org/question/8461/attributeerror-on-oneiric-ocelot/Hello,
I get the message "AttributeError: 'module' object has no attribute 'core'" when i try to define a vector using "vector" command like v = vector([1,2]). Does anyone knows what causes this and how can i fix it?
Edit: this is on Ubuntu 11.10 with an older version binary.OAThu, 10 Nov 2011 04:26:03 -0600https://ask.sagemath.org/question/8461/AttributeError: 'int' object has no attribute 'mod'https://ask.sagemath.org/question/8131/attributeerror-int-object-has-no-attribute-mod/Hello,
How can I solve the problem with an error message: "AttributeError: 'int' object has no attribute 'mod'" when executing the following program?
maxdeg = 5
maxord = maxdeg
for m in range(maxord + 1):
for l in range(m, maxdeg + 1):
print l, m, gen_legendre_P(l, m, z) # this uses "l.mod(2).is_zero()."
Sincerely,
KKondoKKondoThu, 26 May 2011 22:47:58 -0500https://ask.sagemath.org/question/8131/