next up previous contents index
Next: Using SIC from Python Up: Using Python from SIC Previous: The SIC command PYTHON   Contents   Index

Calling Python functions

The Python community has developped a large set of additional modules for many purposes. Some functions that SIC does not provide can be imported from an external Python module. User can also define its own functions written with Python.

The numerical functions can be called from SIC formulas. When SIC does not find a function in its own builtin or user-defined ones, it will have a look in the Python main namespace area (if Python interpreter is launched!). If one object name matches and is callable, it will call this Python function with the arguments you provided:

SIC> PYTHON from scipy.special import jn
>>> from scipy.special import jn
SIC> PYTHON print jn.__doc__
>>> print jn.__doc__
y = jn(n,x) returns the Bessel function of integer order n at x.
SIC> A = JN(0,1)
A               =   0.7651977                ! Real    GLOBAL
jn5 is the Bessel function, called here at order 0 with x = 1. Always take care to import (or create) your Python functions in the main namespace. Note that function names are fully lowercased before trying to match them with Python names.

Gildas manager 2014-07-01