I've just started using IPython for interactive development and exploratory research, which I've found really exciting with all the cool features and possibilities. I am using the Anaconda package manager to manage dependencies, which includes IPython.
From what I've read, one goal of the IPython team is to eventually integrate Sage Math (CAS) into IPython, as a cell magic. Does anyone know if this is still under development? Or rather, if I wanted to use Sage now, is writing an extension the only way to do this [1]?
[1] https://github.com/ipython/ipython/wiki/Extensions-Index
Also, if I install additional packages for scientific development, not included in the Anaconda distribution, is that as easy as just pip or do I have to go through a Anaconda package build to handle dependencies and such? If I were only using IPython, I could understand just doing easy_install or pip as recommended in the docs, but I believe that overwrites existing dependencies within Anaconda. If I use pip, how does that affect Anaconda dependencies if I do not install in an Anaconda environment, which I take is the equivalent as virtualenv.py, and is this the way to also set up revision control (i.e. Mercurial)?
To clarify, I do not want to run IPython from within Sage, I want to run Sage, as a CAS, from within IPython. I'd rather go the Sage approach of integrating domain specific languages. Or in contrast, will IPython extensions replace Sage?
I'm a self taught programmer, not a professional software developer. As an engineer, I am used to Matlab, Mathematica, and commercial solutions, that allow me to abstract away the plumbing. I'm trying to wrap my mind around getting everything glued together, but it's like a mix of spaghetti soup and a dynamic link library, due to lack of knowledge. I'm probably using the wrong approach.
What I want is Anaconda/Enthought package management (IPython, pandas, etc..), custom rolled Sage through hooks/extensions or magics, extensions to packages not included in Anaconda (i.e. Matlab see [1] above), and revision control with Git and Mercurial. How would professional developers set this up on a Mac or Linux box?
Answering the first question:
Sage is a huge collection of mathematical software, including IPython. There's no way we'd integrate all of that into IPython.
Possibly what you've heard is that we're going to integrate Sage-style 'interacts' into IPython. That's where you have a slider to control the value of some input variable, and the output updates as you move it around, based on a calculation written in Python. That is still on our roadmap to add to IPython.
Another possibility is that you're thinking of SymPy, a Python-based CAS. SymPy works well within IPython, especially if you call sympy.init_printing() to get the fancy representations of expressions.
I wrote an IPython extension to load Sage customizations into the IPython notebook---in fact, that's how many of the customizations to IPython are done for the normal Sage interface. It basically turns the IPython notebook into an interface to Sage (e.g., preparsing is done, etc.).
You do need to run it from Sage's copy of IPython, though. Just start the IPython notebook:
sage -ipython notebook
and then load the sage extension in a cell:
%load_ext sage.misc.sage_extension
Pretty soon we'll upgrade to IPython 1.0 (I've made the changes necessary, and it needs to be reviewed). If you want to run IPython 1.0 already, email the sage-support mailing list and I'll post instructions.
To answer your other question, Sage includes many packages that are not available in Anaconda. Sage depends on these packages heavily for many features. I suppose there is a possibility getting Sage and its dependencies distributed with something like Anaconda, but no one is working on that as far as I know. There is some work on packaging Sage up for different linux distributions and replacing the package manager for Sage.
To clarify, I do not want to run Ipython from within Sage, I want to run Sage, as a CAS, from within Ipython. I'd rather go the Sage approach of integrating domain specific languages. Or in contrast, will Ipython extensions replace Sage?
If you want to run Sage within Ipython, the easiest thing to do is to use Sage's copy of Ipython:
$ sage -ipython
Python 2.7.5 (default, Aug 1 2013, 18:11:00)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from sage.all import *
In [2]: integrate(x^2,x)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-006357f5d9c0> in <module>()
----> 1 integrate(x^2,x)
NameError: name 'x' is not defined
In [3]: var('x')
Out[3]: x
In [4]: integrate(x^2,x)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-4-006357f5d9c0> in <module>()
----> 1 integrate(x^2,x)
/Users/.../sage-5.11.rc0/local/lib/python2.7/site-packages/sage/structure/element.so in sage.structure.element.Element.__xor__ (sage/structure/element.c:6754)()
RuntimeError: Use ** for exponentiation, not '^', which means xor
in Python, and has the wrong precedence.
In [5]: integrate(x**2,x)
Out[5]: 1/3*x^3
Note that there are some differences between this and Sage - for instance, there is no preparsing of the syntax. Presumably if you had Sage someplace your own installation of Ipython can find it, you could do this there too (though there is no easy_install and the Python versions might not match correctly!).
Please observe that Sage, as it currently is and should be in the near future, is a huge package that runs in POSIX (Linux-like) OSes only. If you intend it to run in Windows you must use VirtualBox with Sage running under a VM.
If you want a simple CAS that is simple to install and runs everywhere that Python does, you should consider taking a look at Sympy. It doesn't interact with all the software that Sage does, but is simple to use, lightweight (no external libraries needed) and is already included in the base Anaconda distribution.
Besides, it can be easily used inside other Python programs, since it's just like any other module and doesn't make changes to the Python syntax.
Related
I'm using Octave right now, but earlier I had used MatLab. In MatLab there is a function ord2 and according to this document (http://www.obihiro.ac.jp/~suzukim/masuda/octave/html3/octave_159.html/) it should also exist in Octave. Could anyone help me with this issue, since I'm new in Octave. How can I import or in other way use 'ord2' function (second-ordered system).
The documentation you mention is for Octave 3.0 which is a very very old version. All of Control functions, together with Finance and Quaternion, were removed from core Octave with release 3.2. If you see the news for Octave 3.2 (if you have a very recent version, this may be in one of the old news file:
** The Control, Finance and Quaternion functions have been removed.
These functions are now available as separate packages from
http://octave.sourceforge.net/packages.html
and can be reinstalled using the Octave package manager (see
the pkg function).
As it is mentioned, you can download the packages from Octave Forge website but depending on your operating system, you may be better off use your package manager.
Finally, the ord2 function does not actually exist in the control package and I'm even unsure that the version you are referring to in Octave 3.0 was even Matlab compatible. However, you can still see its source online right before it was removed.
I am creating a kbskit for my tcl executable application as follows on Suse :
./kbs.tcl -builddir=85 -r -mk-bi -bi="itcl3.4 itk3.4 iwidgets4.0.2 img1.4.1" install kbskit8.5
cp 85/bin/kbsmk8.5-bi kbsmk8.5-bi-run
./kbsmk8.5-bi sdx.kit wrap sim -runtime kbsmk8.5-bi-run
The application will be used on several flavours of linux like Redhat,Ubuntu etc. I am trying my best to test it myself under many combinations. Neverthless, i would be like to know someone thinks this would/wouldn’t work seamlessly across different platforms since I wont be able to cover all combinations exhaustively.
A Linux/x86 kbskit is at least reasonable to run on that collection of platforms. Unfortunately, the only way to be sure is to try. It should work, but if your script refers to files in a particular location and another platform (or deployment!) puts them elsewhere, then things will fail. The other thing that might go wrong is if there are significant incompatibilities in the small number of system libraries that Tcl uses, especially the C library; I do not know whether such problems exist, but I suspect they're not a major problem in practice.
You can try using the platform package (a standard part of Tcl since at least 8.5) to report what platform you're dealing with. That's the usual level of granularity you need to pay attention to.
package require platform
puts [platform::identify]
When attempting to use pandoc to convert JSON based files (.ipynb) from iPython notebook (0.12), I receive an error stating "bad decodeArgs" for the JSON. I suspect that it may be due to the Ubuntu provided version of pandoc that I am using (1.8.1.1). It seems that getting the latest pandoc version requires setting up the Haskell platform which I was not successful doing because of dependency challenges (and really don't want to). I don't want to spend any more time trying to install Haskell if this is not my problem.
Is there a way to get the latest pandoc binaries for Ubuntu without rebuilding it?
Given that iPython notebook is new (and very cool!!), it would be nice to hear about experiences related to translating the JSON to other formats. Perhaps there is a different way to accomplish this other than pandoc.
Regarding your "keeping up to date with Pandoc", I'm afraid you do need Haskell installed. The best way to do this via the Haskell Platform ("HP") package, and then just like with Ruby, it's a lot more consistent to use the environment's package manager for dependencies than your OS. I've had no trouble getting it working, even in Windoze. . .
I'm sure questions to the Haskell mailing list would result in quick help for a platform as mainstream as Debian/Ubuntu, but you might need to manually install a newer version of HP that what's available through the OS package manager.
Once you get HP up and running, the dev Pandoc is dead easy to compile, and git will keep you up to date with the latest - specific instructions here, currently maintained:
https://github.com/jgm/pandoc/wiki/Installing-the-development-version-of-pandoc-1.9
Note that v1.9 has now been officially released if you really don't want to go to the trouble of keeping up to date with the dev cycle, but of course again you won't get it in your OS package manager for quite some time after that (I assume anyway).
==========================
Regarding your attempts to treat JSON as a document syntax:
The best syntax inputs for Pandoc at this point are its native markdown+extensions, and reST (especially for Python people/environments), basically maintained as functionally equivalent, although there may be features available in the former that aren't represented in the latter, since John can just add extensions anytime he wants. AFAIK Pandoc hasn't begun to support the Sphinx extensions (yet?)
The JSON format used internally within Pandoc isn't documented (yet?) but it's the native Haskell data type. As the Thomas K notes, there may be some similarity between how the two tools represent data, but probably not enough to treat either as "just another markup format".
However, if you're working on this, it's easy enough to see what Pandoc looks for in the way of JSON input.
pandoc -t json
compare this to
pandoc -t native
and it's easy to see the specs created by Text.Pandoc.Definition and Text.JSON.Generic
Using Pandoc's internal data representation as input would obviously be more stable than a marked up text stream, and others have expressed a desire for documentation on this and it would be a great contribution to the community.
Please do inform the Pandoc mail list of any work done in this area. The crew there is very responsive, including getting quick feedback from John M (the lead developer) himself directly.
I doubt pandoc or any other tool knows what to do with ipynb files yet (at the time of writing, the IPython notebook was released less than a month ago). JSON is just a generic data structure like XML, not a document format.
We're (IPython) working on tools to export notebooks to other formats, but they're not ready for a proper release yet. If you want to help develop that, see this mailing list thread. Hopefully it will be part of the next IPython release.
I've installed the Yojson library for OCaml via GODI:
http://martin.jambon.free.fr/yojson.html
I want to start an interactive ocaml session (i.e. via the ocaml command) and execute functions from the Yojson library e.g.
Yojson.Safe.from_string;;
How do I do this? The above command gives "Error: Unbound module Yojson". I've worked out how to compile via ocamlc with Yojson available, but I want to launch an interactive session instead.
I know this seems like a horrible beginners question but Yojson comes with no samples and minimal instructions so I'm really stumped. I've tried various combinations of "#load" and compiler switches and I'm stuck.
The tool you are after is called findlib. It is included in the base GODI installation. The tools that come with findlib allow you to easily compile against most OCaml libraries and use those libraries from a toplevel session (ocaml). The findlib documentation is fairly comprehensive, but here is a quick summary to get started.
To start using findlib from within a toplevel session:
#use "topfind";;
This will display a brief usage message. Then you can type:
#list;;
This will show you a list of all of the available packages. Yojson will likely be among them. Finally:
#require "yojson";;
where yojson is replaced by the appropriate entry shown by #list;;. Yojson's modules should be available for you to use at this point.
I am in the process of building interactive front-ends to a
distributed application which to date has been used to run workloads
that had a batch-job like structures and needed no UI at all. The application is mostly written in Perl and C and runs on a mix of Unix and Windows machines, but I think this isn't relevant to the UI.
The first such frontend is going have a command-line user interface --
currently, I envision something similar to the CLIs of the Procurve
switches and Cisco routers that I have worked with.
Like modern network gear CLIs, commands are going to resemble
simple sentences, (i.e. show vlans ports 1-4) and the CLI will
have some implicit state, much in the way that Unix shells and
cmd.exe in Windows have environment variables and current working
directories. Moreover, I'd like to implement great tab completion that
is aware of the application's state as much as possible and I want to be able to do that with as
little application-specific code as possible.
The low-level functionality (terminal I/O) seems easy to implement on
top of GNU Readline or similar libraries, but that's only where the
real fun starts. So far I have looked at the Perl modules
Term::Shell
and
Term::ShellUI,
but I'm not convinced that I want to use either of them. I am still
considering rolling my own solution and at the moment I am primarily looking for
inspiration.
Can you recommend any application or library, regardless of
implementation language, that implements a good CLI from which I can
borrow ideas?
I suggest you take a look at the philosophy underlying Microsoft PowerShell. From the idea of piping typed objects between commands to the consistency of its commands and argument syntax, I think it can be a source of inspiration.
You could try having a look at libcli :
"Libcli provides a shared library for
including a Cisco-like command-line
interface into other software."
http://code.google.com/p/libcli/
BTW - I forgot to mention that it is GNU Lesser GPL and actually used by Cisco in some products.
As for your last sentence/question, I'm particularly fond of zsh completion and line editing (zle).