Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
Pyston Namespace Reference

Classes

class  AttrGetter
 
struct  BinaryWrapper
 
class  Cast
 
class  Constant
 
class  Exception
 
class  ExceptionRaiser
 
class  ExpressionTree
 
class  ExpressionTree< R(Args...)>
 
class  ExpressionTree< R(const std::vector< T > &)>
 
class  ExpressionTreeBase
 
class  ExpressionTreeBuilder
 
class  Function
 
class  FunctionFactory
 
class  FunctionFactory< R(Args...)>
 
class  GILLocker
 
class  GILReleaser
 
class  GraphvizGenerator
 
struct  Identity
 
struct  makeBinaryFunctionHelper
 
struct  makeBinaryFunctionHelper< R(T, T)>
 
struct  makeFunctionHelper
 
struct  makeFunctionHelper< R(Args...)>
 
struct  makeFunctionHelper< R(const Context &, Args...)>
 
class  Node
 
class  NodeBase
 
struct  NodeCast
 
struct  NodeCast< double >
 
struct  NodeCast< int64_t >
 
struct  NodeConverter
 
class  Placeholder
 
class  Placeholder< AttributeSet >
 
class  PythonCall
 
class  RecoverableError
 
struct  RegisterNode
 
class  SaveThread
 
class  TextReprVisitor
 
struct  UnaryWrapper
 
class  UnrecoverableError
 
struct  VariantToPython
 
class  Visitor
 

Typedefs

template<typename T >
using Pow = BinaryWrapper< T, T, std::pow >
 Wraps the power function.
 
template<typename T >
using Abs = UnaryWrapper< T, T, std::abs >
 Wraps the abs function.
 
template<typename T >
using Round = UnaryWrapper< T, T, std::round >
 Wraps the round function.
 
template<typename T >
using Exp = UnaryWrapper< T, T, std::exp >
 Wraps the exponential function.
 
template<typename T >
using Exp2 = UnaryWrapper< T, T, std::exp2 >
 Wraps the exponential, base 2, function.
 
template<typename T >
using Log = UnaryWrapper< T, T, std::log >
 Wraps the log function.
 
template<typename T >
using Log2 = UnaryWrapper< T, T, std::log2 >
 Wraps the log, base 2, function.
 
template<typename T >
using Log10 = UnaryWrapper< T, T, std::log10 >
 Wraps the log, base 10, function.
 
template<typename T >
using Sqrt = UnaryWrapper< T, T, std::sqrt >
 Wraps the square root function.
 
template<typename T >
using Sin = UnaryWrapper< T, T, std::sin >
 Wraps the sin function.
 
template<typename T >
using Cos = UnaryWrapper< T, T, std::cos >
 Wraps the cos function.
 
template<typename T >
using Tan = UnaryWrapper< T, T, std::tan >
 Wraps the tan function.
 
template<typename T >
using ArcSin = UnaryWrapper< T, T, std::asin >
 Wraps the arcsin function.
 
template<typename T >
using ArcCos = UnaryWrapper< T, T, std::acos >
 Wraps the arcos function.
 
template<typename T >
using ArcTan = UnaryWrapper< T, T, std::atan >
 Wraps the arctan function.
 
template<typename T >
using Sinh = UnaryWrapper< T, T, std::sinh >
 Wraps the hyperbolic sin function.
 
template<typename T >
using Cosh = UnaryWrapper< T, T, std::cosh >
 Wraps the hyperbolic cos function.
 
template<typename T >
using Tanh = UnaryWrapper< T, T, std::tanh >
 Wraps the hyperbolic tan function.
 
template<typename T >
using ArcSinh = UnaryWrapper< T, T, std::asinh >
 Wraps the hyperbolic arcsin function.
 
template<typename T >
using ArcCosh = UnaryWrapper< T, T, std::acosh >
 Wraps the hyperbolic arccos function.
 
template<typename T >
using ArcTanh = UnaryWrapper< T, T, std::atanh >
 Wraps the hyperbolic arctan function.
 
