Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Cimporting Sage classes with the new Sage IPython notebook

Sage Version 6.2, Release Date: 2014-05-06, Unbuntu 12.04, 64 bit version

Hello,

I am using the new Sage IPython notebook and would like to cimport the class "Matrix_mod2e_dense" in a cython cell.

(1) Here is a minimum working example in the Sage IPython command line (also works on a SageMathCloud terminal), and that I would like to transpose in the Ipython notebook :

 from sage.all import *
 cython("#clang C++\n from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense")

(A similar statement works in the old Sage notebook, and also on the SageMathCloud notebook).

(2) And here is a (nearly) minimum non working example in the Sage IPython notebook, nor on a SageMathCloud IPython notebook :

  from sage.all import *
  %load_ext sage
  %load_ext cythonmagic

    %%cython
    #clang C++
    from sage.all import *
    cimport numpy as np
    #It is worth noting that the *cimport numpy* works. But when I add this last statement:
    from sage.matrix.matrix_mod2e_dense cimport Matrix_mod2e_dense

It then says :

.cache/ipython/cython/_cython_magic_9842ede087c20823a43baddf277ba52c.pyx:6:0: 'Matrix_mod2e_dense.pxd' not found

3) So everything leads me to think that it is the cimport command that is badly interpreted by the Ipython Notebook. Does someone has a solution to make (1) work in the Sage Ipython Notebook ? (For instance, what should I add/remove in the cythonmagic.py file ? I couldn't attach mine to this post, but could publish/send in a way or another if this might help)

Finaly, I mention similar posts on AskSage.org , but not exactly on the same issue, so which could not help me : http://ask.sagemath.org/question/2575/importing-sage-functions-into-cython --- http://ask.sagemath.org/question/2766/about-cython-and-the-main-sage-commands --- http://ask.sagemath.org/question/23226/ip-notebooks-and-extensions-sage-versus-sage-cloud/

Thank you for your help !

Matthieu

Cimporting Sage classes with the new Sage IPython notebook

Sage Version 6.2, Release Date: 2014-05-06, Unbuntu 12.04, 64 bit version

Hello,

I am using the new Sage IPython notebook and would like to cimport the class "Matrix_mod2e_dense" in a cython cell.

(1) Here is a minimum working example in the Sage IPython command line (also works on a SageMathCloud terminal), and that I would like to transpose in the Ipython notebook :

 from sage.all import *
 cython("#clang C++\n from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense")

(A similar statement works in the old Sage notebook, and also on the SageMathCloud notebook).

(2) And here is a (nearly) minimum non working example in the Sage IPython notebook, nor on a SageMathCloud IPython notebook :

  from sage.all import *
  %load_ext sage
  %load_ext cythonmagic

    %%cython
    #clang C++
    from sage.all import *
    cimport numpy as np
    #It is worth noting that the *cimport numpy* works. But when I add this last statement:
    from sage.matrix.matrix_mod2e_dense cimport Matrix_mod2e_dense

It then says :

.cache/ipython/cython/_cython_magic_9842ede087c20823a43baddf277ba52c.pyx:6:0: 'Matrix_mod2e_dense.pxd' not found

3) So everything leads me to think that it is the cimport command that is badly interpreted by the Ipython Notebook. Does someone has a solution to make (1) work in the Sage Ipython Notebook ? (For instance, what should I add/remove in the cythonmagic.py file ? I couldn't attach mine to this post, but could publish/send in a way or another if this might help)

Finaly, I mention similar posts on AskSage.org , posts, but not exactly on the same issue, so which could not help me : http://ask.sagemath.org/question/2575/importing-sage-functions-into-cython --- http://ask.sagemath.org/question/2766/about-cython-and-the-main-sage-commands --- http://ask.sagemath.org/question/23226/ip-notebooks-and-extensions-sage-versus-sage-cloud/ --- http://stackoverflow.com/questions/24532549/making-sage-work-with-ipython

Thank you for your help !

Matthieu

Cimporting Sage classes with the new Sage IPython notebook

Sage Version 6.2, Release Date: 2014-05-06, Unbuntu 12.04, 64 bit version

Hello,

I am using the new Sage IPython notebook and would like to cimport the class "Matrix_mod2e_dense" in a cython cell.

(1) Here is a minimum working example in the Sage IPython command line (also works on a SageMathCloud terminal), and that I would like to transpose in the Ipython notebook :

 from sage.all import *
 cython("#clang C++\n from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense")

(A similar statement works in the old Sage notebook, and also on the SageMathCloud notebook).

(2) And here is a (nearly) minimum non working example in the Sage IPython notebook, nor on a SageMathCloud IPython notebook :

  from sage.all import *
  %load_ext sage
  %load_ext cythonmagic

    %%cython
    #clang C++
    from sage.all import *
    cimport numpy as np
    #It is worth noting that the *cimport numpy* works. But when I add this last statement:
    from sage.matrix.matrix_mod2e_dense cimport Matrix_mod2e_dense

It then says :

.cache/ipython/cython/_cython_magic_9842ede087c20823a43baddf277ba52c.pyx:6:0: 'Matrix_mod2e_dense.pxd' not found

3) So everything leads me to think that it is the cimport command that is badly interpreted by the Ipython Notebook. Does someone has a solution to make (1) work in the Sage Ipython Notebook ? (For instance, what should I add/remove in the cythonmagic.py file ? I couldn't attach mine to this post, but could publish/send in a way or another if this might help)

Finaly, I mention similar posts, but not exactly on the same issue, so which could not help me : http://ask.sagemath.org/question/2575/importing-sage-functions-into-cython --- http://ask.sagemath.org/question/2766/about-cython-and-the-main-sage-commands --- http://ask.sagemath.org/question/23226/ip-notebooks-and-extensions-sage-versus-sage-cloud/ --- http://stackoverflow.com/questions/24532549/making-sage-work-with-ipython

Thank you for your help !

Matthieu

click to hide/show revision 4
retagged

Cimporting Sage classes with the new Sage IPython notebook

Sage Version 6.2, Release Date: 2014-05-06, Unbuntu 12.04, 64 bit version

Hello,

I am using the new Sage IPython notebook and would like to cimport the class "Matrix_mod2e_dense" in a cython cell.

(1) Here is a minimum working example in the Sage IPython command line (also works on a SageMathCloud terminal), and that I would like to transpose in the Ipython notebook :

 from sage.all import *
 cython("#clang C++\n from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense")

(A similar statement works in the old Sage notebook, and also on the SageMathCloud notebook).

(2) And here is a (nearly) minimum non working example in the Sage IPython notebook, nor on a SageMathCloud IPython notebook :

  from sage.all import *
  %load_ext sage
  %load_ext cythonmagic

    %%cython
    #clang C++
    from sage.all import *
    cimport numpy as np
    #It is worth noting that the *cimport numpy* works. But when I add this last statement:
    from sage.matrix.matrix_mod2e_dense cimport Matrix_mod2e_dense

It then says :

.cache/ipython/cython/_cython_magic_9842ede087c20823a43baddf277ba52c.pyx:6:0: 'Matrix_mod2e_dense.pxd' not found

3) So everything leads me to think that it is the cimport command that is badly interpreted by the Ipython Notebook. Does someone has a solution to make (1) work in the Sage Ipython Notebook ? (For instance, what should I add/remove in the cythonmagic.py file ? I couldn't attach mine to this post, but could publish/send in a way or another if this might help)

Finaly, I mention similar posts, but not exactly on the same issue, so which could not help me : http://ask.sagemath.org/question/2575/importing-sage-functions-into-cython --- http://ask.sagemath.org/question/2766/about-cython-and-the-main-sage-commands --- http://ask.sagemath.org/question/23226/ip-notebooks-and-extensions-sage-versus-sage-cloud/ --- http://stackoverflow.com/questions/24532549/making-sage-work-with-ipython

Thank you for your help !

Matthieu

click to hide/show revision 5
retagged

Cimporting Sage classes with the new Sage IPython notebook

Sage Version 6.2, Release Date: 2014-05-06, Unbuntu 12.04, 64 bit version

Hello,

I am using the new Sage IPython notebook and would like to cimport the class "Matrix_mod2e_dense" in a cython cell.

(1) Here is a minimum working example in the Sage IPython command line (also works on a SageMathCloud terminal), and that I would like to transpose in the Ipython notebook :

 from sage.all import *
 cython("#clang C++\n from sage.matrix.matrix_mod2_dense cimport Matrix_mod2_dense")

(A similar statement works in the old Sage notebook, and also on the SageMathCloud notebook).

(2) And here is a (nearly) minimum non working example in the Sage IPython notebook, nor on a SageMathCloud IPython notebook :

  from sage.all import *
  %load_ext sage
  %load_ext cythonmagic

    %%cython
    #clang C++
    from sage.all import *
    cimport numpy as np
    #It is worth noting that the *cimport numpy* works. But when I add this last statement:
    from sage.matrix.matrix_mod2e_dense cimport Matrix_mod2e_dense

It then says :

.cache/ipython/cython/_cython_magic_9842ede087c20823a43baddf277ba52c.pyx:6:0: 'Matrix_mod2e_dense.pxd' not found

3) So everything leads me to think that it is the cimport command that is badly interpreted by the Ipython Notebook. Does someone has a solution to make (1) work in the Sage Ipython Notebook ? (For instance, what should I add/remove in the cythonmagic.py file ? I couldn't attach mine to this post, but could publish/send in a way or another if this might help)

Finaly, I mention similar posts, but not exactly on the same issue, so which could not help me : http://ask.sagemath.org/question/2575/importing-sage-functions-into-cython --- http://ask.sagemath.org/question/2766/about-cython-and-the-main-sage-commands --- http://ask.sagemath.org/question/23226/ip-notebooks-and-extensions-sage-versus-sage-cloud/ --- http://stackoverflow.com/questions/24532549/making-sage-work-with-ipython

Thank you for your help !

Matthieu