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, 12 Dec 2017 04:06:39 +0100Error when trying to import without sage.allhttps://ask.sagemath.org/question/40116/error-when-trying-to-import-without-sageall/I am trying to import only the Sage functions needed as is done in the Sage source code, but I am running into issues. For example, (running `sage -python`),
>>> from sage.groups.group import Group
results in
...
from sage.rings.complex_double import CDF
File "sage/rings/real_double.pxd", line 8, in init sage.rings.complex_double (/export/pkgs/linux-rh6/sagemath-7.0/src/build/cythonized/sage/rings/complex_double.c:22654)
File "sage/rings/real_double.pyx", line 64, in init sage.rings.real_double (/export/pkgs/linux-rh6/sagemath-7.0/src/build/cythonized/sage/rings/real_double.c:25060)
ImportError: cannot import name ZZ
(I can post the full traceback if that would be helpful.) Similar things happen for almost any import I try. I was using the `import_statements` to determine what to import.
Am I missing something?
EDIT:
I think I get the picture a little better now. The Sage source files aren't meant to be imported in Python, they are meant to be imported into Sage, which presumably runs `import sage.all` when it starts.jaebondTue, 12 Dec 2017 04:06:39 +0100https://ask.sagemath.org/question/40116/File imports for polynomial rings in sagehttps://ask.sagemath.org/question/7584/file-imports-for-polynomial-rings-in-sage/If i type in the following
R.<z1,z2> = PolynomialRing(GF(5),2,"z")
direclty to Sage it accepts it as a polynomial ring.
But if i place this in a .py file and load it from this Sage
eg `sage my.py` it gives me a syntax error.
I guess i need a module loaded for it to be detected, but which module and hence which command do i need to make Sage accept this ring.aeThu, 19 Aug 2010 11:41:02 +0200https://ask.sagemath.org/question/7584/Importing Sage functions into Cython?https://ask.sagemath.org/question/10121/importing-sage-functions-into-cython/I am playing around with Cython but I can't get it to work very well with Sage. As a very simple example of the problems I am having, the following code doesn't work. I know that the reason is that I need to import `numerical_integral()` from Sage somehow, but I don't know exactly how to do that.
%cython
numerical_integral(x^2, 0,1)
(This is something that's been confusing me for a few days now. I'm not sure if there's something about how Cython is supposed to be used that I am not understanding properly.)
EDIT: after trying out some things, I realized that `sage.gsl.integration.numerical_integral()` has the same effect as `numerical_integral()` in Sage. So, somehow, I should import the function from `sage.gsl.integration`, if that even makes any sense? Alan ChangTue, 14 May 2013 14:46:04 +0200https://ask.sagemath.org/question/10121/