[CoCalc] [SageManifolds] Error : Black hole rendering with SageMath 2
HI! I, Jaekwook Lee, am a graduate student at Chungbuk National university, Korea, and am currently working on particle trajectory around black holes.
The error source is https://nbviewer.org/github/sagemanif...
The error occur in Cell Number [38] and [39] as below
AttributeError Traceback (most recent call last)
Cell In [40], line 1
----> 1 get_ipython().run_cell_magic('cython', '', 'from libc.math cimport cos, sin\ncimport cython\n\n@cython.boundscheck(False)\n@cython.wraparound(False)\ncpdef intersection(list curve, float alpha, float beta, float dmin, float dmax):\n """\n Return True if the curve intersect the disk comprised between dmin and dmax\n tilted of angles alpha and beta\n """\n cdef float x, y, z\n cdef float x2, y2, z2\n cdef float r, theta, phi\n cdef int n, i\n cdef float t\n cdef float sinalpha, cosalpha\n cdef float sinbeta, cosbeta\n sinalpha = sin(alpha)\n cosalpha = cos(alpha)\n sinbeta = sin(beta)\n cosbeta = cos(beta)\n n = len(curve)\n r, theta, phi = curve[0][2:5]\n x, y, z = r*sin(theta)*cos(phi), r*sin(theta)*sin(phi), r*cos(theta)\n x, y, z = x, y*cos(beta)-z*sin(beta), z*cos(beta)+y*sin(beta)\n z = z*cos(alpha)+x*sin(alpha)\n for i in range(1, n): \n r = curve[i][2]\n theta = curve[i][3]\n phi = curve[i][4]\n x2, y2, z2 = r*sin(theta)*cos(phi), r*sin(theta)*sin(phi), r*cos(theta)\n y2, z2 = y2*cosbeta-z2*sinbeta, z2*cosbeta+y2*sinbeta\n x2, z2 = x2*cosalpha-z2*sinalpha, z2*cosalpha+x2*sinalpha\n if z!=z2:\n t = z/(z-z2)\n if t>=0 and t<1 and curve[i][2]>dmin and curve[i][2]<dmax:\n return True\n x, y, z = x2, y2, z2\n return False\n')
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/IPython/core/interactiveshell.py:2417, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2415 with self.builtin_trap:
2416 args = (magic_arg_s, cell)
-> 2417 result = fn(*args, **kwargs)
2418 return result
File /ext/sage/10.1/src/sage/repl/ipython_extension.py:364, in SageMagics.cython(self, line, cell)
335 """
336 Cython cell magic
337
(...)
361 test
362 """
363 from sage.misc.cython import cython_compile
--> 364 return cython_compile(cell)
File /ext/sage/10.1/src/sage/misc/cython.py:695, in cython_compile(code, **kwds)
693 with open(tmpfile, 'w') as f:
694 f.write(code)
--> 695 return cython_import_all(tmpfile, get_globals(), **kwds)
File /ext/sage/10.1/src/sage/misc/cython.py:585, in cython_import_all(filename, globals, **kwds)
570 def cython_import_all(filename, globals, **kwds):
571 """
572 Imports all non-private (i.e., not beginning with an underscore)
573 attributes of the specified Cython module into the given context.
(...)
583 code
584 """
--> 585 m = cython_import(filename, **kwds)
586 for k, x in m.__dict__.items():
587 if k[0] != '_':
File /ext/sage/10.1/src/sage/misc/cython.py:556, in cython_import(filename, **kwds)
539 def cython_import(filename, **kwds):
540 """
541 Compile a file containing Cython code, then import and return the
542 module. Raises an ``ImportError`` if anything goes wrong.
(...)
554 - the module that contains the compiled Cython code.
555 """
--> 556 name, build_dir = cython(filename, **kwds)
558 oldpath = sys.path
559 try:
File /ext/sage/10.1/src/sage/misc/cython.py:380, in cython(filename, verbose, compile_message, use_cache, create_local_c_file, annotate, sage_namespace, create_local_so_file)
378 from sage.misc.package_dir import cython_namespace_package_support
379 with cython_namespace_package_support():
--> 380 ext, = cythonize([ext],
381 aliases=aliases,
382 include_path=includes,
383 compiler_directives=directives,
384 quiet=(verbose <= 0),
385 errors_to_stderr=False,
386 use_listing_file=True)
387 finally:
388 # Read the "listing file" which is the file containing
389 # warning and error messages generated by Cython.
390 try:
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Build/Dependencies.py:968, in cythonize(module_list, exclude, nthreads, aliases, quiet, force, language, exclude_failures, **options)
966 c_options = CompilationOptions(**options)
967 cpp_options = CompilationOptions(**options); cpp_options.cplus = True
--> 968 ctx = c_options.create_context()
969 options = c_options
970 module_list, module_metadata = create_extension_list(
971 module_list,
972 exclude=exclude,
(...)
976 language=language,
977 aliases=aliases)
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Compiler/Main.py:596, in CompilationOptions.create_context(self)
595 def create_context(self):
--> 596 return Context(self.include_path, self.compiler_directives,
597 self.cplus, self.language_level, options=self)
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Compiler/Main.py:80, in Context.__init__(self, include_directories, compiler_directives, cpp, language_level, options)
74 def __init__(self, include_directories, compiler_directives, cpp=False,
75 language_level=None, options=None):
76 # cython_scope is a hack, set to False by subclasses, in order to break
77 # an infinite loop.
78 # Better code organization would fix it.
---> 80 from . import Builtin, CythonScope
81 self.modules = {"__builtin__" : Builtin.builtin_scope}
82 self.cython_scope = CythonScope.create_cython_scope(self)
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Compiler/CythonScope.py:5
3 from .Symtab import ModuleScope
4 from .PyrexTypes import *
----> 5 from .UtilityCode import CythonUtilityCode
6 from .Errors import error
7 from .Scanning import StringSourceDescriptor
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Compiler/UtilityCode.py:3
1 from __future__ import absolute_import
----> 3 from .TreeFragment import parse_from_strings, StringParseContext
4 from . import Symtab
5 from . import Naming
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Compiler/TreeFragment.py:17
15 from .Symtab import ModuleScope
16 from . import PyrexTypes
---> 17 from .Visitor import VisitorTransform
18 from .Nodes import Node, StatListNode
19 from .ExprNodes import NameNode
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Compiler/Visitor.py:16, in init Cython.Compiler.Visitor()
14 from . import TypeSlots
15 from . import Builtin
---> 16 from . import Nodes
17 from . import ExprNodes
18 from . import Errors
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Compiler/Nodes.py:31
29 from . import Options
30 from . import DebugFlags
---> 31 from .Pythran import has_np_pythran, pythran_type, is_pythran_buffer
32 from ..Utils import add_metaclass
35 if sys.version_info[0] >= 3:
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/Cython/Compiler/Pythran.py:10
7 import cython
9 try:
---> 10 import pythran
11 pythran_is_pre_0_9 = tuple(map(int, pythran.__version__.split('.')[0:2])) < (0, 9)
12 pythran_is_pre_0_9_6 = tuple(map(int, pythran.__version__.split('.')[0:3])) < (0, 9, 6)
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/pythran/__init__.py:42
40 import pythran.log
41 from pythran.config import get_include
---> 42 from pythran.toolchain import (generate_cxx, compile_cxxfile, compile_cxxcode,
43 compile_pythrancode, compile_pythranfile,
44 test_compile)
45 from pythran.spec import spec_parser
46 from pythran.spec import load_specfile
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/pythran/toolchain.py:12
10 from pythran.cxxgen import ReturnStatement
11 from pythran.dist import PythranExtension, PythranBuildExt
---> 12 from pythran.middlend import refine, mark_unexported_functions
13 from pythran.passmanager import PassManager
14 from pythran.tables import pythran_ward
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/pythran/middlend.py:4
1 """This module turns a python AST into an optimized, pythran compatible ast."""
3 from pythran.analyses import ExtendedSyntaxCheck
----> 4 from pythran.optimizations import (ComprehensionPatterns, ListCompToGenexp,
5 RemoveDeadFunctions)
6 from pythran.transformations import (ExpandBuiltins, ExpandImports,
7 ExpandImportAll, FalsePolymorphism,
8 NormalizeCompare, NormalizeException,
(...)
15 NormalizeStaticIf, SplitStaticExpression,
16 RemoveFStrings)
17 import re
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/pythran/optimizations/__init__.py:21
19 from .loop_full_unrolling import LoopFullUnrolling
20 from .modindex import ModIndex
---> 21 from .pattern_transform import PatternTransform
22 from .range_loop_unfolding import RangeLoopUnfolding
23 from .range_based_simplify import RangeBasedSimplify
File /ext/sage/10.1/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/pythran/optimizations/pattern_transform.py:346
343 pattern_selector = type(known_pattern.pattern).__name__
344 attr_name = "{}Patterns".format(pattern_selector)
345 setattr(PatternTransform, attr_name,
--> 346 getattr(PatternTransform, attr_name) + (known_pattern,))
AttributeError: type object 'PatternTransform' has no attribute 'typePatterns'
TypeError Traceback (most recent call last) File <timed eval="">:1 TypeError: intersection() takes 3 positional arguments but 5 were given
This looks like a Pythran error on your machine... What is your system ? How did you installed SageMath on it ? (it looks you are using SageMath 10.1).
I using SageMath on CoCalc's Jupyter Notebooks..,
https://cocalc.com/features/sage?utm_source=sagemath.org&utm_medium=landingpage (https://cocalc.com/features/sage?utm_...)