On Jan 8, 12:03 pm, ztnews <cronin.vin...@gmail.com> wrote:
Hi,
> Forgive me if this is too obvious. I'm still evaluating/learning the
> basics of SAGE
No problem, this is what a support group is for :)
> Just how compatible is SAGE with Python? By which I mean, should I be
> able to just "drop-in" an existing/working python script and have it
> run, or should I expect some modifications will be required? And if
> so, what's the major things I need to keep an eye out for?
One thing is that you need to deal with some numerical types, i.e.
sage: j=numpy.complex(0,1)
sage: RealNumber=float
sage: Integer=int
See http://www.math.washington.edu/~jkantor/Numerical_Sage/node3.html
for more info on that.
> I've looked in the documents, particularly "Coding in Python for Sage"
>
> http://www.sagemath.org/doc/prog/node15.html
>
> I'll illustrate by example. I found a Python script that does a
> physics calculation (band structure of silicon)
>
> http://www.wag.caltech.edu/home/rpm/projects/tight-binding/harrison.py
>
> or see here for a discussion of the script:
>
> http://www.wag.caltech.edu/home/rpm/projects/tight-binding/
>
> I've successfully run harrison.py (without modification) using both
> linux and windows-based python installations. But under SAGE (I've
> installed the latest vmware version) required a little diddling to get
> it (mostly) running.
>
> Two points. 1) This script calls for modules "Numeric" and
> "LinearAlgebra"
>
> from Numeric import * # Make sure that NumPy is in your
> from LinearAlgebra import eigenvalues
Numeric is the predecessor to NumPy which is in Sage. Nunmeric used to
be at least an optional spkg for Sage, but I am not sure if it still
works. Installing Numeric should be possible, but AFAIK this is
seriously outdated code.
> both of which failed in SAGE. A couple minor modifications and I got
> past those points. I suspect these are deprecated, but still the
> Python installations handled the script without mods.
You probably have either Numeric or an older numpy installed, but I am
not an expert about the finer details of what numeric code works with
that numpy release (if at all)
> 2) The other thing that failed was the system call to gnuplot at the
> end of the script. I can imagine that would be hard make work in a
> SAGE-notebook environment, and I haven't managed that.
Do you have gnuplot installed? If so what are the failures? Did the
gnuplot part of script work with the pure Python env?
> Now, my point here is not that I need that script to run,
> particularly. My question is about compatibility. Have I missed
> something about how to execute a Python script with the minimum of
> modifications?
Without going into specifics Sage ships a subset of what the usual
distributions ship for python modules, but adds some unusual ones that
aren't in every distribution. You can install pretty much any Python
module by running
./sage -sh
cd into unpacked python module directory
python setup.py install
There might be problems with dependencies and so on, but for most pure
Python code this should work really well.
> Thanks for your time. BTW, SAGE is really impressive.
:)
Cheers,
Michael
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---