Ask Your Question
0

Import class using mathematica

asked 2017-04-07 19:34:45 +0200

anonymous user

Anonymous

I have a class a in a file a.sage using the interface to mathematica. I want to use this class in another class b. One way I found was to run first "mv a.sage a.py", which generates a python file. But then I get the error: "NameError: global name 'mathematica' is not defined" because you cannot use mathematica in python as you can use it with sage.

Is there a way importing a self-written class (a.sage) using mathematica in another self-written class (b.sage)?

edit retag flag offensive close merge delete

Comments

This would be a problem with anything similar, not just that particular interface. You may want to try from sage.all import * at the top of your .py file ...

kcrisman gravatar imagekcrisman ( 2017-04-07 20:32:24 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2017-04-08 12:51:45 +0200

FrédéricC gravatar image

In a .py file, you need to add some imports at the beginning. For example, if you need "mathematica", you can find what you should add using

sage: import_statements(mathematica)
from sage.interfaces.mathematica import mathematica
edit flag offensive delete link more

Comments

Thanks for the answer.

sageUser gravatar imagesageUser ( 2017-04-20 01:16:30 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-04-07 19:34:45 +0200

Seen: 676 times

Last updated: Apr 08 '17