Overview - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


OpenMaple Application Program Interface (API) for Python

  

OpenMaple for Python provides an interface between the Maple evaluation engine and a Python program.  This is implemented using Python classes and standard interfaces.

 

Overview

maple Package

maple.namespace Subpackage

Classes

Overview

  

To use the Maple API for Python, start by importing the library maple. This implicitly launches a Maple session.

import maple

maple Package

• 

The maple package has the following commands:

range

symbol

symbols

 

• 

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 offers general access to any Maple name or function.

– 

The range function returns an Expression object corresponding to a Maple range.

maple.namespace Subpackage

• 

The maple.namespace subpackage allows any Maple name or function to be accessed with a simple prefix. This prefix is arbitrary, but for consistency in these examples we will assume the subpackage was assigned the name mpl after being imported with the following command.

import maple.namespace as mpl

• 

Global names or commands may be referenced as mpl.sin, mpl.solve, etc.

• 

Commands in Maple packages or subpackages may be referenced using the chosen prefix and replacing instances of the Maple member selection operator (:-) in the Maple qualified name with a period (.). For example, LinearAlgebra:-Determinant would become mpl.LinearAlgebra.Determinant.

Classes

• 

Every OpenMaple object created in a Python session is an Expression object.

• 

Depending on the type of the underlying Maple expression, the object may also be an instance of a subclass of Expression, such as ComplexNumeric or List.

Class Listing

ComplexNumeric

Expression

ExpressionSequence

Indexable

List

Name

RealNumeric

RTable

Set

Table

 

 

Expression

• 

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

 

 

ComplexNumeric

• 

The ComplexNumeric class represents complex numbers.  Conceptually, a ComplexNumeric object contains two RealNumeric objects: its real part and its imaginary part.

• 

Inherits from Expression.

conjugate

imag

real

 

RealNumeric

• 

The RealNumeric class represents numeric literals. Note that Maple integers and fractions appearing in output from OpenMaple computations are represented as Python integers and Fractions.fraction objects, so this class is effectively only used for floating-point numbers.

• 

Inherits from ComplexNumeric.

Name

• 

The Name class represents a Maple symbol. This includes both global symbols and names defined in Maple packages.

• 

Inherits from Expression.

__getattr__

assign

 

 

Indexable

• 

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.

• 

Inherits from Expression.

__contains__

__iter__

__len__

 

ExpressionSequence

• 

The ExpressionSequence class represents a Maple expression sequence.

• 

Inherits from Indexable.

__reversed__

index

 

 

List

• 

The List class represents a Maple list.

• 

Inherits from Indexable.

__reversed__

index

 

 

RTable

• 

The RTable class represents an rtable (rectangular table), a Maple data structure for storing homogenous data of arbitrary dimension.

• 

Inherits from Indexable.

__bytes__

 

 

 

Set

• 

The Set class represents a Maple set.

• 

Inherits from Indexable.

__`and`__

__`or`__

__`xor`__

__ge__

__gt__

__le__

__lt__

__sub__

isdisjoint

 

 

 

Table

• 

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.

• 

Inherits from Indexable.

See Also

Python