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.Tue, 22 Dec 2020 22:22:45 +0100infinite if inside a loophttps://ask.sagemath.org/question/54852/infinite-if-inside-a-loop/I want to define a function that checks if a member of a set is another then print "well".
Let me explain it it the following example:
Assume that `Z = Compositions(17, min_part=4).list()`, `L` is some set and `f` is some function.
How I can write a function such that if `f(a)`, where `a` is a member of `Z`, was in `L`, then that is "well"?
My attempt:
for i in in srange(len(Z)):
for j in srange(i):
if f(Z[i][j]) in L:
I don't know how to finish it because I just know finite `if, else`, not more.Blue skyTue, 22 Dec 2020 22:22:45 +0100https://ask.sagemath.org/question/54852/conditions among the variableshttps://ask.sagemath.org/question/48809/conditions-among-the-variables/ Suppose I am defining some variables in sagemath. How can I give conditions among the variables such that the condition is applied in the future calculations?
Thank You.user789Tue, 19 Nov 2019 13:55:04 +0100https://ask.sagemath.org/question/48809/Translucency lost after applying add_condition methodhttps://ask.sagemath.org/question/48752/translucency-lost-after-applying-add_condition-method/I need to render translucent implicit surfaces satisfying some additional constraints, such as, for example, the portion of the hyperboloid $x^2+y^2-z^2=1$ which is above the paraboloid $z=(x-1)^2+y^2-1$. The problem I found is that the `opacity` property is not preserved after applying the `add_condition` method. To be more concrete, the following code plots a gray, translucent hyperboloid:
var("x,y,z")
texture = dict(color="gray", opacity=0.6)
s = implicit_plot3d(x^2+y^2-z^2==1, (x,-3,3), (y,-3,3), (z,-2.5,2.5), **texture)
opts = dict(viewer="threejs", decimals=1)
s.show(**opts)
Let us apply the constraint:
s1 = s.add_condition(lambda x,y,z: z>(x-1)^2+y^2-1,10)
s1.show(**opts)
One gets a gray, but opaque, surface. Translucency is lost. I have found the following workaround:
from sage.plot.plot3d.index_face_set import IndexFaceSet
s2 = IndexFaceSet(s1.face_list(), **texture)
s2.show(**opts)
which yields the expected result. So I wonder if the loss of translucency is a bug. Anyway, is there a better workaround?
This [Sagecell](https://sagecell.sagemath.org/?z=eJxlkcFOwzAMhu99Cmu7pCOr1k5wQCpHJM5M4rYpSwwNypoozkbTp8cdYxriEMlxbP-_v8xh01kC7Q1CtugMgYKPqLKEFFVP7qixT9DlgHHvnbemOKkoZoPMcpyVRcIhHSNCC8bqJDSXxHY2DZhJ8EFpm3K7qh7KgrjGHoKznNoF59PaiGHb3OVtsxy3TdvWEsQgl2u5LjnK12iUy6a6l3z4tlhcFMvCh0S_uieLX8jCqYuIn8TaBrU9KEdtzdIVdf5LLBZTS1kUc3hDUCG4zMtq3xubrO8heZjq4PNICVKHEHw8P6i9P-HExZ6wh6CiuqCYw-YKSWdgkM5TKqhmX1QpY3bX6cKpw94oOIN7hPFJDMu6vOxfy3rFNut_PjcdEoKzPRJE1Gwj3vyLzsV79Acg9YHVhLT64VrZ3uCwe1cad4Rpws6bwMuUfebkK7LHhj3eZgTLnzucpST-oqbmj7Nv3we6tA==&lang=sage&interacts=eJyLjgUAARUAuQ==) contains the above code.JuanjoFri, 15 Nov 2019 13:47:41 +0100https://ask.sagemath.org/question/48752/