Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 1.13 KB

PythonBindings.md

File metadata and controls

50 lines (40 loc) · 1.13 KB

Python bindings

Currently there are no offical python support. The feature is planned. But nevertheless, you can use Etaler in Python via ROOT and it's automatic binding generation feature.

Example

# Load ROOT
import ROOT
gROOT = ROOT.gROOT
gSystem = ROOT.gSystem

# Include Etaler headers
gROOT.ProcessLine("""
#include <Etaler/Etaler.hpp>
#include <Etaler/Algorithms/SpatialPooler.hpp>
#include <Etaler/Algorithms/TemporalMemory.hpp>
#include <Etaler/Algorithms/Anomaly.hpp>
#include <Etaler/Encoders/GridCell1d.hpp>
""")
# Load the library
gSystem.Load("/usr/local/lib/libEtaler.so");

# make a handy namespace alias
et = ROOT.et

Then you can call Etaler functions from Python.

s = et.Shape()
[s.push_back(v) for v in [2, 2]] #HACK: ROOT doesn't support initalizer lists.
t = et.ones(s)
print(t)
"""
{{ 1, 1}, 
 { 1, 1}}

"""

PyEtaler

The offical Python binding - PyEtaler in currently work in progress. We recomment using ROOT to bind from Python before PyEtaler leaves WIP.

>>> from etaler import et
>>> et.ones([2, 2])
{{ 1, 1}, 
 { 1, 1}}