Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

importing .ipynb notebooks in Sagemath 9.4

Following https://stackoverflow.com/questions/44116194/import-a-function-from-another-ipynb-file Python/Sagemath9.4/Jupyter error?
Using jupyter with kernel selections:sagemath9.4, python3
I found that the import works if the file pyt.ipynb is written with the Jupyter kernel Python3 selected, but can't be read if it's written from Sagemath9.4 kernel.
Is there a more correct way or is it a bug?
File pyt.ipynb to be imported

def factorial(n):
if n == 0:
    return 1
else:
    return n * factorial(n-1)

File for importing

from ipynb.fs.full.pyt import *
testing = factorial(5)
testing

importing .ipynb notebooks in Sagemath 9.4

Following https://stackoverflow.com/questions/44116194/import-a-function-from-another-ipynb-file Python/Sagemath9.4/Jupyter error?
Using jupyter with kernel selections:sagemath9.4, python3
I found that the import works if the file pyt.ipynb is written with the Jupyter kernel Python3 selected, but can't be read if it's written from Sagemath9.4 kernel.
Is there a more correct way or is it a bug?
File pyt.ipynb to be imported

def factorial(n):
if n == 0:
    return 1
else:
    return n * factorial(n-1)

File for importing

from ipynb.fs.full.pyt import *
testing = factorial(5)
testing

importing .ipynb notebooks in Sagemath 9.4

Following https://stackoverflow.com/questions/44116194/import-a-function-from-another-ipynb-file Python/Sagemath9.4/Jupyter error?
Using jupyter with kernel selections:sagemath9.4, python3
I found that the import works if the file pyt.ipynb is written with the Jupyter kernel Python3 selected, but can't be read if it's written from Sagemath9.4 kernel.
Is there a more correct way or is it a bug?
File pyt.ipynb to be imported

def factorial(n):
if n == 0:
    return 1
else:
    return n * factorial(n-1)

File for importing

from ipynb.fs.full.pyt import *
testing = factorial(5)
testing

Here is the "diff" output, comparing the python3 save and the sagemath9.4 save
diff pyt.ipynb pyt-python.ipynb

< "display_name": "SageMath 9.4",
< "language": "sage",
< "name": "sagemath"

'> "display_name": "Python 3",
'> "language": "python",
'> "name": "python3"