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.Thu, 02 Dec 2021 02:33:37 +0100- sage not installing from sourcehttps://ask.sagemath.org/question/60029/sage-not-installing-from-source/I am running Ubuntu 21.04. I have cloned sagemath's source with git and run ```./configure``` folowed by ```make```. It terminates with errors. The first error is in cysignals-1.10.3. I can't attach the log files here since I do not have enough points. So I hope these are the relevant things from ```logs/pkgs/cysignals-1.10.3.log```:
```
Processing /home/brett/Projects/SAGE/sage/local/var/tmp/sage/build/cysignals-1.10.3/src
Created temporary directory: /tmp/pip-req-build-reb5uglo
DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
Added file:///home/brett/Projects/SAGE/sage/local/var/tmp/sage/build/cysignals-1.10.3/src to build tracker '/tmp/pip-req-tracker-31wllir1'
Running setup.py (path:/tmp/pip-req-build-reb5uglo/setup.py) egg_info for package from file:///home/brett/Projects/SAGE/sage/local/var/tmp/sage/build/cysignals-1.10.3/src
Created temporary directory: /tmp/pip-pip-egg-info-rmc2dd38
Running command python setup.py egg_info
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fdd4693a340>, 'Connection to 192.0.2.0 timed out. (connect timeout=15)')': /simple/cython/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fdd4693aa30>, 'Connection to 192.0.2.0 timed out. (connect timeout=15)')': /simple/cython/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fdd4693ab50>, 'Connection to 192.0.2.0 timed out. (connect timeout=15)')': /simple/cython/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fdd4693ac10>, 'Connection to 192.0.2.0 timed out. (connect timeout=15)')': /simple/cython/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fdd4693acd0>, 'Connection to 192.0.2.0 timed out. (connect timeout=15)')': /simple/cython/
ERROR: Could not find a version that satisfies the requirement Cython>=0.28 (from versions: none)
ERROR: No matching distribution found for Cython>=0.28
Traceback (most recent call last):
File "/home/brett/Projects/SAGE/sage/local/lib/python3.9/site-packages/setuptools/installer.py", line 75, in fetch_build_egg
subprocess.check_call(cmd)
File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/brett/Projects/SAGE/sage/local/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpbhnfluj1', '--quiet', 'Cython>=0.28']' returned non-zero exit status 1.
```
One thing I noticed is that it seems to be looking for cython version >= 0.28. ```./configure``` says
> cython-0.29.21: standard, will be installed as an SPKG
but ```python3 -m pip install cython``` reports that python v0.29 is installed:
> Requirement already satisfied: cython in /home/brett/.local/lib/python3.9/site-packages (0.29.24)brettpimThu, 02 Dec 2021 02:33:37 +0100https://ask.sagemath.org/question/60029/
- failure to compile cython .pyx when cimporting some function from sagehttps://ask.sagemath.org/question/58659/failure-to-compile-cython-pyx-when-cimporting-some-function-from-sage/Hello,
I am working on a Sage graph project, and for optimization,
I have chosen to move it to Cython.
The code compiles just fine as is, but for further optimization
I will need to use a union find data structure in my `cdef` function.
So far, I was using `DisjointSet` from `sage.sets.disjoint_set`
in a separate function: my issue is I do not know
how to `cdef` such an object.
My initial attempt to solve this was to `cimport`
the disjoint set class from the `sage/sets/disjoint_set.pyx` file,
and use it to `cdef`.
This would in summary be something like this :
...
from sage.sets.disjoint_set cimport DisjointSet_of_hashables
cdef DisjointSet_of_hashables D
D = DisjointSet(10)
...
Though this does not compile : I get an error related to a library
(that I assumed was included in the install of Sage).
Just in case it was not, I manually installed GAP
(which did not solve the problem).
/usr/bin/ld : ne peut trouver -lgap
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
This message is partly in French but it translates exactly to
/usr/bin/ld: cannot find -lgap
I believe this is mostly likely due to me misunderstanding
how to import a class from the Sage Cython files.
I had a similar problem when trying to work with bitsets
(although the error was on the library PARI instead of GAP).
In case it is relevant, I am working on Ubuntu 20.04,
installed Sage with apt (Sage version is 9.0).
Thank you in advance for any help.
PierrepierreTue, 24 Aug 2021 17:17:33 +0200https://ask.sagemath.org/question/58659/
- TypeError: dist must be a Distribution instancehttps://ask.sagemath.org/question/58081/typeerror-dist-must-be-a-distribution-instance/Hi,
Suddenly, using Cython magic, I got the message **"TypeError: dist must be a Distribution instance"**.
I use Sage 9.3 Ubuntu with Jupyter and compile via %%cython -a.
I tried an other *ipynb* file, and there was no problem using Cython...<br>
Only one *ipynb* file seems to have this problem.
Further research shows that the probable cause is the use of **cython_lambda**.
Any solution is very appreciated.
RolandrolandThu, 22 Jul 2021 10:33:18 +0200https://ask.sagemath.org/question/58081/
- Cython / Sage: how to use Static Typing (cdef)?https://ask.sagemath.org/question/56519/cython-sage-how-to-use-static-typing-cdef/I'm looking at Sage developer guide for Cython:
https://doc.sagemath.org/html/en/developer/coding_in_cython.html
But I cannot find information about how to use static typing, which is what enables Cython (not necessarily in the context of Sage) to reach C-like performance. Since objects in Sage often have complicated types (expressions, polynomials), how would type declarations (cdef in Cython) work?
P.S. Does Cython have some type inference capability (like the "auto" keyword in C++) so the user can avoid typing long type names?greatpetTue, 06 Apr 2021 13:01:20 +0200https://ask.sagemath.org/question/56519/
- To call sagemath program (jupyter notebook) from c programhttps://ask.sagemath.org/question/54161/to-call-sagemath-program-jupyter-notebook-from-c-program/Hi, Actually I am implementing an attack on cipher. For that I need some SAT computation. Since SAT computation can be done easily in SAGEMATH. So my program looks something like:
----------
1. I write some code in C
2. Then I will pass some input to SAT i.e. to SAGEMATH (jupyter notebook)
3. Take the output in C , verify
4. Again run 1,2,3 for finite number of times.
----------
I check SAGE documentation for a piece of Cython code but that worked for small example but the program gets complicated it returns some error.
Can you guide me in this way or provide me some references? Which is faster calling sage from c OR calling c from sage jupyter notebook?
Thanks for your help.SatyamSun, 08 Nov 2020 13:57:25 +0100https://ask.sagemath.org/question/54161/
- Using matrices in Cythonhttps://ask.sagemath.org/question/53856/using-matrices-in-cython/I want to work with matrices in Cython.
But I cannot even define a matrix. Here is the code in my Sage notebook:
sage:%%cython
sage:A=Matrix([[1,0],[0,1]])
Here is the error messsage:
RuntimeError: Error compiling Cython file:
------------------------------------------------------------
...
from sage import all
A=Matrix([[1,0],[0,1]]) ^
------------------------------------------------------------
_Users_macbook__sage_temp_bogon_52702_tmp_jzby0ki0_pyx_0.pyx:2:2: undeclared name not builtin: Matrix
In the end, my goal is to make use of this library in Cython:
matrix/matrix_integer_dense.pyx
Thanks for your help1571Mon, 12 Oct 2020 03:21:48 +0200https://ask.sagemath.org/question/53856/
- Echelon form in cythonhttps://ask.sagemath.org/question/53685/echelon-form-in-cython/Is there an already function implemented in Cython which computes the echelon form of an integer matrix?
Thanks for the help.1571Thu, 01 Oct 2020 12:36:01 +0200https://ask.sagemath.org/question/53685/
- How to use finite fields in cython?https://ask.sagemath.org/question/51411/how-to-use-finite-fields-in-cython/To use finite fields there is the function GF.
It works well in python, but produces the following error in cython:
`undeclared name not builtin: GF`
How to use finite fields in cython?Sébastien PalcouxThu, 14 May 2020 22:40:35 +0200https://ask.sagemath.org/question/51411/
- Cython class : iterate over cdef'ed membershttps://ask.sagemath.org/question/50501/cython-class-iterate-over-cdefed-members/Dear all,
my question is in the title : for some reason it may be usefull to me to iterate over a cdef'ed class cdef'ed members. I inherit from sage.calculus.ode.ode_system for ODE computation.
cdef class trapModelImporter(sage.calculus.ode.ode_system):
cdef double ASi, NSi, AGe, NGe, AEr, NEr, BEr, C,BSi, PSi, BAl, PAl, g;
def setParams(self,pdict):
All the members have default values and I want to customize some of them.
The aim of this iteration through the members should be to associate a value from the "pdict" parameter of setParam.
This parameter is intended to associate keys which names are Asi, NSi, etc, with their new value.
I tried by generating a string and using "exec" but it did not work, i belive it coms from cython itself.
I am not sure it is possible that way, but that seemed to be an efficient way to change only the wanted paremeters.
Is that possible ?
Regards,
MikeMika007Fri, 03 Apr 2020 20:13:52 +0200https://ask.sagemath.org/question/50501/
- Problem with %attach for SageMath 9.0 on Windows 10 with .spyx fileshttps://ask.sagemath.org/question/44176/problem-with-attach-for-sagemath-90-on-windows-10-with-spyx-files/> EDIT (01/02/2020) on version 9.0.
Consider a source code reduced to the following line:
# %attach SAGE/AttachTest.spyx
When I attach it the first time, it is OK, but if I **save again** the source code, there is the following problem (which appears from version 8.3 or less). How to fix this problem?
Note that this problem is specific to .spyx files, as everything works well for .sage files.
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.0, Release Date: 2020-01-01 │
│ Using Python 3.7.3. Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: %attach SAGE/AttachTest.spyx
Compiling ./SAGE/AttachTest.spyx...
sage: 0 [main] python3.7 1214 child_info_fork::abort: unable to map \??\C:\Users\SÃ©bastien Palcoux\.sage\temp\LAPTOP-7O5QV19T\1192\spyx\_home_sage_SAGE_AttachTest_spyx\_home_sage_SAGE_A
ttachTest_spyx_0.dll (using C:\Users\SÃ©bastien Palcoux\.sage\temp\LAPTOP-7O5QV19T\1192\spyx\_home_sage_SAGE_AttachTest_spyx\_home_sage_SAGE_AttachTest_spyx_0.dll), Win32 error 126
### reloading attached file AttachTest.spyx modified at 05:48:32 ###
Compiling /home/sage/SAGE/AttachTest.spyx...
---------------------------------------------------------------------------
BlockingIOError Traceback (most recent call last)
/opt/sagemath-9.0/local/lib/python3.7/site-packages/pkgconfig/pkgconfig.py in _wrapper(*args, **kwargs)
59 try:
---> 60 return func(*args, **kwargs)
61 except OSError as e:
/opt/sagemath-9.0/local/lib/python3.7/site-packages/pkgconfig/pkgconfig.py in _query(package, *options)
69 cmd = '{0} {1} {2}'.format(pkg_config_exe, ' '.join(options), package)
---> 70 proc = Popen(shlex.split(cmd), stdout=PIPE, stderr=PIPE)
71 out, err = proc.communicate()
/opt/sagemath-9.0/local/lib/python3.7/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
774 errread, errwrite,
--> 775 restore_signals, start_new_session)
776 except:
/opt/sagemath-9.0/local/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1452 errpipe_read, errpipe_write,
-> 1453 restore_signals, start_new_session, preexec_fn)
1454 self._child_created = True
BlockingIOError: [Errno 11] Resource temporarily unavailable
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
<ipython-input-2-7b41dee30a81> in <module>()
----> 1 sage.repl.load.load(sage.repl.load.base64.b64decode("L2hvbWUvc2FnZS9TQUdFL0F0dGFjaFRlc3Quc3B5eA=="),globals(),True)
/opt/sagemath-9.0/local/lib/python3.7/site-packages/sage/repl/load.py in load(filename, globals, attach)
274 if attach:
275 add_attached_file(fpath)
--> 276 exec(load_cython(fpath), globals)
277 elif ext == '.f' or ext == '.f90':
278 from sage.misc.inline_fortran import fortran
/opt/sagemath-9.0/local/lib/python3.7/site-packages/sage/repl/load.py in load_cython(name)
65 """
66 from sage.misc.cython import cython
---> 67 mod, dir = cython(name, compile_message=True, use_cache=True)
68 import sys
69 sys.path.append(dir)
/opt/sagemath-9.0/local/lib/python3.7/site-packages/sage/misc/cython.py in cython(filename, verbose, compile_message, use_cache, create_local_c_file, annotate, sage_namespace, create_local_so_file)
324 try:
325 ext, = cythonize([ext],
--> 326 aliases=cython_aliases(),
327 include_path=includes,
328 compiler_directives=directives,
/opt/sagemath-9.0/local/lib/python3.7/site-packages/sage/env.py in cython_aliases()
392 for lib in ['fflas-ffpack', 'givaro', 'gsl', 'linbox', 'Singular']:
393 var = lib.upper().replace("-", "") + "_"
--> 394 aliases[var + "CFLAGS"] = pkgconfig.cflags(lib).split()
395 pc = pkgconfig.parse(lib)
396 # INCDIR should be redundant because the -I options are also
/opt/sagemath-9.0/local/lib/python3.7/site-packages/pkgconfig/pkgconfig.py in cflags(package)
106 If ``pkg-config`` not on path, raises ``EnvironmentError``.
107 """
--> 108 return _query(package, '--cflags')
109
110
/opt/sagemath-9.0/local/lib/python3.7/site-packages/pkgconfig/pkgconfig.py in _wrapper(*args, **kwargs)
60 return func(*args, **kwargs)
61 except OSError as e:
---> 62 raise EnvironmentError("pkg-config is probably not installed. Could not run pkg-config: %r"%e)
63 return _wrapper
64
OSError: pkg-config is probably not installed. Could not run pkg-config: BlockingIOError(11, 'Resource temporarily unavailable')
sage:Sébastien PalcouxSat, 03 Nov 2018 20:27:46 +0100https://ask.sagemath.org/question/44176/
- Cython: undeclared name not builtinhttps://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/Loading a .spyx file with
def bla(W):
RootSystem(W.cartan_type())
yields
undeclared name not builtin: RootSystem
Is there a library that I need to include?Bob67846Fri, 03 Jan 2020 17:32:28 +0100https://ask.sagemath.org/question/49341/
- Cython problem with map-reducehttps://ask.sagemath.org/question/46839/cython-problem-with-map-reduce/Below some minimal code using map-reduce:
# %attach SAGE/test.spyx
from sage.parallel.map_reduce import RESetMapReduce
cpdef test(int n):
S = RESetMapReduce(roots = [[]],children = lambda l: [l+[0], l+[1]] if len(l) <= n else [],map_function = lambda x : 1,reduce_function = lambda x,y: x+y,reduce_init = 0)
return S.run()
whose compilation reveals a Cython problem `Error compiling Cython file` , `AttributeError: 'ClosureScope' object has no attribute 'scope_class'`, see below:
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.3, Release Date: 2018-08-03 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: %attach SAGE/test.spyx
Compiling ./SAGE/test.spyx...
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-1-506a10c79ce0> in <module>()
----> 1 get_ipython().magic(u'attach SAGE/test.spyx')
/opt/sagemath-8.3/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
2158 magic_name, _, magic_arg_s = arg_s.partition(' ')
2159 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2160 return self.run_line_magic(magic_name, magic_arg_s)
2161
2162 #-------------------------------------------------------------------------
/opt/sagemath-8.3/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
2079 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2080 with self.builtin_trap:
-> 2081 result = fn(*args,**kwargs)
2082 return result
2083
<decorator-gen-115> in attach(self, s)
/opt/sagemath-8.3/local/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):
/opt/sagemath-8.3/local/lib/python2.7/site-packages/sage/repl/ipython_extension.pyc in attach(self, s)
156 sage: shell.quit()
157 """
--> 158 return self.shell.ex(load_wrap(s, attach=True))
159
160 @line_magic
/opt/sagemath-8.3/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in ex(self, cmd)
2421 """Execute a normal python statement in user namespace."""
2422 with self.builtin_trap:
-> 2423 exec(cmd, self.user_global_ns, self.user_ns)
2424
2425 def ev(self, expr):
<string> in <module>()
/opt/sagemath-8.3/local/lib/python2.7/site-packages/sage/repl/load.pyc in load(filename, globals, attach)
265 if attach:
266 add_attached_file(fpath)
--> 267 exec(load_cython(fpath), globals)
268 elif ext == '.f' or ext == '.f90':
269 from sage.misc.inline_fortran import fortran
/opt/sagemath-8.3/local/lib/python2.7/site-packages/sage/repl/load.pyc in load_cython(name)
65 """
66 from sage.misc.cython import cython
---> 67 mod, dir = cython(name, compile_message=True, use_cache=True)
68 import sys
69 sys.path.append(dir)
/opt/sagemath-8.3/local/lib/python2.7/site-packages/sage/misc/cython.pyc in cython(filename, verbose, compile_message, use_cache, create_local_c_file, annotate, sage_namespace, create_local_so_file)
636 You can fix your code by adding "from {} cimport {}".
637 """.format(pxd, name))
--> 638 raise RuntimeError(cython_messages.strip())
639
640 if verbose >= 0:
RuntimeError: Error compiling Cython file:
------------------------------------------------------------
...
# %attach SAGE/test.spyx
from sage.parallel.map_reduce import RESetMapReduce
cpdef test(int n):
^
------------------------------------------------------------
_home_sage_SAGE_test_spyx_0.pyx:5:6: closures inside cpdef functions not yet supported
Error compiling Cython file:
------------------------------------------------------------
...
# %attach SAGE/test.spyx
from sage.parallel.map_reduce import RESetMapReduce
cpdef test(int n):
S = RESetMapReduce(roots = [[]],children = lambda l: [l+[0], l+[1]] if len(l) <= n else [],map_function = lambda x : 1,reduce_function = lambda x,y: x+y,reduce_init = 0)
^
------------------------------------------------------------
_home_sage_SAGE_test_spyx_0.pyx:6:44: Compiler crash in CreateClosureClasses
ModuleNode.body = StatListNode(_home_sage_SAGE_test_spyx_0.pyx:3:0)
StatListNode.stats[1] = CFuncDefNode(_home_sage_SAGE_test_spyx_0.pyx:5:6,
args = [...]/1,
modifiers = [...]/0,
needs_closure = True,
overridable = 1,
visibility = u'private')
CFuncDefNode.body = StatListNode(_home_sage_SAGE_test_spyx_0.pyx:6:1,
is_terminator = True)
StatListNode.stats[0] = SingleAssignmentNode(_home_sage_SAGE_test_spyx_0.pyx:6:19)
SingleAssignmentNode.rhs = GeneralCallNode(_home_sage_SAGE_test_spyx_0.pyx:6:19,
is_temp = 1,
result_is_used = True,
use_managed_ref = True)
GeneralCallNode.keyword_args = DictNode(_home_sage_SAGE_test_spyx_0.pyx:6:20,
is_dict_literal = True,
is_temp = 1,
obj_conversion_errors = [...]/0,
reject_duplicates = True,
result_is_used = True,
use_managed_ref = True)
DictNode.key_value_pairs[1] = DictItemNode(_home_sage_SAGE_test_spyx_0.pyx:6:33,
result_is_used = True,
use_managed_ref = True)
DictItemNode.value = LambdaNode(_home_sage_SAGE_test_spyx_0.pyx:6:44,
args = [...]/1,
binding = True,
is_temp = 1,
lambda_name = 'lambda',
name = u'<lambda>',
needs_closure = True,
needs_self_code = True,
pymethdef_cname = u'__pyx_mdef_27_home_sage_SAGE_test_spyx_0_4test_lambda',
result_is_used = True,
use_managed_ref = True)
Compiler crash traceback from this point on:
File "Cython/Compiler/Visitor.py", line 180, in Cython.Compiler.Visitor.TreeVisitor._visit
return handler_method(obj)
File "/opt/sagemath-8.3/local/lib/python2.7/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 2764, in visit_LambdaNode
self.create_class_from_scope(node.def_node, self.module_scope, node)
File "/opt/sagemath-8.3/local/lib/python2.7/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 2713, in create_class_from_scope
func_scope.scope_class = cscope.scope_class
AttributeError: 'ClosureScope' object has no attribute 'scope_class'Sébastien PalcouxThu, 06 Jun 2019 22:51:24 +0200https://ask.sagemath.org/question/46839/
- How to implement a parallelization?https://ask.sagemath.org/question/46682/how-to-implement-a-parallelization/Consider a code of the kind *tree exploration amassing fruits*: when the procedure arrives to a new node of the tree, if it is a leaf a possible fruit is collected, else a computation is done to determine the children of the node. I would like to parallelize as follows: the children are allocated to all the available CPUs, each CPU has a queue and a given child is allocated to the CPU with the smallest queue.
It seems to be a generic way to parallelize such a tree exploration.
**Question**: How to implement such a parallelization?
In addition, how to use GPU (for HPC)?
The code has the following form:
cpdef function(list L1, list L2):
cdef int i,n #...
cdef list LL1,LL2 #...
#...
# core of the code
#...
n= #...
for i in range(n):
LL1= #...
LL2= #...
function(LL1,LL2)Sébastien PalcouxMon, 27 May 2019 07:14:24 +0200https://ask.sagemath.org/question/46682/
- How to write a standalone cython script?https://ask.sagemath.org/question/46097/how-to-write-a-standalone-cython-script/To use Cython in sage, according to the [document](http://doc.sagemath.org/html/en/developer/coding_in_cython.html), you can either write Cython code in a sage notebook, load a .spyx file from command line, or create a .pyx file and add it to the sage library.
My question is, can we write a standalone cython script and run it with sage? Just like a normal sage standalone script.ablmfThu, 11 Apr 2019 18:10:44 +0200https://ask.sagemath.org/question/46097/
- Sage Floyd algorithm in Cythonhttps://ask.sagemath.org/question/44823/sage-floyd-algorithm-in-cython/Hi
Classical Floyd algorithm computes all shortest path in a **weighted** graph and this algorithm has a $O(n^3)$ complexity (-> it can be slow). So i'm a bit surprised to see that the Cython version provided in Sage works only if `by_weight==False` meaning that all weights are 1 by default (its computes the transitive closure of the graph).
As a consequence, does it mean the only way to compute the "true" all-shortest-path in Sage is by using the pure Python implementation ?elasticaMon, 31 Dec 2018 10:53:04 +0100https://ask.sagemath.org/question/44823/
- How to run Cython examples in SageMathCellhttps://ask.sagemath.org/question/43786/how-to-run-cython-examples-in-sagemathcell/Hi, this is not a math question, this is a programming question.
I'm trying to run the first example at doc.sagemath.org/html/en/thematic_tutorials/cython_interface by using SageMathCell service ([link](http://doc.sagemath.org/html/en/thematic_tutorials/cython_interface.html)).
For this, I've created a zip folder that I've stored in the cloud (Google Drive).
When I run the following python script in SageMathCell (I wrote it to test Cython capabilities in SageMath remote server), it seems good, but I can't see the output, that would be "Hello World".
This python script, after execution, ends with "Compiling ./Call_C_code/hello_sage.pyx..." without anyone else output.
Can you help me?
Thanks,
import os
import tempfile
import sys
from distutils.dir_util import copy_tree
directory_name = tempfile.mkdtemp()
print(directory_name)
sys.path.append(directory_name)
#https://drive.google.com/open?id=129vvaCzB0M5iuPxdSdNWRG5A2gG0DwEu
import urllib
url = "https://drive.google.com/uc?export=download&id=129vvaCzB0M5iuPxdSdNWRG5A2gG0DwEu"
filename = "/Call_C_code.zip"
urllib.urlretrieve(url, directory_name + filename)
# opening the zip file in READ mode
from zipfile import ZipFile
os.chdir(directory_name)
file_name = "Call_C_code.zip"
with ZipFile(file_name, 'r') as zip:
# extracting all the files
print('Extracting all the files now...')
zip.extractall()
print('Done!')
print(sys.path)
print(os.getcwd())
for root, dirs, files in os.walk("."):
for filename in files:
print(filename)
#############
%runfile Call_C_code/hello_sage.pyx
my_bridge_function()MatteoThu, 27 Sep 2018 17:20:24 +0200https://ask.sagemath.org/question/43786/
- How to compute on Cython mode with 64-bit int?https://ask.sagemath.org/question/43832/how-to-compute-on-cython-mode-with-64-bit-int/The computation is on SageMath 8.3, on a 64-bit computer.
If the integers are less than $2^{31}$ everything is alright:
sage: %time champions(2**30,2**30+10)
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 2.15 ms
But if the integers are greater than $2^{31}$, there is a problem `OverflowError: value too large to convert to int`.
sage: champions(2**31,2**31+10)
---------------------------------------------------------------------------
OverflowError Traceback (most recent call last)
<ipython-input-7-2a762f4cafd8> in <module>()
----> 1 champions(Integer(2)**Integer(31),Integer(2)**Integer(31)+Integer(10))
/home/sage/.sage/temp/LAPTOP-7O5QV19T/9856/spyx/_home_sage_SAGE_EulerRH_spyx/_home_sage_SAGE_EulerRH_spyx_0.pyx in _home_sage_SAGE_EulerRH_spyx_0.champions()
12 return len(list(factor(n)))
13
---> 14 cpdef champions(int m1, int m2):
15 cdef int n,o,s,p,pr
16 cdef float a,c
OverflowError: value too large to convert to int
Here is the code:
from sage.all import *
cpdef g(float x):
return x/(exp(float(euler_gamma))*ln(ln(x)))
cpdef omega(int n):
return len(list(factor(n)))
cpdef champions(int m1, int m2):
cdef int n,o,s,p,pr
cdef float a,c
a=1.7683358; s=2; p=3; pr=6; n=m1
while n<=m2:
if mod(n,10**7)==0:
print(n)
if n>pr:
p=next_prime(p); pr*=p; s+=1
o=omega(n)
if n<>pr:
c=(euler_phi(n)/g(float(n)))**(1/float(s-o))
if c>a:
a=c
print([n,a,factor(Integer(pr)/Integer(n))])
n+=1Sébastien PalcouxFri, 05 Oct 2018 11:52:59 +0200https://ask.sagemath.org/question/43832/
- Importing Sage functions into Cython?https://ask.sagemath.org/question/42277/importing-sage-functions-into-cython/ I am trying to define variables in Cython part of my code like this
a,b,c = var('a,b,c')
But in this line I cant import var() function from Sage
from sage.calculus.var import var
I got this error:
$ sage -python real_sage.sage
Compiling ./real_sage.spyx...
Traceback (most recent call last):
File "real_sage.sage", line 6, in <module>
from real_sage import foo
File "real_sage.pyx", line 10, in init real_sage
File "sage/calculus/var.pyx", line 6, in init sage.calculus.var
File "/home/tunamustafakemal/sega/SageMath/local/lib/python2.7/site-packages/sage/symbolic/function_factory.py", line 15, in <module>
from sage.symbolic.function import SymbolicFunction, sfunctions_funcs, \
File "sage/rings/integer.pxd", line 7, in init sage.symbolic.function
File "sage/rings/rational.pxd", line 8, in init sage.rings.integer
File "sage/rings/rational.pyx", line 89, in init sage.rings.rational
File "sage/rings/real_mpfr.pyx", line 1, in init sage.rings.real_mpfr
File "sage/rings/complex_number.pxd", line 6, in init sage.libs.mpmath.utils
File "sage/rings/complex_double.pxd", line 10, in init sage.rings.complex_number
File "sage/rings/complex_double.pyx", line 94, in init sage.rings.complex_double
ImportError: cannot import name complex_number
Thanks for any support.tunaMon, 07 May 2018 06:14:53 +0200https://ask.sagemath.org/question/42277/
- Avoid recompilation of .spyx filehttps://ask.sagemath.org/question/41455/avoid-recompilation-of-spyx-file/ I have a script I am running many times with a .spyx file. Unfortunately each compilation creates a large temporary file, and these are eating up my disk quota so it now no longer runs. What do I do to avoid this situation? Ideally I compile once and sage uses that for all executions.watson_laddFri, 09 Mar 2018 18:43:39 +0100https://ask.sagemath.org/question/41455/
- Mixing %cython and @interact in one cellhttps://ask.sagemath.org/question/40417/mixing-cython-and-interact-in-one-cell/I'm trying to make an interactive applet to visualize the Mandelbrot Set, much in the way of the implementation of interactive fractals (wiki.sagemath.org/interact/fractal#Exploring_Mandelbrot - cannot copy full link because of not enough karma ;-))
But I'd like to embed the applet in a webpage using SageMathCell, and for this all the code must be encapsulated in just one cell, something in the following scheme
%cython
def function(...)
...
@interact
...
Unfortunately, `%cython` and `@interact` behave badly together, because the latter is unknown to the former (just try to join the code in the two cells of the example above or try the following minimal working example
%cython
def square(float x0):
return x0*x0
@interact
def _(x0=-2.5):
print(square(x0))
which, surprisingly enough, raises different errors in a online Sage Cell and in a Sage Notebook Cell)
Which would be the smartest way to mix everything up? Any suggestion is highly appreciated.jepstraMon, 01 Jan 2018 14:03:14 +0100https://ask.sagemath.org/question/40417/
- Is there a way do declare a python function or fast_callable fo a cython function ?https://ask.sagemath.org/question/40252/is-there-a-way-do-declare-a-python-function-or-fast_callable-fo-a-cython-function/I want to get efficient code for a repetitive computation on a "grid" of arguments, using a runtime-defined function (passed as an argument). Basically :
def myfunc(f, somerange, someotherrange):
initstorage()
for x in somerange:
for y in someotherrange:
store(x,y,dosomething(f,x,y))
return storage
In order to accelerate things, I'd like to write myfunc in cython.
I can safely assume that my numerical arguments (`x ` and `y`) will be coerced to double, so I can further accelerate things gy declaring them as typed. The problem is the function argument `f`. I can test the nature of `f` (e. g. before `initstorage()` and set `dosomething` to a special_case function according to this nature.
There are basically four cases :
* a symbolic expression : it seems that, in most cases, it pays to generate a `fast_callable`.
* a `fast_callable`.
* a Python function or a lambda expression.
* a Cython function declared as `cpdef`, or a C/C++ function suitably imported.
For this last case, I know the solution : it is enough to declare the relevant function signature with `ctypedef`, and use this type in the declaration of my function :
ctypedef double (*mytype)(double, double)
and use it to declare `myfunc` :
cpdef myfunc(mytype, double, double): #see above...
with the benefit of acceleration due to static typing.
Can something analogous be done in the three other cases (or possibly in the `fast_callable` and Python function cases, an expression being convertible to the `fast_callable` case) ?Emmanuel CharpentierWed, 20 Dec 2017 11:55:01 +0100https://ask.sagemath.org/question/40252/
- problems with attach on Machttps://ask.sagemath.org/question/36294/problems-with-attach-on-mac/I am having problems with attaching a file to a notebook. At first Sage cannot find cython, when I removed the cython calls sage cannot find parallel. See the code fragments and error below.
The code works as written when contained in the notebook. Am I doing something wrong or is this a bug?
Thank you for your help.
Mike
The code is:
...
cython("""
import numpy as np
import scipy as sp
from scipy import linalg
cimport numpy as np
cdef extern from "math.h":
float cosf(float theta)
float sinf(float theta)
def shape_calc_cy(Omega_array_stuff):
Omega_array_pt = Omega_array_stuff[0]
rf_shape = Omega_array_stuff[1]
t_step = Omega_array_stuff[2]
phi_p = Omega_array_stuff[3]
def pulse(Omega_0, omega_nut, t_p, phi_p):
Brot = np.matrix([[0,-Omega_0,omega_nut*sinf(phi_p)],[Omega_0,0,-omega_nut*cosf(phi_p)],[-omega_nut*sinf(phi_p),omega_nut*cosf(phi_p),0]],dtype = np.complex128)
return sp.linalg.expm(np.dot(Brot,t_p))
MPs = np.array([0,0,1],dtype = np.complexfloating)
for s in range(len(rf_shape)):
tmp = MPs
MPs = np.dot(pulse(Omega_array_pt, rf_shape[s], t_step, phi_p[s]),tmp)
return MPs
""")
...
The error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_5.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dz13YWxsdGltZSgpCmF0dGFjaCAoIi9Vc2Vycy9taWNoYWVsL01IRl9CbG9jaF9uX1Bsb3Rfb3JpX2N5dGhvbi5zYWdlIikgIyBBdHRhY2ggbXkgQmxvY2ggcm91dGluZXMKYXR0YWNoZWRfZmlsZXMoKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/j8/d2zfx1m16zv25klkgh71rjv40000gn/T/tmpcqrA7g/___code___.py", line 3, in <module>
attach ("/Users/michael/MHF_Bloch_n_Plot_ori_cython.sage") # Attach my Bloch routines
File "sage/misc/lazy_import.pyx", line 389, in sage.misc.lazy_import.LazyImport.__call__ (/Users/michael/sage-7.5/src/build/cythonized/sage/misc/lazy_import.c:4007)
File "/Users/michael/sage-7.5/local/lib/python2.7/site-packages/sage/repl/attach.py", line 349, in attach
load(filename, globals(), attach=True)
File "/Users/michael/sage-7.5/local/lib/python2.7/site-packages/sage/repl/load.py", line 242, in load
exec(code, globals)
File "/Users/michael/.sage/temp/Michaels-MBP.freystuff.com/83858/MHF_Bloch_n_Plot_ori_cython.sagemdLt2C.py", line 193, in <module>
cython("""
NameError: name 'cython' is not define
The parallel code:
import multiprocessing
@parallel('fork', ncpus = (multiprocessing.cpu_count()))
def shape_calc(Omega_array_stuff):
return shape_calc_cy(Omega_array_stuff)
The parallel error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_7.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dz13YWxsdGltZSgpCmF0dGFjaCAoIi9Vc2Vycy9taWNoYWVsL01IRl9CbG9jaF9uX1Bsb3Rfbm9fY3l0aG9uLnNhZ2UiKSAjIEF0dGFjaCBteSBCbG9jaCByb3V0aW5lcwphdHRhY2hlZF9maWxlcygp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/j8/d2zfx1m16zv25klkgh71rjv40000gn/T/tmpuKkIzm/___code___.py", line 3, in <module>
attach ("/Users/michael/MHF_Bloch_n_Plot_no_cython.sage") # Attach my Bloch routines
File "sage/misc/lazy_import.pyx", line 389, in sage.misc.lazy_import.LazyImport.__call__ (/Users/michael/sage-7.5/src/build/cythonized/sage/misc/lazy_import.c:4007)
File "/Users/michael/sage-7.5/local/lib/python2.7/site-packages/sage/repl/attach.py", line 349, in attach
load(filename, globals(), attach=True)
File "/Users/michael/sage-7.5/local/lib/python2.7/site-packages/sage/repl/load.py", line 242, in load
exec(code, globals)
File "/Users/michael/.sage/temp/Michaels-MBP.freystuff.com/83858/MHF_Bloch_n_Plot_no_cython.sagesTGITt.py", line 216, in <module>
@parallel('fork', ncpus = (multiprocessing.cpu_count()))
NameError: name 'parallel' is not definedmhfreySun, 15 Jan 2017 02:10:09 +0100https://ask.sagemath.org/question/36294/
- Suppress error warnings from Cythonized codehttps://ask.sagemath.org/question/36004/suppress-error-warnings-from-cythonized-code/The following Python code
n = 6.58
c0 = 1.1275
l = c0 - c0^(n+1)/(n+1)
c1 = 0.832857588520877
def f(c):
return real( 1 / sqrt( c - c^(n+1)/(n+1) - l ) )
c = var('c')
integral = numerical_integral( f(c), ( c1, c0 ) )
print(integral)
gives an error message along with a numeric result
Exception KeyError: (3,) in 'sage.gsl.integration.c_ff' ignored
(1.7927361507678317, 1.5185983395728818e-06)
The numeric result matches an evaluation in Mathemtica, so I'd just like to suppress the error message. Since it arises in the Cythonized GSL C library, regular Python error handling with `try/except` or the `warnings` module doesn't appear able to do so.
The error message will go away if I add a small amount like 10<sup>-10</sup> to the lower integration limit, but I'd like to know in general how to handle errors arising in Cythonized code.paulmassonWed, 14 Dec 2016 01:29:38 +0100https://ask.sagemath.org/question/36004/
- brial and cython failed to build while building Sagehttps://ask.sagemath.org/question/35240/brial-and-cython-failed-to-build-while-building-sage/ I followed the documentation to build Sage with Debian packages.
I run the command "debian/rules prune build" and I got the following ouput:
make[3]: *** [all] Error 2
make[3]: Leaving directory '/home/alien/sagemath/sage/build/make'
real 10m4.412s
user 18m13.656s
sys 0m20.556s
***************************************************************
Error building Sage.
The following package(s) may have failed to build (not necessarily
during this run of 'make all'):
* package: brial-0.8.5
log file: /home/alien/sagemath/sage/logs/pkgs/brial-0.8.5.log
build directory: /home/alien/sagemath/debian/build/usr/var/tmp/sage/build/brial-0.8.5
* package: cython-0.24.1.p0
log file: /home/alien/sagemath/sage/logs/pkgs/cython-0.24.1.p0.log
build directory: /home/alien/sagemath/debian/build/usr/var/tmp/sage/build/cython-0.24.1.p0
The build directory may contain configuration files and other potentially
helpful information. WARNING: if you now run 'make' again, the build
directory will, by default, be deleted. Set the environment variable
SAGE_KEEP_BUILT_SPKGS to 'yes' to prevent this.
Makefile:16: recipe for
target 'all' failed
make[2]: *** [all] Error 1
make[2]: Leaving directory '/home/alien/sagemath/sage'
debian/rules:51: recipe for target 'override_dh_auto_build' failed
make[1]: *** [override_dh_auto_build] Error 2
make[1]: Leaving directory '/home/alien/sagemath'
debian/rules:35: recipe for target 'build' failed
make: *** [build] Error 2
Cython is already installed (Cython version 0.23.2) and I can't install brial because it depends of libstdc++6 (>= 5.2) but 4.9.2-10 will be installed. debian_economistSun, 23 Oct 2016 21:50:28 +0200https://ask.sagemath.org/question/35240/
- Sage/Cython compile embedded Cython with Sage importhttps://ask.sagemath.org/question/9119/sagecython-compile-embedded-cython-with-sage-import/Hi,
I was wondering how you can compile a Sage .pyx file into an embedded Cython .c file and compile it with gcc to create a standalone executable?
I tried:
sage -cython --embed filename.pyx
gcc filename.c -I/path/to/python -lpython2.7
but when I run the program it gives me the following error:
from sage.all import *
ImportError: No module named sage.all
Thanks!
DandaliuThu, 28 Jun 2012 18:04:34 +0200https://ask.sagemath.org/question/9119/
- Using MPolynomial_libsingular in Cython codehttps://ask.sagemath.org/question/33290/using-mpolynomial_libsingular-in-cython-code/I wrote some Sage code to deal with multivariate polynomials (over `QQ` say). In order to increase performances, I tried to cythonize the file, and in particular to add static types. I was able to add types for basic types (such as `int` or `list`¹) but I am not able to use the type `MPolynomial_libsingular`. I tried to import `Mpolynomial_libsingular` with either `import` or `cimport`. A minimal example (file named `essai.spyx`):
from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomial_libsingular # or cimport
cpdef MPolynomial_libsingular dummy(MPolynomial_libsingular p):
return p
I give below the result I get when I call `sage essai.spyx`, first with `import` and then with `cimport`:
1. With `import`:
Compiling essai.spyx...
Traceback (most recent call last):
File "/home/bruno/Software/sage/src/bin/sage-run-cython", line 8, in <module>
s = load_cython(sys.argv.pop(1))
File "/home/bruno/Software/sage/local/lib/python2.7/site-packages/sage/repl/load.py", line 65, in load_cython
mod, dir = cython(name, compile_message=True, use_cache=True)
File "/home/bruno/Software/sage/local/lib/python2.7/site-packages/sage/misc/cython.py", line 469, in cython
raise RuntimeError("Error converting {} to C:\n{}\n{}".format(filename, log, err))
RuntimeError: Error converting essai.spyx to C:
Error compiling Cython file:
------------------------------------------------------------
...
include "cysignals/signals.pxi" # ctrl-c interrupt block support
include "stdsage.pxi"
include "cdefs.pxi"
from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomial_libsingular
cpdef MPolynomial_libsingular dummy(MPolynomial_libsingular p):
^
------------------------------------------------------------
_home_bruno_Recherche_Sage_LinearFactors_essai_spyx_0.pyx:7:6: 'MPolynomial_libsingular' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
include "cysignals/signals.pxi" # ctrl-c interrupt block support
include "stdsage.pxi"
include "cdefs.pxi"
from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomial_libsingular
cpdef MPolynomial_libsingular dummy(MPolynomial_libsingular p):
^
------------------------------------------------------------
_home_bruno_Recherche_Sage_LinearFactors_essai_spyx_0.pyx:7:36: 'MPolynomial_libsingular' is not a type identifier
2. With `cimport`, I get also a `RuntimeError`, but with many more errors. You can read the [complete log file](https://gist.github.com/bgrenet/aa804090a62e52183b4c6545e022cf45). Here is an excerpt:
In file included from /home/bruno/Software/sage/local/include/factory/factory.h:45:0,
from /home/bruno/Software/sage/local/include/factor.h:8,
from _home_bruno_Recherche_Sage_LinearFactors_essai_spyx_0.c:249:
/home/bruno/Software/sage/local/include/factory/templates/ftmpl_array.h:19:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
template <class T>
^
**Question:** What am I doing wrong, and what is the correct way of cythonizing such a file?
¹ An aside question: Is there a way to specify the type of elements in a `list`? Something like `list<int>` (this does not work)?
B r u n oMon, 02 May 2016 14:15:08 +0200https://ask.sagemath.org/question/33290/
- rational numbers with cythonhttps://ask.sagemath.org/question/33154/rational-numbers-with-cython/ I want to work efficiently with rational numbers under the context %cython but I don`t know how. Can anyone suggest any ideas? Thank you.
An example:
%cython
def rational_partitions(n):
sol = [i/n for i in range(n)]
for a in sol[0:-1]:
for b in sol[1:]:
k=2
while abs(b-a)/k>1/n:
sol.append(abs(b-a)/k)
k += 1
return sol
rational_partitions(10)rafarob32Wed, 20 Apr 2016 17:07:20 +0200https://ask.sagemath.org/question/33154/
- Calling a C function with printf from sagehttps://ask.sagemath.org/question/32628/calling-a-c-function-with-printf-from-sage/ Hi,
I'm trying to run the first example in doc.sagemath.org/html/en/thematic_tutorials/cython_interface.html on SageMathCloud. After creating the necessary hello.c and hello_sage.pyx, I tried running the Cython function in a sage notebook:
%runfile hello_sage.pyx
my_bridge_function()
The problem is that I see the pyx was compiled successfully, but nothing is printed.
I would appreciate any help on how to run the example, or an alternative way to print from a C function that would be visible in the notebook.
(I have a more complex C file that I'm trying to run, but it is difficult to debug it without printing)
ThankskroovyMon, 22 Feb 2016 15:25:01 +0100https://ask.sagemath.org/question/32628/
- Include assembler file in Cython compilationhttps://ask.sagemath.org/question/32125/include-assembler-file-in-cython-compilation/ I'm just experimenting with Cython files in sage and I'm quite happy that I found out how to specify arbitrary compiler flags in my .spyx file using `cargs` declaration.
But there is one other thing I want to do. Beside further C source files (which I can include using the `cfile` declaration) I also need to include a .s file containing assembler code.
Unfortunately, I cannot simply do it the way I include C files, because it gives me `error: unknown file type '.s'`
Any way I can pass the .s file within my .spyx file?firefexxSat, 09 Jan 2016 17:38:14 +0100https://ask.sagemath.org/question/32125/
- def type of mpmath matrices in cythonhttps://ask.sagemath.org/question/31210/def-type-of-mpmath-matrices-in-cython/ I'm trying to speed up the exact *iterative* calculation of the 1E9 th Fibonacci number, which has 208987640 digits.
Working with Python and mpmath I've reached an acceptable time, but I'm looking to further reduce it using Cython.
In this case the overload is due to the huge numbers, stored in Knuth's 2 x 2 matrices, that have been defined using Numpy and mpmath.
For Cython to be helpful in this subject, I should define those matrices as static, but I don't know the type I should use to define it. Is there a special type for this case?
Cython curiousMon, 30 Nov 2015 19:43:17 +0100https://ask.sagemath.org/question/31210/