OpenMaple Application Program Interface (API) for Python
Python Maple provides an interface between the Maple evaluation engine and a Python program. This is implemented using Python classes and Python interfaces. The classes allow Python programs to access the Maple evaluation engine. The interfaces allow the Maple evaluation engine to call Python functions.
Overviewmaple.namespace SubpackageClasses
<Text-field style="Heading 2" layout="Heading 2" bookmark="bkmrk0">Overview</Text-field>
To use the Maple API for Python, start by importing the library maple. This implicitly launches a Maple session.
import maple
To access Maple variables and predefined functions and commands, you can use the symbol or symbols function or import the maple.namespace interface:
The symbol function returns an Expression object.
The symbols function returns a tuple of Expression objects.
The namespace subpackage
<Text-field style="Heading 2" layout="Heading 2" bookmark="bkmrk1">maple.namespace Subpackage</Text-field>
The maple.namespace subpackage allows any Maple variable or function to be accessed with a simple prefix.import maple.namespace as mpl
lengthFormula = mpl.sqrt( mpl.x**2 + mpl.y**2 + mpl.z**2 )
<Text-field style="Heading 2" layout="Heading 2" bookmark="bkmrk2">Classes</Text-field>
The following classes are automatically applied to Maple objects created in a session. All objects are instances of the parent class Expression.
<Text-field style="Heading 3" layout="Heading 3" bookmark="bkmrk3">Class Listing</Text-field>ComplexNumericExpressionIndexableListNameRealNumericRTableSetTable
<Text-field style="Heading 4" layout="Heading 4" bookmark="bkmrk4">Expression</Text-field>
The Expression class is the parent class of all the classes that represent Maple objects. Its member functions provide access to all the basic functions that can be performed on a Maple expression.__abs____add____call____ceil____eq____floor____floordiv____ge____getitem____gt____hash____le____len____lt____mul____ne____neg____pow____radd____rfloordiv____rmod____rmul____round____rpow____rsub____rtruediv____sub____truediv____trunc__eval
<Text-field style="Heading 4" layout="Heading 4" bookmark="bkmrk5">RealNumeric</Text-field>
The RealNumeric class represents numeric object. Note that Maple integers and fractions are implicitly translated to Python integers and Fractions.fraction objects, so this class is only used for floating-point numbers.
<Text-field style="Heading 4" layout="Heading 4" bookmark="bkmrk6">ComplexNumeric</Text-field>
The ComplexNumeric class represents complex numbers. Conceptually, a ComplexNumeric object contains two RealNumeric objects: its real part and its imaginary part.conjugateimagreal
<Text-field style="Heading 4" layout="Heading 4" bookmark="bkmrk7">Name</Text-field>
The Name class represents a Maple name. Name publicly inherits from Expression.__getattr__assign
<Text-field style="Heading 4" layout="Heading 4" bookmark="bkmrk8">Indexable</Text-field>
The Indexable class is the parent class of all the classes that represent Maple collections. Its member functions provide access to the basic functions that can be performed on a collection, such as querying its size and testing for membership.__contains____iter____len__
<Text-field style="Heading 4" layout="Heading 4" bookmark="bkmrk9">RTable</Text-field>
The RTable class represents an rtable. Datatype specific rtables are represented by sub-classes of RTable. These sub-classes have datatype specific functions. The RTable member functions perform operations applicable to any rtable.
<Text-field style="Heading 4" layout="Heading 4" bookmark="bkmrk10">Table</Text-field>
The Table class represents a table. Data can be inserted and removed from the table and a table can be searched for a particular element.
See AlsoPython