template<typename T >
using ArcTan2 = BinaryWrapper< T, T, std::atan2 >
 Wraps atan2.
 
template<typename T >
using Fmod = BinaryWrapper< T, T, std::fmod >
 Wraps fmod.
 
using Attribute = boost::variant< bool, int64_t, double >
 
using AttributeSet = std::map< std::string, Attribute >
 
using Value = boost::variant< bool, int64_t, double, AttributeSet >
 
using Arguments = std::vector< Value >
 
using Context = std::map< std::string, boost::any >
 

Functions

template<typename Signature >
static boost::python::object makeFunction (const std::string &repr, std::function< Signature > functor)
 
template<typename Signature >
static boost::python::object makeBinaryFunction (const std::string &repr, std::function< Signature > functor, bool reversed=false)
 
template<typename To , typename From >
static bool createCastNode (boost::python::object &object, void *storage)
 
boost::python::numpy::ndarray table2numpy (const Euclid::Table::Table &table)
 
static std::string escape (const std::string &str)
 
py::object attributeSetGetter (const AttributeSet &attr_set, const std::string &name)
 
void RegisterAttributeSet ()
 
static PyObject * createExceptionClass (const std::string &name)
 
void translateRecoverable (const RecoverableError &e)
 
void translateUnrecoverable (const UnrecoverableError &e)
 
 BOOST_PYTHON_MODULE (pyston)
 

Variables

thread_local Context sharedContext
 
static size_t s_lock_count = 0
 
PyObject * pyRecoverableError = nullptr
 
PyObject * pyUnrecoverableError = nullptr
 

Detailed Description

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Copyright (C) 2012-2022 Euclid Science Ground Segment

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Typedef Documentation

◆ Abs

template<typename T >
using Pyston::Abs = typedef UnaryWrapper<T, T, std::abs>

Wraps the abs function.

Definition at line 78 of file Functors.h.

◆ ArcCos

template<typename T >
using Pyston::ArcCos = typedef UnaryWrapper<T, T, std::acos>

Wraps the arcos function.

Definition at line 126 of file Functors.h.

◆ ArcCosh

template<typename T >
using Pyston::ArcCosh = typedef UnaryWrapper<T, T, std::acosh>

Wraps the hyperbolic arccos function.

Definition at line 150 of file Functors.h.

◆ ArcSin

template<typename T >
using Pyston::ArcSin = typedef UnaryWrapper<T, T, std::asin>

Wraps the arcsin function.

Definition at line 122 of file Functors.h.

◆ ArcSinh

template<typename T >
using Pyston::ArcSinh = typedef UnaryWrapper<T, T, std::asinh>

Wraps the hyperbolic arcsin function.

Definition at line 146 of file Functors.h.

◆ ArcTan

template<typename T >
using Pyston::ArcTan = typedef UnaryWrapper<T, T, std::atan>

Wraps the arctan function.

Definition at line 130 of file Functors.h.

◆ ArcTan2

template<typename T >
using Pyston::ArcTan2 = typedef BinaryWrapper<T,T, std::atan2>

Wraps atan2.

Definition at line 158 of file Functors.h.

◆ ArcTanh

template<typename T >
using Pyston::ArcTanh = typedef UnaryWrapper<T, T, std::atanh>

Wraps the hyperbolic arctan function.

Definition at line 154 of file Functors.h.

◆ Arguments

A vector where the values correspond to the position placeholders have, on the function call.

Definition at line 94 of file Node.h.

◆ Attribute

using Pyston::Attribute = typedef boost::variant<bool, int64_t, double>

Arbitrary key/value pairs, interpreted as an object attribute

Definition at line 82 of file Node.h.

◆ AttributeSet

Definition at line 83 of file Node.h.

◆ Context

using Pyston::Context = typedef std::map<std::string, boost::any>

Arbitrary key/value pairing for giving a context to function calls

Definition at line 99 of file Node.h.

◆ Cos

template<typename T >
using Pyston::Cos = typedef UnaryWrapper<T, T, std::cos>

Wraps the cos function.

Definition at line 114 of file Functors.h.

◆ Cosh

template<typename T >
using Pyston::Cosh = typedef UnaryWrapper<T, T, std::cosh>

Wraps the hyperbolic cos function.

Definition at line 138 of file Functors.h.

◆ Exp

template<typename T >
using Pyston::Exp = typedef UnaryWrapper<T, T, std::exp>

Wraps the exponential function.

Definition at line 86 of file Functors.h.

◆ Exp2

template<typename T >
using Pyston::Exp2 = typedef UnaryWrapper<T, T, std::exp2>

Wraps the exponential, base 2, function.

Definition at line 90 of file Functors.h.

◆ Fmod

template<typename T >
using Pyston::Fmod = typedef BinaryWrapper<T, T, std::fmod>

Wraps fmod.

Definition at line 162 of file Functors.h.

◆ Log

template<typename T >
using Pyston::Log = typedef UnaryWrapper<T, T, std::log>

Wraps the log function.

Definition at line 94 of file Functors.h.

◆ Log10

template<typename T >
using Pyston::Log10 = typedef UnaryWrapper<T, T, std::log10>

Wraps the log, base 10, function.

Definition at line 102 of file Functors.h.

◆ Log2

template<typename T >
using Pyston::Log2 = typedef UnaryWrapper<T, T, std::log2>

Wraps the log, base 2, function.

Definition at line 98 of file Functors.h.

◆ Pow

template<typename T >
using Pyston::Pow = typedef BinaryWrapper<T, T, std::pow>

Wraps the power function.

Definition at line 74 of file Functors.h.

◆ Round

template<typename T >
using Pyston::Round = typedef UnaryWrapper<T, T, std::round>

Wraps the round function.

Definition at line 82 of file Functors.h.

◆ Sin

template<typename T >
using Pyston::Sin = typedef UnaryWrapper<T, T, std::sin>

Wraps the sin function.

Definition at line 110 of file Functors.h.

◆ Sinh

template<typename T >
using Pyston::Sinh = typedef UnaryWrapper<T, T, std::sinh>

Wraps the hyperbolic sin function.

Definition at line 134 of file Functors.h.

◆ Sqrt

template<typename T >
using Pyston::Sqrt = typedef UnaryWrapper<T, T, std::sqrt>

Wraps the square root function.

Definition at line 106 of file Functors.h.

◆ Tan

template<typename T >
using Pyston::Tan = typedef UnaryWrapper<T, T, std::tan>

Wraps the tan function.

Definition at line 118 of file Functors.h.

◆ Tanh

template<typename T >
using Pyston::Tanh = typedef UnaryWrapper<T, T, std::tanh>

Wraps the hyperbolic tan function.

Definition at line 142 of file Functors.h.

◆ Value

using Pyston::Value = typedef boost::variant<bool, int64_t, double, AttributeSet>

Can hold any values a Placeholder may require

Definition at line 88 of file Node.h.

Function Documentation

◆ attributeSetGetter()

py::object Pyston::attributeSetGetter ( const AttributeSet attr_set,
const std::string name 
)

Definition at line 224 of file Module.cpp.

References std::map< K, T >::end(), and std::map< K, T >::find().

Referenced by RegisterAttributeSet().

Here is the call graph for this function:

◆ BOOST_PYTHON_MODULE()

Pyston::BOOST_PYTHON_MODULE ( pyston  )

◆ createCastNode()

template<typename To , typename From >
static bool Pyston::createCastNode ( boost::python::object &  object,
void *  storage 
)
static

Create a new Cast Node from a Node of some other type (i.e. bool => float)

Template Parameters
FromOriginal type
Parameters
objectPython object
storageMemory area, handled by boost::python, where to store the new object
Returns
true if it could be converted

Definition at line 39 of file NodeConverter.h.

◆ createExceptionClass()

static PyObject * Pyston::createExceptionClass ( const std::string name)
static

Create a new exception on the Python side

Used by Recoverable and Unrecoverable errors, which can not be directly exposed, since they do not (and can not due to boost::python API limitations) inherit from Python's Exception

Definition at line 256 of file Module.cpp.

References std::string::c_str().

Referenced by BOOST_PYTHON_MODULE().

Here is the call graph for this function:

◆ escape()

static std::string Pyston::escape ( const std::string str)
static

◆ makeBinaryFunction()

template<typename Signature >
static boost::python::object Pyston::makeBinaryFunction ( const std::string repr,
std::function< Signature >  functor,
bool  reversed = false 
)
static

Special case that allows to create calls to binary functions, supporting the reversal or arguments if needed, which is the case for methods like rmul, rpow and similar The functor can only receive parameters of the same type. Any required casting will be done by NodeConverter

Template Parameters
SignatureSignature of the functor that receives two parameters of the same type
Parameters
reprLiteral representation of the node, for pretty-printing
functorFunctor to insert
Returns
A callable python object

Definition at line 124 of file Helpers.h.

Referenced by Pyston::RegisterNode< T >::defCastOperations(), Pyston::RegisterNode< T >::general(), Pyston::RegisterNode< T >::specialized(), and Pyston::RegisterNode< T >::specialized().

◆ makeFunction()

template<typename Signature >
static boost::python::object Pyston::makeFunction ( const std::string repr,
std::function< Signature >  functor 
)
static

boost::python seems to have some trouble attaching functors as methods to python objects, so it requires some massaging in order to figure out the signature, keep the reference alive, etc. Since the code is a bit convolved, we isolate it here to make it easier to use

Template Parameters
SignatureSignature of the functor
Parameters
reprLiteral representation of the node, for pretty-printing
functorFunctor to insert
Returns
A callable python object

Definition at line 104 of file Helpers.h.

Referenced by Pyston::RegisterNode< T >::general(), Pyston::RegisterNode< T >::specialized(), and Pyston::RegisterNode< T >::specialized().

◆ RegisterAttributeSet()

void Pyston::RegisterAttributeSet ( )

Register the attribute set placeholder

Definition at line 235 of file Module.cpp.

References attributeSetGetter().

Referenced by BOOST_PYTHON_MODULE().

Here is the call graph for this function:

◆ table2numpy()

boost::python::numpy::ndarray Pyston::table2numpy ( const Euclid::Table::Table table)

Transform an Euclid::Table::Table into a numpy structured array

Definition at line 218 of file Table2Numpy.cpp.

References Euclid::Table::Table::getColumnInfo(), and Euclid::Table::Table::size().

Here is the call graph for this function:

◆ translateRecoverable()

void Pyston::translateRecoverable ( const RecoverableError e)

Translate C++ recoverable exception to its Python counterpart

Definition at line 269 of file Module.cpp.

References pyRecoverableError.

Referenced by BOOST_PYTHON_MODULE().

◆ translateUnrecoverable()

void Pyston::translateUnrecoverable ( const UnrecoverableError e)

Translate C++ unrecoverable exception to its Python counterpart

Definition at line 276 of file Module.cpp.

References pyUnrecoverableError.

Referenced by BOOST_PYTHON_MODULE().

Variable Documentation

◆ pyRecoverableError

PyObject* Pyston::pyRecoverableError = nullptr

Definition at line 61 of file Module.cpp.

Referenced by BOOST_PYTHON_MODULE(), and translateRecoverable().

◆ pyUnrecoverableError

PyObject* Pyston::pyUnrecoverableError = nullptr

Definition at line 62 of file Module.cpp.

Referenced by BOOST_PYTHON_MODULE(), and translateUnrecoverable().

◆ s_lock_count

size_t Pyston::s_lock_count = 0
static

◆ sharedContext

thread_local Context Pyston::sharedContext

This context is used globally (per thread) to pass a context whenever the original python snippet could not be compiled. Basically, it is stored on this global just before jumping into python, and passed to the registered function that has need for it.

See also
PythonCall
ExpressionTreeBuilder::registerFunction

Definition at line 22 of file SharedContext.cpp.

Referenced by Pyston::PythonCall< T >::eval().