/* Generated by Cython 0.29.5 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [],
        "libraries": [
            "madx"
        ],
        "name": "cpymad.libmadx",
        "sources": [
            "src/cpymad/libmadx.pyx"
        ]
    },
    "module_name": "cpymad.libmadx"
}
END: Cython Metadata */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_5"
#define CYTHON_HEX_VERSION 0x001D05F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
  #define PyObject_Unicode             PyObject_Str
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif


#define __PYX_ERR(f_index, lineno, Ln_error) \
{ \
  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
}

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__cpymad__libmadx
#define __PYX_HAVE_API__cpymad__libmadx
/* Early includes */
#include "pyport.h"
#include "string.h"
#include "madX/mad_types_f.h"
#include "madX/mad_extrn_f.h"
#include "madX/mad_def.h"
#include "madX/mad_gcst.h"
#include "madX/mad_array.h"
#include "madX/mad_name.h"
#include "madX/mad_table.h"
#include "madX/mad_expr.h"
#include "madX/mad_cmdpar.h"
#include "madX/mad_cmd.h"
#include "madX/mad_elem.h"
#include "madX/mad_node.h"
#include "madX/mad_seq.h"
#include "madX/mad_var.h"
#include "madX/mad_gvar.h"
#include "madX/mad_api.h"
#include "madX/mad_core.h"
#include "madX/mad_err.h"
#include "madX/mad_str.h"
#include "madX/mad_eval.h"
#include "madX/mad_parse.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "src/cpymad/libmadx.pyx",
};
/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()

/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif


/*--- Type declarations ---*/
struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row;

/* "cpymad/clibmadx.pxd":106
 *         command_parameter** parameters
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     PARAM_TYPE_LOGICAL = 0
 *     PARAM_TYPE_INTEGER = 1
 */
enum  {
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_LOGICAL = 0,
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_INTEGER = 1,
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_DOUBLE = 2,
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_STRING = 3,
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_CONSTRAINT = 4,
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_LOGICAL_ARRAY = 10,
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_INTEGER_ARRAY = 11,
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_DOUBLE_ARRAY = 12,
  __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_STRING_ARRAY = 13
};

/* "cpymad/clibmadx.pxd":117
 *     PARAM_TYPE_STRING_ARRAY = 13
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     CONSTR_TYPE_NONE = 0            # occurs in defined_commands
 *     CONSTR_TYPE_MIN = 1
 */
enum  {
  __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_NONE = 0,
  __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_MIN = 1,
  __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_MAX = 2,
  __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_BOTH = 3,
  __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_VALUE = 4
};

/* "cpymad/clibmadx.pxd":124
 *     CONSTR_TYPE_VALUE = 4
 * 
 * cdef enum:                          # struct variable::type             # <<<<<<<<<<<<<<
 *     VAR_TYPE_CONST = 0
 *     VAR_TYPE_DIRECT = 1
 */
enum  {
  __pyx_e_6cpymad_8clibmadx_VAR_TYPE_CONST = 0,
  __pyx_e_6cpymad_8clibmadx_VAR_TYPE_DIRECT = 1,
  __pyx_e_6cpymad_8clibmadx_VAR_TYPE_DEFERRED = 2,
  __pyx_e_6cpymad_8clibmadx_VAR_TYPE_STRING = 3
};

/* "cpymad/clibmadx.pxd":130
 *     VAR_TYPE_STRING = 3
 * 
 * cdef enum:                          # struct variable::val_type             # <<<<<<<<<<<<<<
 *     VAL_TYPE_INTEGER = 0
 *     VAL_TYPE_DOUBLE = 1
 */
enum  {
  __pyx_e_6cpymad_8clibmadx_VAL_TYPE_INTEGER = 0,
  __pyx_e_6cpymad_8clibmadx_VAL_TYPE_DOUBLE = 1
};

/* "cpymad/clibmadx.pxd":211
 *         variable** vars             # variable pointer list
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     REF_EXIT = -1
 *     REF_CENTER = 0
 */
enum  {
  __pyx_e_6cpymad_8clibmadx_REF_EXIT = -1L,
  __pyx_e_6cpymad_8clibmadx_REF_CENTER = 0,
  __pyx_e_6cpymad_8clibmadx_REF_ENTRY = 1
};
struct __pyx_opt_args_6cpymad_7libmadx__expr;

/* "cpymad/libmadx.pyx":989
 * _expr_types = [bool, int, float]
 * 
 * cdef _expr(clib.expression* expr,             # <<<<<<<<<<<<<<
 *            double value,
 *            int typeid=clib.PARAM_TYPE_DOUBLE):
 */
struct __pyx_opt_args_6cpymad_7libmadx__expr {
  int __pyx_n;
  int typeid;
};

/* "cpymad/libmadx.pyx":489
 * 
 * 
 * def get_table_row(table_name, row_index, columns='selected'):             # <<<<<<<<<<<<<<
 *     """
 *     Return row as tuple of values.
 */
struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row {
  PyObject_HEAD
  PyObject *__pyx_v_row_index;
  struct table *__pyx_v_table;
};


/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* PyIntFromDouble.proto */
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE PyObject* __Pyx_PyInt_FromDouble(double value);
#else
#define __Pyx_PyInt_FromDouble(value) PyLong_FromDouble(value)
#endif

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunction.proto */
#define __Pyx_CyFunction_USED 1
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* PyIntCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_FloorDivideObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceFloorDivide(op1, op2) : PyNumber_FloorDivide(op1, op2))
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_RemainderObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceRemainder(op1, op2) : PyNumber_Remainder(op1, op2))
#endif

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* decode_c_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 0;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = -1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}

/* decode_c_string.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);


/* Module declarations from 'cpymad.clibmadx' */

/* Module declarations from 'cpymad.libmadx' */
static PyTypeObject *__pyx_ptype_6cpymad_7libmadx___pyx_scope_struct__get_table_row = 0;
static struct expression *__pyx_f_6cpymad_7libmadx__make_expr(PyObject *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__expr(struct expression *, double, struct __pyx_opt_args_6cpymad_7libmadx__expr *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__get_param_value(struct command_parameter *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__parse_command(struct command *); /*proto*/
static struct sequence *__pyx_f_6cpymad_7libmadx__find_sequence(PyObject *); /*proto*/
static struct table *__pyx_f_6cpymad_7libmadx__find_table(PyObject *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__split_header_line(PyObject *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__name_list(struct name_list *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__str(char const *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__cstr(PyObject *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__node_name(struct node *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__get_node(struct node *, int, int, int); /*proto*/
static double __pyx_f_6cpymad_7libmadx__get_node_entry_pos(struct node *, int, int); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__get_element(struct element *); /*proto*/
static PyObject *__pyx_f_6cpymad_7libmadx__get_table_row_name(struct table *, int); /*proto*/
static struct variable *__pyx_f_6cpymad_7libmadx__get_var(PyObject *); /*proto*/
static void __pyx_f_6cpymad_7libmadx__strip_comments(char *); /*proto*/
#define __Pyx_MODULE_NAME "cpymad.libmadx"
extern int __pyx_module_is_main_cpymad__libmadx;
int __pyx_module_is_main_cpymad__libmadx = 0;

/* Implementation of 'cpymad.libmadx' */
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_map;
static PyObject *__pyx_builtin_KeyError;
static const char __pyx_k_[] = " ";
static const char __pyx_k_S[] = "S";
static const char __pyx_k_V[] = "V";
static const char __pyx_k_d[] = "d";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_k[] = "k";
static const char __pyx_k_s[] = "s";
static const char __pyx_k_t[] = "t";
static const char __pyx_k__3[] = ";";
static const char __pyx_k__7[] = ".";
static const char __pyx_k_at[] = "at";
static const char __pyx_k_le[] = "%le";
static const char __pyx_k_np[] = "np";
static const char __pyx_k_os[] = "os";
static const char __pyx_k__13[] = "";
static const char __pyx_k_all[] = "all";
static const char __pyx_k_cmd[] = "cmd";
static const char __pyx_k_col[] = "col";
static const char __pyx_k_idx[] = "idx";
static const char __pyx_k_map[] = "map";
static const char __pyx_k_max[] = "max";
static const char __pyx_k_min[] = "min";
static const char __pyx_k_pch[] = "_pch";
static const char __pyx_k_seq[] = "seq";
static const char __pyx_k_val[] = "val";
static const char __pyx_k_var[] = "var";
static const char __pyx_k_addr[] = "addr";
static const char __pyx_k_data[] = "data";
static const char __pyx_k_elem[] = "elem";
static const char __pyx_k_eval[] = "eval";
static const char __pyx_k_expr[] = "expr";
static const char __pyx_k_from[] = "from";
static const char __pyx_k_info[] = "info";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_name[] = "name";
static const char __pyx_k_seqs[] = "seqs";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_vars[] = "vars";
static const char __pyx_k_all_2[] = "__all__";
static const char __pyx_k_array[] = "array";
static const char __pyx_k_chdir[] = "chdir";
static const char __pyx_k_cmd_2[] = "_cmd";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_elems[] = "elems";
static const char __pyx_k_error[] = "error";
static const char __pyx_k_index[] = "index";
static const char __pyx_k_input[] = "input";
static const char __pyx_k_lower[] = "lower";
static const char __pyx_k_nodes[] = "nodes";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_strip[] = "strip";
static const char __pyx_k_table[] = "table";
static const char __pyx_k_utf_8[] = "utf-8";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_ctypes[] = "ctypes";
static const char __pyx_k_enable[] = "enable";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_finish[] = "finish";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_getcwd[] = "getcwd";
static const char __pyx_k_header[] = "header";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_inform[] = "inform";
static const char __pyx_k_length[] = "length";
static const char __pyx_k_name_2[] = "__name__";
static const char __pyx_k_parent[] = "parent";
static const char __pyx_k_rsplit[] = "rsplit";
static const char __pyx_k_rstrip[] = "rstrip";
static const char __pyx_k_typeid[] = "typeid";
static const char __pyx_k_columns[] = "columns";
static const char __pyx_k_get_var[] = "get_var";
static const char __pyx_k_indices[] = "indices";
static const char __pyx_k_occ_cnt[] = "occ_cnt";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_as_array[] = "as_array";
static const char __pyx_k_c_double[] = "c_double";
static const char __pyx_k_char_tmp[] = "char_tmp";
static const char __pyx_k_col_name[] = "_col_name";
static const char __pyx_k_endswith[] = "endswith";
static const char __pyx_k_position[] = "position";
static const char __pyx_k_selected[] = "selected";
static const char __pyx_k_sentence[] = "sentence";
static const char __pyx_k_tab_name[] = "_tab_name";
static const char __pyx_k_var_type[] = "var_type";
static const char __pyx_k_Parameter[] = "Parameter";
static const char __pyx_k_base_name[] = "base_name";
static const char __pyx_k_base_type[] = "base_type";
static const char __pyx_k_col_index[] = "col_index";
static const char __pyx_k_ctypeslib[] = "ctypeslib";
static const char __pyx_k_node_name[] = "node_name";
static const char __pyx_k_row_index[] = "row_index";
static const char __pyx_k_Constraint[] = "Constraint";
static const char __pyx_k_IndexError[] = "IndexError";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_array_data[] = "array_data";
static const char __pyx_k_array_type[] = "array_type";
static const char __pyx_k_expr_types[] = "_expr_types";
static const char __pyx_k_expression[] = "expression";
static const char __pyx_k_is_started[] = "is_started";
static const char __pyx_k_position_2[] = "_position";
static const char __pyx_k_table_name[] = "table_name";
static const char __pyx_k_column_name[] = "column_name";
static const char __pyx_k_cpymad_util[] = "cpymad.util";
static const char __pyx_k_fetch_value[] = "fetch_value";
static const char __pyx_k_get_element[] = "get_element";
static const char __pyx_k_get_globals[] = "get_globals";
static const char __pyx_k_get_options[] = "get_options";
static const char __pyx_k_num_globals[] = "num_globals";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_command_name[] = "command_name";
static const char __pyx_k_cpymad_types[] = "cpymad.types";
static const char __pyx_k_element_name[] = "element_name";
static const char __pyx_k_from_address[] = "from_address";
static const char __pyx_k_get_var_type[] = "get_var_type";
static const char __pyx_k_madx_started[] = "_madx_started";
static const char __pyx_k_table_exists[] = "table_exists";
static const char __pyx_k_table_name_2[] = "_table_name";
static const char __pyx_k_version_info[] = "version_info";
static const char __pyx_k_element_index[] = "element_index";
static const char __pyx_k_get_table_row[] = "get_table_row";
static const char __pyx_k_sequence_name[] = "sequence_name";
static const char __pyx_k_command_name_2[] = "_command_name";
static const char __pyx_k_cpymad_libmadx[] = "cpymad.libmadx";
static const char __pyx_k_element_name_2[] = "_element_name";
static const char __pyx_k_Invalid_table_r[] = "Invalid table: {!r}";
static const char __pyx_k_expression_vars[] = "expression_vars";
static const char __pyx_k_get_table_count[] = "get_table_count";
static const char __pyx_k_get_table_names[] = "get_table_names";
static const char __pyx_k_sequence_exists[] = "sequence_exists";
static const char __pyx_k_get_element_name[] = "get_element_name";
static const char __pyx_k_get_table_column[] = "get_table_column";
static const char __pyx_k_get_version_date[] = "get_version_date";
static const char __pyx_k_name_to_internal[] = "name_to_internal";
static const char __pyx_k_Invalid_command_r[] = "Invalid command: {!r}";
static const char __pyx_k_Invalid_row_index[] = "Invalid row index: {}";
static const char __pyx_k_get_element_count[] = "get_element_count";
static const char __pyx_k_get_element_index[] = "get_element_index";
static const char __pyx_k_get_element_names[] = "get_element_names";
static const char __pyx_k_get_sequence_beam[] = "get_sequence_beam";
static const char __pyx_k_get_table_summary[] = "get_table_summary";
static const char __pyx_k_Invalid_sequence_r[] = "Invalid sequence: {!r}";
static const char __pyx_k_No_active_sequence[] = "No active sequence!";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_get_global_element[] = "get_global_element";
static const char __pyx_k_get_rightmost_word[] = "_get_rightmost_word";
static const char __pyx_k_get_sequence_count[] = "get_sequence_count";
static const char __pyx_k_get_sequence_names[] = "get_sequence_names";
static const char __pyx_k_get_version_number[] = "get_version_number";
static const char __pyx_k_name_from_internal[] = "name_from_internal";
static const char __pyx_k_get_base_type_names[] = "get_base_type_names";
static const char __pyx_k_get_defined_command[] = "get_defined_command";
static const char __pyx_k_get_table_row_count[] = "get_table_row_count";
static const char __pyx_k_get_table_row_names[] = "get_table_row_names";
static const char __pyx_k_Column_not_found_0_r[] = "Column not found: {0!r}";
static const char __pyx_k_Invalid_expression_r[] = "Invalid expression: {!r}";
static const char __pyx_k_get_expanded_element[] = "get_expanded_element";
static const char __pyx_k_is_sequence_expanded[] = "is_sequence_expanded";
static const char __pyx_k_normalize_range_name[] = "normalize_range_name";
static const char __pyx_k_No_beam_attached_to_r[] = "No beam attached to {!r}";
static const char __pyx_k_get_element_positions[] = "get_element_positions";
static const char __pyx_k_No_summary_for_table_r[] = "No summary for table: {!r}";
static const char __pyx_k_Unknown_parameter_type[] = "Unknown parameter type: {}";
static const char __pyx_k_Variable_not_defined_r[] = "Variable not defined: {!r}";
static const char __pyx_k_apply_table_selections[] = "apply_table_selections";
static const char __pyx_k_get_table_column_count[] = "get_table_column_count";
static const char __pyx_k_get_table_column_names[] = "get_table_column_names";
static const char __pyx_k_src_cpymad_libmadx_pyx[] = "src/cpymad/libmadx.pyx";
static const char __pyx_k_get_global_element_name[] = "get_global_element_name";
static const char __pyx_k_get_active_sequence_name[] = "get_active_sequence_name";
static const char __pyx_k_get_global_element_count[] = "get_global_element_count";
static const char __pyx_k_get_global_element_index[] = "get_global_element_index";
static const char __pyx_k_TWISS_table_invalid_for_r[] = "TWISS table invalid for {!r}";
static const char __pyx_k_get_defined_command_names[] = "get_defined_command_names";
static const char __pyx_k_get_expanded_element_name[] = "get_expanded_element_name";
static const char __pyx_k_Column_r_is_not_in_table_r[] = "Column {!r} is not in table {!r}.";
static const char __pyx_k_Element_name_not_found_0_r[] = "Element name not found: {0!r}";
static const char __pyx_k_get_expanded_element_count[] = "get_expanded_element_count";
static const char __pyx_k_get_expanded_element_index[] = "get_expanded_element_index";
static const char __pyx_k_get_expanded_element_names[] = "get_expanded_element_names";
static const char __pyx_k_get_table_column_count_all[] = "get_table_column_count_all";
static const char __pyx_k_get_table_column_names_all[] = "get_table_column_names_all";
static const char __pyx_k_get_element_index_by_position[] = "get_element_index_by_position";
static const char __pyx_k_get_sequence_twiss_table_name[] = "get_sequence_twiss_table_name";
static const char __pyx_k_No_element_found_at_position_0[] = "No element found at position: {0}";
static const char __pyx_k_Unknown_datatype_r_in_column_r[] = "Unknown datatype {!r} in column {!r}.";
static const char __pyx_k_get_expanded_element_positions[] = "get_expanded_element_positions";
static const char __pyx_k_Low_level_cython_binding_to_MAD[] = "\nLow level cython binding to MAD-X.\n\nCAUTION: Do not import this module directly! Use :class:`Madx` instead.\n\n- The API of this module is considered private, i.e. it may change between\n  versions without further notice.\n- Importing this module means loading MAD-X directly into the process space.\n  This means that any crash in the (sometimes fragile) MAD-X interpreter will\n  crash the importing process with it.\n- All functions in this module operate on a shared global state.\n- this module exposes a very C-ish API that is not convenient to work with.\n";
static const char __pyx_k_Column_index_out_of_range_0_colu[] = "Column index out of range: {0} (column count is {1})";
static const char __pyx_k_Empty_node_or_subsequence_Please[] = "Empty node or subsequence! Please report this incident!";
static const char __pyx_k_Index_out_of_range_0_element_cou[] = "Index out of range: {0} (element count is {1})";
static const char __pyx_k_get_expanded_element_index_by_po[] = "get_expanded_element_index_by_position";
static const char __pyx_k_get_table_row_locals_fetch_value[] = "get_table_row.<locals>.fetch_value";
static PyObject *__pyx_kp_u_;
static PyObject *__pyx_kp_u_Column_index_out_of_range_0_colu;
static PyObject *__pyx_kp_u_Column_not_found_0_r;
static PyObject *__pyx_kp_u_Column_r_is_not_in_table_r;
static PyObject *__pyx_n_s_Constraint;
static PyObject *__pyx_kp_u_Element_name_not_found_0_r;
static PyObject *__pyx_kp_u_Empty_node_or_subsequence_Please;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_kp_u_Index_out_of_range_0_element_cou;
static PyObject *__pyx_kp_u_Invalid_command_r;
static PyObject *__pyx_kp_u_Invalid_expression_r;
static PyObject *__pyx_kp_u_Invalid_row_index;
static PyObject *__pyx_kp_u_Invalid_sequence_r;
static PyObject *__pyx_kp_u_Invalid_table_r;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_kp_u_No_active_sequence;
static PyObject *__pyx_kp_u_No_beam_attached_to_r;
static PyObject *__pyx_kp_u_No_element_found_at_position_0;
static PyObject *__pyx_kp_u_No_summary_for_table_r;
static PyObject *__pyx_n_s_Parameter;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_n_b_S;
static PyObject *__pyx_kp_u_TWISS_table_invalid_for_r;
static PyObject *__pyx_kp_u_Unknown_datatype_r_in_column_r;
static PyObject *__pyx_kp_u_Unknown_parameter_type;
static PyObject *__pyx_n_b_V;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_u_Variable_not_defined_r;
static PyObject *__pyx_kp_b__13;
static PyObject *__pyx_kp_u__13;
static PyObject *__pyx_kp_u__3;
static PyObject *__pyx_kp_u__7;
static PyObject *__pyx_n_s_addr;
static PyObject *__pyx_n_u_all;
static PyObject *__pyx_n_s_all_2;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_apply_table_selections;
static PyObject *__pyx_n_u_apply_table_selections;
static PyObject *__pyx_n_s_array;
static PyObject *__pyx_n_s_array_data;
static PyObject *__pyx_n_s_array_type;
static PyObject *__pyx_n_s_as_array;
static PyObject *__pyx_n_s_at;
static PyObject *__pyx_n_u_at;
static PyObject *__pyx_n_u_base_name;
static PyObject *__pyx_n_u_base_type;
static PyObject *__pyx_n_s_c_double;
static PyObject *__pyx_n_s_char_tmp;
static PyObject *__pyx_n_s_chdir;
static PyObject *__pyx_n_u_chdir;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_cmd;
static PyObject *__pyx_n_s_cmd_2;
static PyObject *__pyx_n_s_col;
static PyObject *__pyx_n_s_col_index;
static PyObject *__pyx_n_s_col_name;
static PyObject *__pyx_n_s_column_name;
static PyObject *__pyx_n_s_columns;
static PyObject *__pyx_n_s_command_name;
static PyObject *__pyx_n_s_command_name_2;
static PyObject *__pyx_n_s_cpymad_libmadx;
static PyObject *__pyx_n_s_cpymad_types;
static PyObject *__pyx_n_s_cpymad_util;
static PyObject *__pyx_n_s_ctypes;
static PyObject *__pyx_n_s_ctypeslib;
static PyObject *__pyx_n_b_d;
static PyObject *__pyx_n_u_data;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_elem;
static PyObject *__pyx_n_s_element_index;
static PyObject *__pyx_n_s_element_name;
static PyObject *__pyx_n_s_element_name_2;
static PyObject *__pyx_n_s_elems;
static PyObject *__pyx_n_u_enable;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_endswith;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_n_s_eval;
static PyObject *__pyx_n_u_eval;
static PyObject *__pyx_n_s_expr;
static PyObject *__pyx_n_s_expr_types;
static PyObject *__pyx_n_s_expression;
static PyObject *__pyx_n_s_expression_vars;
static PyObject *__pyx_n_s_fetch_value;
static PyObject *__pyx_n_s_finish;
static PyObject *__pyx_n_u_finish;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_u_from;
static PyObject *__pyx_n_s_from_address;
static PyObject *__pyx_n_s_get_active_sequence_name;
static PyObject *__pyx_n_u_get_active_sequence_name;
static PyObject *__pyx_n_s_get_base_type_names;
static PyObject *__pyx_n_u_get_base_type_names;
static PyObject *__pyx_n_s_get_defined_command;
static PyObject *__pyx_n_u_get_defined_command;
static PyObject *__pyx_n_s_get_defined_command_names;
static PyObject *__pyx_n_u_get_defined_command_names;
static PyObject *__pyx_n_s_get_element;
static PyObject *__pyx_n_u_get_element;
static PyObject *__pyx_n_s_get_element_count;
static PyObject *__pyx_n_u_get_element_count;
static PyObject *__pyx_n_s_get_element_index;
static PyObject *__pyx_n_u_get_element_index;
static PyObject *__pyx_n_s_get_element_index_by_position;
static PyObject *__pyx_n_u_get_element_index_by_position;
static PyObject *__pyx_n_s_get_element_name;
static PyObject *__pyx_n_u_get_element_name;
static PyObject *__pyx_n_s_get_element_names;
static PyObject *__pyx_n_u_get_element_names;
static PyObject *__pyx_n_s_get_element_positions;
static PyObject *__pyx_n_u_get_element_positions;
static PyObject *__pyx_n_s_get_expanded_element;
static PyObject *__pyx_n_u_get_expanded_element;
static PyObject *__pyx_n_s_get_expanded_element_count;
static PyObject *__pyx_n_u_get_expanded_element_count;
static PyObject *__pyx_n_s_get_expanded_element_index;
static PyObject *__pyx_n_u_get_expanded_element_index;
static PyObject *__pyx_n_s_get_expanded_element_index_by_po;
static PyObject *__pyx_n_u_get_expanded_element_index_by_po;
static PyObject *__pyx_n_s_get_expanded_element_name;
static PyObject *__pyx_n_u_get_expanded_element_name;
static PyObject *__pyx_n_s_get_expanded_element_names;
static PyObject *__pyx_n_u_get_expanded_element_names;
static PyObject *__pyx_n_s_get_expanded_element_positions;
static PyObject *__pyx_n_u_get_expanded_element_positions;
static PyObject *__pyx_n_s_get_global_element;
static PyObject *__pyx_n_u_get_global_element;
static PyObject *__pyx_n_s_get_global_element_count;
static PyObject *__pyx_n_u_get_global_element_count;
static PyObject *__pyx_n_s_get_global_element_index;
static PyObject *__pyx_n_u_get_global_element_index;
static PyObject *__pyx_n_s_get_global_element_name;
static PyObject *__pyx_n_u_get_global_element_name;
static PyObject *__pyx_n_s_get_globals;
static PyObject *__pyx_n_u_get_globals;
static PyObject *__pyx_n_s_get_options;
static PyObject *__pyx_n_u_get_options;
static PyObject *__pyx_n_s_get_rightmost_word;
static PyObject *__pyx_n_s_get_sequence_beam;
static PyObject *__pyx_n_u_get_sequence_beam;
static PyObject *__pyx_n_s_get_sequence_count;
static PyObject *__pyx_n_u_get_sequence_count;
static PyObject *__pyx_n_s_get_sequence_names;
static PyObject *__pyx_n_u_get_sequence_names;
static PyObject *__pyx_n_s_get_sequence_twiss_table_name;
static PyObject *__pyx_n_u_get_sequence_twiss_table_name;
static PyObject *__pyx_n_s_get_table_column;
static PyObject *__pyx_n_u_get_table_column;
static PyObject *__pyx_n_s_get_table_column_count;
static PyObject *__pyx_n_u_get_table_column_count;
static PyObject *__pyx_n_s_get_table_column_count_all;
static PyObject *__pyx_n_u_get_table_column_count_all;
static PyObject *__pyx_n_s_get_table_column_names;
static PyObject *__pyx_n_u_get_table_column_names;
static PyObject *__pyx_n_s_get_table_column_names_all;
static PyObject *__pyx_n_u_get_table_column_names_all;
static PyObject *__pyx_n_s_get_table_count;
static PyObject *__pyx_n_u_get_table_count;
static PyObject *__pyx_n_s_get_table_names;
static PyObject *__pyx_n_u_get_table_names;
static PyObject *__pyx_n_s_get_table_row;
static PyObject *__pyx_n_u_get_table_row;
static PyObject *__pyx_n_s_get_table_row_count;
static PyObject *__pyx_n_u_get_table_row_count;
static PyObject *__pyx_n_s_get_table_row_locals_fetch_value;
static PyObject *__pyx_n_s_get_table_row_names;
static PyObject *__pyx_n_u_get_table_row_names;
static PyObject *__pyx_n_s_get_table_summary;
static PyObject *__pyx_n_u_get_table_summary;
static PyObject *__pyx_n_s_get_var;
static PyObject *__pyx_n_u_get_var;
static PyObject *__pyx_n_s_get_var_type;
static PyObject *__pyx_n_u_get_var_type;
static PyObject *__pyx_n_s_get_version_date;
static PyObject *__pyx_n_u_get_version_date;
static PyObject *__pyx_n_s_get_version_number;
static PyObject *__pyx_n_u_get_version_number;
static PyObject *__pyx_n_s_getcwd;
static PyObject *__pyx_n_u_getcwd;
static PyObject *__pyx_n_s_header;
static PyObject *__pyx_n_b_i;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_idx;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_indices;
static PyObject *__pyx_n_s_info;
static PyObject *__pyx_n_s_inform;
static PyObject *__pyx_n_s_input;
static PyObject *__pyx_n_u_input;
static PyObject *__pyx_n_s_is_sequence_expanded;
static PyObject *__pyx_n_u_is_sequence_expanded;
static PyObject *__pyx_n_s_is_started;
static PyObject *__pyx_n_u_is_started;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_kp_u_le;
static PyObject *__pyx_n_u_length;
static PyObject *__pyx_n_s_lower;
static PyObject *__pyx_n_s_madx_started;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_map;
static PyObject *__pyx_n_s_max;
static PyObject *__pyx_n_s_min;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_u_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_name_from_internal;
static PyObject *__pyx_n_s_name_to_internal;
static PyObject *__pyx_n_u_node_name;
static PyObject *__pyx_n_s_nodes;
static PyObject *__pyx_n_s_normalize_range_name;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_num_globals;
static PyObject *__pyx_n_u_num_globals;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_u_occ_cnt;
static PyObject *__pyx_n_s_os;
static PyObject *__pyx_n_u_parent;
static PyObject *__pyx_n_s_pch;
static PyObject *__pyx_n_s_position;
static PyObject *__pyx_n_u_position;
static PyObject *__pyx_n_s_position_2;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_row_index;
static PyObject *__pyx_n_s_rsplit;
static PyObject *__pyx_n_s_rstrip;
static PyObject *__pyx_n_u_s;
static PyObject *__pyx_n_u_selected;
static PyObject *__pyx_n_s_sentence;
static PyObject *__pyx_n_s_seq;
static PyObject *__pyx_n_s_seqs;
static PyObject *__pyx_n_s_sequence_exists;
static PyObject *__pyx_n_u_sequence_exists;
static PyObject *__pyx_n_s_sequence_name;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_kp_s_src_cpymad_libmadx_pyx;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_u_start;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_s_t;
static PyObject *__pyx_n_s_tab_name;
static PyObject *__pyx_n_s_table;
static PyObject *__pyx_n_s_table_exists;
static PyObject *__pyx_n_u_table_exists;
static PyObject *__pyx_n_s_table_name;
static PyObject *__pyx_n_s_table_name_2;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_typeid;
static PyObject *__pyx_kp_u_utf_8;
static PyObject *__pyx_n_s_val;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_var;
static PyObject *__pyx_n_s_var_type;
static PyObject *__pyx_n_s_vars;
static PyObject *__pyx_n_s_version_info;
static PyObject *__pyx_pf_6cpymad_7libmadx__get_rightmost_word(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sentence); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_2get_version_number(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_4get_version_date(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_6is_started(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_8start(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_10finish(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_12input(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cmd); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_14get_var(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_16get_var_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_18get_options(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_20num_globals(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_22get_globals(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_24sequence_exists(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_26get_sequence_twiss_table_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_28get_sequence_beam(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_30get_active_sequence_name(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_32get_sequence_names(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_34get_sequence_count(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_36table_exists(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_38get_table_names(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_40get_table_count(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_42get_table_summary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_44get_table_column_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_46get_table_column_names_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_48get_table_column_count(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_50get_table_column_count_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_52get_table_column(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name, PyObject *__pyx_v_column_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_13get_table_row_fetch_value(PyObject *__pyx_self, PyObject *__pyx_v_col_index); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_54get_table_row(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name, PyObject *__pyx_v_row_index, PyObject *__pyx_v_columns); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_56get_table_row_count(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_58get_table_row_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name, PyObject *__pyx_v_indices); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_60apply_table_selections(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_62get_element(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_index); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_64get_element_positions(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_66get_element_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_68get_element_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_index); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_70get_element_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_72get_element_index_by_position(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_position); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_74get_element_count(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_76get_expanded_element(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_index); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_78get_expanded_element_positions(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_80get_expanded_element_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_82get_expanded_element_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_index); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_84get_expanded_element_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_86get_expanded_element_index_by_position(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_position); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_88get_expanded_element_count(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_90get_global_element(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_element_index); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_92get_global_element_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_element_index); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_94get_global_element_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_element_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_96get_global_element_count(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_98get_base_type_names(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_100get_defined_command(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_command_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_102get_defined_command_names(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_104is_sequence_expanded(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_106eval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_expression); /* proto */
static PyObject *__pyx_pf_6cpymad_7libmadx_108expression_vars(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_expression); /* proto */
static PyObject *__pyx_tp_new_6cpymad_7libmadx___pyx_scope_struct__get_table_row(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_5;
static PyObject *__pyx_int_7;
static PyObject *__pyx_int_100000000;
static PyObject *__pyx_int_neg_1;
static int __pyx_k__9;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_slice__12;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_codeobj__6;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_codeobj__17;
static PyObject *__pyx_codeobj__18;
static PyObject *__pyx_codeobj__19;
static PyObject *__pyx_codeobj__20;
static PyObject *__pyx_codeobj__21;
static PyObject *__pyx_codeobj__22;
static PyObject *__pyx_codeobj__24;
static PyObject *__pyx_codeobj__26;
static PyObject *__pyx_codeobj__28;
static PyObject *__pyx_codeobj__29;
static PyObject *__pyx_codeobj__30;
static PyObject *__pyx_codeobj__31;
static PyObject *__pyx_codeobj__33;
static PyObject *__pyx_codeobj__35;
static PyObject *__pyx_codeobj__37;
static PyObject *__pyx_codeobj__38;
static PyObject *__pyx_codeobj__40;
static PyObject *__pyx_codeobj__41;
static PyObject *__pyx_codeobj__43;
static PyObject *__pyx_codeobj__45;
static PyObject *__pyx_codeobj__46;
static PyObject *__pyx_codeobj__48;
static PyObject *__pyx_codeobj__50;
static PyObject *__pyx_codeobj__52;
static PyObject *__pyx_codeobj__54;
static PyObject *__pyx_codeobj__56;
static PyObject *__pyx_codeobj__58;
static PyObject *__pyx_codeobj__60;
static PyObject *__pyx_codeobj__62;
static PyObject *__pyx_codeobj__64;
static PyObject *__pyx_codeobj__66;
static PyObject *__pyx_codeobj__68;
static PyObject *__pyx_codeobj__70;
static PyObject *__pyx_codeobj__72;
static PyObject *__pyx_codeobj__74;
static PyObject *__pyx_codeobj__76;
static PyObject *__pyx_codeobj__78;
static PyObject *__pyx_codeobj__80;
static PyObject *__pyx_codeobj__82;
static PyObject *__pyx_codeobj__84;
static PyObject *__pyx_codeobj__86;
static PyObject *__pyx_codeobj__88;
static PyObject *__pyx_codeobj__90;
static PyObject *__pyx_codeobj__92;
static PyObject *__pyx_codeobj__94;
static PyObject *__pyx_codeobj__96;
static PyObject *__pyx_codeobj__98;
static PyObject *__pyx_codeobj__100;
static PyObject *__pyx_codeobj__101;
static PyObject *__pyx_codeobj__102;
static PyObject *__pyx_codeobj__104;
static PyObject *__pyx_codeobj__105;
static PyObject *__pyx_codeobj__107;
static PyObject *__pyx_codeobj__109;
static PyObject *__pyx_codeobj__111;
/* Late includes */

/* "cpymad/libmadx.pyx":128
 * 
 * 
 * def _get_rightmost_word(sentence):             # <<<<<<<<<<<<<<
 *     """Get the work right of the rightmost space character."""
 *     return sentence.rsplit(' ', 1)[-1]
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_1_get_rightmost_word(PyObject *__pyx_self, PyObject *__pyx_v_sentence); /*proto*/
static char __pyx_doc_6cpymad_7libmadx__get_rightmost_word[] = "_get_rightmost_word(sentence)\nGet the work right of the rightmost space character.";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_1_get_rightmost_word = {"_get_rightmost_word", (PyCFunction)__pyx_pw_6cpymad_7libmadx_1_get_rightmost_word, METH_O, __pyx_doc_6cpymad_7libmadx__get_rightmost_word};
static PyObject *__pyx_pw_6cpymad_7libmadx_1_get_rightmost_word(PyObject *__pyx_self, PyObject *__pyx_v_sentence) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_rightmost_word (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx__get_rightmost_word(__pyx_self, ((PyObject *)__pyx_v_sentence));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx__get_rightmost_word(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sentence) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_get_rightmost_word", 0);

  /* "cpymad/libmadx.pyx":130
 * def _get_rightmost_word(sentence):
 *     """Get the work right of the rightmost space character."""
 *     return sentence.rsplit(' ', 1)[-1]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sentence, __pyx_n_s_rsplit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":128
 * 
 * 
 * def _get_rightmost_word(sentence):             # <<<<<<<<<<<<<<
 *     """Get the work right of the rightmost space character."""
 *     return sentence.rsplit(' ', 1)[-1]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx._get_rightmost_word", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":133
 * 
 * 
 * def get_version_number():             # <<<<<<<<<<<<<<
 *     """
 *     Get the version number of loaded MAD-X interpreter.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_3get_version_number(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_2get_version_number[] = "get_version_number()\n\n    Get the version number of loaded MAD-X interpreter.\n\n    :returns: full version number\n    :rtype: str\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_3get_version_number = {"get_version_number", (PyCFunction)__pyx_pw_6cpymad_7libmadx_3get_version_number, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_2get_version_number};
static PyObject *__pyx_pw_6cpymad_7libmadx_3get_version_number(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_version_number (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_2get_version_number(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_2get_version_number(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("get_version_number", 0);

  /* "cpymad/libmadx.pyx":140
 *     :rtype: str
 *     """
 *     return _get_rightmost_word(_str(clib.version_name))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_rightmost_word); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__str(version_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":133
 * 
 * 
 * def get_version_number():             # <<<<<<<<<<<<<<
 *     """
 *     Get the version number of loaded MAD-X interpreter.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpymad.libmadx.get_version_number", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":143
 * 
 * 
 * def get_version_date():             # <<<<<<<<<<<<<<
 *     """
 *     Get the release date of loaded MAD-X interpreter.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_5get_version_date(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_4get_version_date[] = "get_version_date()\n\n    Get the release date of loaded MAD-X interpreter.\n\n    :returns: release date in YYYY.MM.DD format\n    :rtype: str\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_5get_version_date = {"get_version_date", (PyCFunction)__pyx_pw_6cpymad_7libmadx_5get_version_date, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_4get_version_date};
static PyObject *__pyx_pw_6cpymad_7libmadx_5get_version_date(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_version_date (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_4get_version_date(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_4get_version_date(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("get_version_date", 0);

  /* "cpymad/libmadx.pyx":150
 *     :rtype: str
 *     """
 *     return _get_rightmost_word(_str(clib.version_date))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_rightmost_word); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__str(version_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":143
 * 
 * 
 * def get_version_date():             # <<<<<<<<<<<<<<
 *     """
 *     Get the release date of loaded MAD-X interpreter.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpymad.libmadx.get_version_date", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":153
 * 
 * 
 * def is_started():             # <<<<<<<<<<<<<<
 *     """
 *     Check whether MAD-X has been initialized.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_7is_started(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_6is_started[] = "is_started()\n\n    Check whether MAD-X has been initialized.\n\n    :returns: whether :func:`start` was called without matching :func:`finish`\n    :rtype: bool\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_7is_started = {"is_started", (PyCFunction)__pyx_pw_6cpymad_7libmadx_7is_started, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_6is_started};
static PyObject *__pyx_pw_6cpymad_7libmadx_7is_started(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_started (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_6is_started(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_6is_started(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("is_started", 0);

  /* "cpymad/libmadx.pyx":160
 *     :rtype: bool
 *     """
 *     return _madx_started             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_madx_started); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":153
 * 
 * 
 * def is_started():             # <<<<<<<<<<<<<<
 *     """
 *     Check whether MAD-X has been initialized.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.is_started", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":163
 * 
 * 
 * def start():             # <<<<<<<<<<<<<<
 *     """
 *     Initialize MAD-X.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_9start(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_8start[] = "start()\n\n    Initialize MAD-X.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_9start = {"start", (PyCFunction)__pyx_pw_6cpymad_7libmadx_9start, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_8start};
static PyObject *__pyx_pw_6cpymad_7libmadx_9start(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_8start(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_8start(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start", 0);

  /* "cpymad/libmadx.pyx":167
 *     Initialize MAD-X.
 *     """
 *     clib.madx_start()             # <<<<<<<<<<<<<<
 *     global _madx_started
 *     _madx_started = True
 */
  madx_start();

  /* "cpymad/libmadx.pyx":169
 *     clib.madx_start()
 *     global _madx_started
 *     _madx_started = True             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_madx_started, Py_True) < 0) __PYX_ERR(0, 169, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":163
 * 
 * 
 * def start():             # <<<<<<<<<<<<<<
 *     """
 *     Initialize MAD-X.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpymad.libmadx.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":172
 * 
 * 
 * def finish():             # <<<<<<<<<<<<<<
 *     """
 *     Cleanup MAD-X.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_11finish(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_10finish[] = "finish()\n\n    Cleanup MAD-X.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_11finish = {"finish", (PyCFunction)__pyx_pw_6cpymad_7libmadx_11finish, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_10finish};
static PyObject *__pyx_pw_6cpymad_7libmadx_11finish(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("finish (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_10finish(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_10finish(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("finish", 0);

  /* "cpymad/libmadx.pyx":176
 *     Cleanup MAD-X.
 *     """
 *     clib.madx_finish()             # <<<<<<<<<<<<<<
 *     global _madx_started
 *     _madx_started = False
 */
  madx_finish();

  /* "cpymad/libmadx.pyx":178
 *     clib.madx_finish()
 *     global _madx_started
 *     _madx_started = False             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_madx_started, Py_False) < 0) __PYX_ERR(0, 178, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":172
 * 
 * 
 * def finish():             # <<<<<<<<<<<<<<
 *     """
 *     Cleanup MAD-X.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpymad.libmadx.finish", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":181
 * 
 * 
 * def input(cmd):             # <<<<<<<<<<<<<<
 *     """
 *     Pass one input command to MAD-X.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_13input(PyObject *__pyx_self, PyObject *__pyx_v_cmd); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_12input[] = "input(cmd)\n\n    Pass one input command to MAD-X.\n\n    :param str cmd: command to be executed by the MAD-X interpreter\n    :returns: success status, whether the command has completed without error\n    :rtype: bool\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_13input = {"input", (PyCFunction)__pyx_pw_6cpymad_7libmadx_13input, METH_O, __pyx_doc_6cpymad_7libmadx_12input};
static PyObject *__pyx_pw_6cpymad_7libmadx_13input(PyObject *__pyx_self, PyObject *__pyx_v_cmd) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("input (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_12input(__pyx_self, ((PyObject *)__pyx_v_cmd));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_12input(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cmd) {
  PyObject *__pyx_v__cmd = 0;
  char *__pyx_v__pch;
  int __pyx_v_error;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  char *__pyx_t_5;
  __Pyx_RefNannySetupContext("input", 0);
  __Pyx_INCREF(__pyx_v_cmd);

  /* "cpymad/libmadx.pyx":189
 *     :rtype: bool
 *     """
 *     cmd = cmd.rstrip().rstrip(';') + ';'             # <<<<<<<<<<<<<<
 *     cdef bytes _cmd = _cstr(cmd)
 *     cdef char* _pch = _cmd
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_cmd, __pyx_n_s_rstrip); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_rstrip); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_u__3) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u__3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_kp_u__3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_cmd, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpymad/libmadx.pyx":190
 *     """
 *     cmd = cmd.rstrip().rstrip(';') + ';'
 *     cdef bytes _cmd = _cstr(cmd)             # <<<<<<<<<<<<<<
 *     cdef char* _pch = _cmd
 *     cdef int error = 0
 */
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_cmd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__cmd = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpymad/libmadx.pyx":191
 *     cmd = cmd.rstrip().rstrip(';') + ';'
 *     cdef bytes _cmd = _cstr(cmd)
 *     cdef char* _pch = _cmd             # <<<<<<<<<<<<<<
 *     cdef int error = 0
 *     with nogil:
 */
  if (unlikely(__pyx_v__cmd == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 191, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyBytes_AsWritableString(__pyx_v__cmd); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L1_error)
  __pyx_v__pch = __pyx_t_5;

  /* "cpymad/libmadx.pyx":192
 *     cdef bytes _cmd = _cstr(cmd)
 *     cdef char* _pch = _cmd
 *     cdef int error = 0             # <<<<<<<<<<<<<<
 *     with nogil:
 *         _strip_comments(_pch)
 */
  __pyx_v_error = 0;

  /* "cpymad/libmadx.pyx":193
 *     cdef char* _pch = _cmd
 *     cdef int error = 0
 *     with nogil:             # <<<<<<<<<<<<<<
 *         _strip_comments(_pch)
 *         clib.supp_lt(_pch, 0)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cpymad/libmadx.pyx":194
 *     cdef int error = 0
 *     with nogil:
 *         _strip_comments(_pch)             # <<<<<<<<<<<<<<
 *         clib.supp_lt(_pch, 0)
 *         clib.stolower_nq(_pch)
 */
        __pyx_f_6cpymad_7libmadx__strip_comments(__pyx_v__pch);

        /* "cpymad/libmadx.pyx":195
 *     with nogil:
 *         _strip_comments(_pch)
 *         clib.supp_lt(_pch, 0)             # <<<<<<<<<<<<<<
 *         clib.stolower_nq(_pch)
 *         clib.pro_input(_pch)
 */
        (void)(supp_lt(__pyx_v__pch, 0));

        /* "cpymad/libmadx.pyx":196
 *         _strip_comments(_pch)
 *         clib.supp_lt(_pch, 0)
 *         clib.stolower_nq(_pch)             # <<<<<<<<<<<<<<
 *         clib.pro_input(_pch)
 *         error = clib.geterrorflag()
 */
        stolower_nq(__pyx_v__pch);

        /* "cpymad/libmadx.pyx":197
 *         clib.supp_lt(_pch, 0)
 *         clib.stolower_nq(_pch)
 *         clib.pro_input(_pch)             # <<<<<<<<<<<<<<
 *         error = clib.geterrorflag()
 *         clib.clearerrorflag()
 */
        pro_input(__pyx_v__pch);

        /* "cpymad/libmadx.pyx":198
 *         clib.stolower_nq(_pch)
 *         clib.pro_input(_pch)
 *         error = clib.geterrorflag()             # <<<<<<<<<<<<<<
 *         clib.clearerrorflag()
 *     return not error
 */
        __pyx_v_error = geterrorflag();

        /* "cpymad/libmadx.pyx":199
 *         clib.pro_input(_pch)
 *         error = clib.geterrorflag()
 *         clib.clearerrorflag()             # <<<<<<<<<<<<<<
 *     return not error
 * 
 */
        clearerrorflag();
      }

      /* "cpymad/libmadx.pyx":193
 *     cdef char* _pch = _cmd
 *     cdef int error = 0
 *     with nogil:             # <<<<<<<<<<<<<<
 *         _strip_comments(_pch)
 *         clib.supp_lt(_pch, 0)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cpymad/libmadx.pyx":200
 *         error = clib.geterrorflag()
 *         clib.clearerrorflag()
 *     return not error             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyBool_FromLong((!(__pyx_v_error != 0))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":181
 * 
 * 
 * def input(cmd):             # <<<<<<<<<<<<<<
 *     """
 *     Pass one input command to MAD-X.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpymad.libmadx.input", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__cmd);
  __Pyx_XDECREF(__pyx_v_cmd);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":203
 * 
 * 
 * def get_var(name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the value of a global variable.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_15get_var(PyObject *__pyx_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_14get_var[] = "get_var(name)\n\n    Get the value of a global variable.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_15get_var = {"get_var", (PyCFunction)__pyx_pw_6cpymad_7libmadx_15get_var, METH_O, __pyx_doc_6cpymad_7libmadx_14get_var};
static PyObject *__pyx_pw_6cpymad_7libmadx_15get_var(PyObject *__pyx_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_var (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_14get_var(__pyx_self, ((PyObject *)__pyx_v_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_14get_var(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name) {
  struct variable *__pyx_v_var;
  int __pyx_v_index;
  int __pyx_v_inform;
  double __pyx_v_value;
  int __pyx_v_typeid;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct variable *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_opt_args_6cpymad_7libmadx__expr __pyx_t_7;
  __Pyx_RefNannySetupContext("get_var", 0);

  /* "cpymad/libmadx.pyx":207
 *     Get the value of a global variable.
 *     """
 *     cdef clib.variable* var = _get_var(name)             # <<<<<<<<<<<<<<
 *     cdef int index = clib.name_list_pos(var.name, clib.variable_list.list)
 *     cdef int inform = index >= clib.start_var
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__get_var(__pyx_v_name); if (unlikely(__pyx_t_1 == ((struct variable *)NULL))) __PYX_ERR(0, 207, __pyx_L1_error)
  __pyx_v_var = __pyx_t_1;

  /* "cpymad/libmadx.pyx":208
 *     """
 *     cdef clib.variable* var = _get_var(name)
 *     cdef int index = clib.name_list_pos(var.name, clib.variable_list.list)             # <<<<<<<<<<<<<<
 *     cdef int inform = index >= clib.start_var
 *     if var.type == clib.VAR_TYPE_STRING:
 */
  __pyx_v_index = name_list_pos(__pyx_v_var->name, variable_list->list);

  /* "cpymad/libmadx.pyx":209
 *     cdef clib.variable* var = _get_var(name)
 *     cdef int index = clib.name_list_pos(var.name, clib.variable_list.list)
 *     cdef int inform = index >= clib.start_var             # <<<<<<<<<<<<<<
 *     if var.type == clib.VAR_TYPE_STRING:
 *         return Parameter(
 */
  __pyx_v_inform = (__pyx_v_index >= start_var);

  /* "cpymad/libmadx.pyx":210
 *     cdef int index = clib.name_list_pos(var.name, clib.variable_list.list)
 *     cdef int inform = index >= clib.start_var
 *     if var.type == clib.VAR_TYPE_STRING:             # <<<<<<<<<<<<<<
 *         return Parameter(
 *             name, _str(var.string), None,
 */
  __pyx_t_2 = ((__pyx_v_var->type == __pyx_e_6cpymad_8clibmadx_VAR_TYPE_STRING) != 0);
  if (__pyx_t_2) {

    /* "cpymad/libmadx.pyx":211
 *     cdef int inform = index >= clib.start_var
 *     if var.type == clib.VAR_TYPE_STRING:
 *         return Parameter(             # <<<<<<<<<<<<<<
 *             name, _str(var.string), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=inform, var_type=var.type)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Parameter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cpymad/libmadx.pyx":212
 *     if var.type == clib.VAR_TYPE_STRING:
 *         return Parameter(
 *             name, _str(var.string), None,             # <<<<<<<<<<<<<<
 *             dtype=clib.PARAM_TYPE_STRING, inform=inform, var_type=var.type)
 *     cdef double value = clib.variable_value(var)
 */
    __pyx_t_4 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_var->string); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "cpymad/libmadx.pyx":211
 *     cdef int inform = index >= clib.start_var
 *     if var.type == clib.VAR_TYPE_STRING:
 *         return Parameter(             # <<<<<<<<<<<<<<
 *             name, _str(var.string), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=inform, var_type=var.type)
 */
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_name);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_5, 2, Py_None);
    __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":213
 *         return Parameter(
 *             name, _str(var.string), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=inform, var_type=var.type)             # <<<<<<<<<<<<<<
 *     cdef double value = clib.variable_value(var)
 *     cdef int typeid
 */
    __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_e_6cpymad_8clibmadx_PARAM_TYPE_STRING); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 213, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_inform); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_inform, __pyx_t_6) < 0) __PYX_ERR(0, 213, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_var->type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_var_type, __pyx_t_6) < 0) __PYX_ERR(0, 213, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cpymad/libmadx.pyx":211
 *     cdef int inform = index >= clib.start_var
 *     if var.type == clib.VAR_TYPE_STRING:
 *         return Parameter(             # <<<<<<<<<<<<<<
 *             name, _str(var.string), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=inform, var_type=var.type)
 */
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":210
 *     cdef int index = clib.name_list_pos(var.name, clib.variable_list.list)
 *     cdef int inform = index >= clib.start_var
 *     if var.type == clib.VAR_TYPE_STRING:             # <<<<<<<<<<<<<<
 *         return Parameter(
 *             name, _str(var.string), None,
 */
  }

  /* "cpymad/libmadx.pyx":214
 *             name, _str(var.string), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=inform, var_type=var.type)
 *     cdef double value = clib.variable_value(var)             # <<<<<<<<<<<<<<
 *     cdef int typeid
 *     if var.val_type == clib.VAL_TYPE_INTEGER:
 */
  __pyx_v_value = variable_value(__pyx_v_var);

  /* "cpymad/libmadx.pyx":216
 *     cdef double value = clib.variable_value(var)
 *     cdef int typeid
 *     if var.val_type == clib.VAL_TYPE_INTEGER:             # <<<<<<<<<<<<<<
 *         typeid = clib.PARAM_TYPE_INTEGER
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_var->val_type == __pyx_e_6cpymad_8clibmadx_VAL_TYPE_INTEGER) != 0);
  if (__pyx_t_2) {

    /* "cpymad/libmadx.pyx":217
 *     cdef int typeid
 *     if var.val_type == clib.VAL_TYPE_INTEGER:
 *         typeid = clib.PARAM_TYPE_INTEGER             # <<<<<<<<<<<<<<
 *     else:
 *         typeid = clib.PARAM_TYPE_DOUBLE
 */
    __pyx_v_typeid = __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_INTEGER;

    /* "cpymad/libmadx.pyx":216
 *     cdef double value = clib.variable_value(var)
 *     cdef int typeid
 *     if var.val_type == clib.VAL_TYPE_INTEGER:             # <<<<<<<<<<<<<<
 *         typeid = clib.PARAM_TYPE_INTEGER
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cpymad/libmadx.pyx":219
 *         typeid = clib.PARAM_TYPE_INTEGER
 *     else:
 *         typeid = clib.PARAM_TYPE_DOUBLE             # <<<<<<<<<<<<<<
 *     return Parameter(
 *         name, *_expr(var.expr, value, typeid),
 */
  /*else*/ {
    __pyx_v_typeid = __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_DOUBLE;
  }
  __pyx_L4:;

  /* "cpymad/libmadx.pyx":220
 *     else:
 *         typeid = clib.PARAM_TYPE_DOUBLE
 *     return Parameter(             # <<<<<<<<<<<<<<
 *         name, *_expr(var.expr, value, typeid),
 *         dtype=typeid, inform=inform, var_type=var.type)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Parameter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "cpymad/libmadx.pyx":221
 *         typeid = clib.PARAM_TYPE_DOUBLE
 *     return Parameter(
 *         name, *_expr(var.expr, value, typeid),             # <<<<<<<<<<<<<<
 *         dtype=typeid, inform=inform, var_type=var.type)
 * 
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_name);
  __pyx_t_7.__pyx_n = 1;
  __pyx_t_7.typeid = __pyx_v_typeid;
  __pyx_t_5 = __pyx_f_6cpymad_7libmadx__expr(__pyx_v_var->expr, __pyx_v_value, &__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cpymad/libmadx.pyx":220
 *     else:
 *         typeid = clib.PARAM_TYPE_DOUBLE
 *     return Parameter(             # <<<<<<<<<<<<<<
 *         name, *_expr(var.expr, value, typeid),
 *         dtype=typeid, inform=inform, var_type=var.type)
 */
  __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cpymad/libmadx.pyx":222
 *     return Parameter(
 *         name, *_expr(var.expr, value, typeid),
 *         dtype=typeid, inform=inform, var_type=var.type)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_typeid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_inform); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_inform, __pyx_t_4) < 0) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_var->type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_var_type, __pyx_t_4) < 0) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cpymad/libmadx.pyx":220
 *     else:
 *         typeid = clib.PARAM_TYPE_DOUBLE
 *     return Parameter(             # <<<<<<<<<<<<<<
 *         name, *_expr(var.expr, value, typeid),
 *         dtype=typeid, inform=inform, var_type=var.type)
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":203
 * 
 * 
 * def get_var(name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the value of a global variable.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpymad.libmadx.get_var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":225
 * 
 * 
 * def get_var_type(name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the type of the variable:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_17get_var_type(PyObject *__pyx_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_16get_var_type[] = "get_var_type(name)\n\n    Get the type of the variable:\n\n        0   constant\n        1   direct\n        2   deferred\n        3   string\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_17get_var_type = {"get_var_type", (PyCFunction)__pyx_pw_6cpymad_7libmadx_17get_var_type, METH_O, __pyx_doc_6cpymad_7libmadx_16get_var_type};
static PyObject *__pyx_pw_6cpymad_7libmadx_17get_var_type(PyObject *__pyx_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_var_type (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_16get_var_type(__pyx_self, ((PyObject *)__pyx_v_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_16get_var_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct variable *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_var_type", 0);

  /* "cpymad/libmadx.pyx":234
 *         3   string
 *     """
 *     return _get_var(name).type             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__get_var(__pyx_v_name); if (unlikely(__pyx_t_1 == ((struct variable *)NULL))) __PYX_ERR(0, 234, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1->type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":225
 * 
 * 
 * def get_var_type(name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the type of the variable:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.get_var_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":237
 * 
 * 
 * def get_options():             # <<<<<<<<<<<<<<
 *     """Get the current option values."""
 *     return _parse_command(clib.options)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_19get_options(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_18get_options[] = "get_options()\nGet the current option values.";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_19get_options = {"get_options", (PyCFunction)__pyx_pw_6cpymad_7libmadx_19get_options, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_18get_options};
static PyObject *__pyx_pw_6cpymad_7libmadx_19get_options(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_options (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_18get_options(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_18get_options(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_options", 0);

  /* "cpymad/libmadx.pyx":239
 * def get_options():
 *     """Get the current option values."""
 *     return _parse_command(clib.options)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__parse_command(options); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":237
 * 
 * 
 * def get_options():             # <<<<<<<<<<<<<<
 *     """Get the current option values."""
 *     return _parse_command(clib.options)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.get_options", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":242
 * 
 * 
 * def num_globals():             # <<<<<<<<<<<<<<
 *     """
 *     Return the number of global variables.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_21num_globals(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_20num_globals[] = "num_globals()\n\n    Return the number of global variables.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_21num_globals = {"num_globals", (PyCFunction)__pyx_pw_6cpymad_7libmadx_21num_globals, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_20num_globals};
static PyObject *__pyx_pw_6cpymad_7libmadx_21num_globals(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("num_globals (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_20num_globals(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_20num_globals(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("num_globals", 0);

  /* "cpymad/libmadx.pyx":246
 *     Return the number of global variables.
 *     """
 *     return clib.variable_list.curr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(variable_list->curr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":242
 * 
 * 
 * def num_globals():             # <<<<<<<<<<<<<<
 *     """
 *     Return the number of global variables.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.num_globals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":249
 * 
 * 
 * def get_globals():             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of names of all global variables.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_23get_globals(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_22get_globals[] = "get_globals()\n\n    Get a list of names of all global variables.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_23get_globals = {"get_globals", (PyCFunction)__pyx_pw_6cpymad_7libmadx_23get_globals, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_22get_globals};
static PyObject *__pyx_pw_6cpymad_7libmadx_23get_globals(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_globals (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_22get_globals(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_22get_globals(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_globals", 0);

  /* "cpymad/libmadx.pyx":253
 *     Get a list of names of all global variables.
 *     """
 *     return _name_list(clib.variable_list.list)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__name_list(variable_list->list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":249
 * 
 * 
 * def get_globals():             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of names of all global variables.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.get_globals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":256
 * 
 * 
 * def sequence_exists(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check if the sequence exists.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_25sequence_exists(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_24sequence_exists[] = "sequence_exists(sequence_name)\n\n    Check if the sequence exists.\n\n    :param str sequence: sequence name\n    :returns: True if the sequence exists\n    :rtype: bool\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_25sequence_exists = {"sequence_exists", (PyCFunction)__pyx_pw_6cpymad_7libmadx_25sequence_exists, METH_O, __pyx_doc_6cpymad_7libmadx_24sequence_exists};
static PyObject *__pyx_pw_6cpymad_7libmadx_25sequence_exists(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sequence_exists (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_24sequence_exists(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_24sequence_exists(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  struct sequence *__pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("sequence_exists", 0);

  /* "cpymad/libmadx.pyx":264
 *     :rtype: bool
 *     """
 *     try:             # <<<<<<<<<<<<<<
 *         _find_sequence(sequence_name)
 *         return True
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "cpymad/libmadx.pyx":265
 *     """
 *     try:
 *         _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *         return True
 *     except ValueError:
 */
      __pyx_t_4 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_4 == ((struct sequence *)NULL))) __PYX_ERR(0, 265, __pyx_L3_error)

      /* "cpymad/libmadx.pyx":266
 *     try:
 *         _find_sequence(sequence_name)
 *         return True             # <<<<<<<<<<<<<<
 *     except ValueError:
 *         return False
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L7_try_return;

      /* "cpymad/libmadx.pyx":264
 *     :rtype: bool
 *     """
 *     try:             # <<<<<<<<<<<<<<
 *         _find_sequence(sequence_name)
 *         return True
 */
    }
    __pyx_L3_error:;

    /* "cpymad/libmadx.pyx":267
 *         _find_sequence(sequence_name)
 *         return True
 *     except ValueError:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("cpymad.libmadx.sequence_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 267, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "cpymad/libmadx.pyx":268
 *         return True
 *     except ValueError:
 *         return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "cpymad/libmadx.pyx":264
 *     :rtype: bool
 *     """
 *     try:             # <<<<<<<<<<<<<<
 *         _find_sequence(sequence_name)
 *         return True
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "cpymad/libmadx.pyx":256
 * 
 * 
 * def sequence_exists(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check if the sequence exists.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpymad.libmadx.sequence_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":271
 * 
 * 
 * def get_sequence_twiss_table_name(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the last calculated twiss table for the given sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_27get_sequence_twiss_table_name(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_26get_sequence_twiss_table_name[] = "get_sequence_twiss_table_name(sequence_name)\n\n    Get the last calculated twiss table for the given sequence.\n\n    :param str sequence_name: sequence name\n    :returns: twiss table name\n    :rtype: str\n    :raises ValueError: if the sequence name is invalid\n    :raises RuntimeError: if the twiss table is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_27get_sequence_twiss_table_name = {"get_sequence_twiss_table_name", (PyCFunction)__pyx_pw_6cpymad_7libmadx_27get_sequence_twiss_table_name, METH_O, __pyx_doc_6cpymad_7libmadx_26get_sequence_twiss_table_name};
static PyObject *__pyx_pw_6cpymad_7libmadx_27get_sequence_twiss_table_name(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_sequence_twiss_table_name (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_26get_sequence_twiss_table_name(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_26get_sequence_twiss_table_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("get_sequence_twiss_table_name", 0);

  /* "cpymad/libmadx.pyx":281
 *     :raises RuntimeError: if the twiss table is invalid
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     if not seq.tw_valid:
 *         raise RuntimeError("TWISS table invalid for {!r}".format(sequence_name))
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 281, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":282
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if not seq.tw_valid:             # <<<<<<<<<<<<<<
 *         raise RuntimeError("TWISS table invalid for {!r}".format(sequence_name))
 *     return _str(seq.tw_table.name)
 */
  __pyx_t_2 = ((!(__pyx_v_seq->tw_valid != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "cpymad/libmadx.pyx":283
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if not seq.tw_valid:
 *         raise RuntimeError("TWISS table invalid for {!r}".format(sequence_name))             # <<<<<<<<<<<<<<
 *     return _str(seq.tw_table.name)
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_TWISS_table_invalid_for_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_sequence_name) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_sequence_name);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 283, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":282
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if not seq.tw_valid:             # <<<<<<<<<<<<<<
 *         raise RuntimeError("TWISS table invalid for {!r}".format(sequence_name))
 *     return _str(seq.tw_table.name)
 */
  }

  /* "cpymad/libmadx.pyx":284
 *     if not seq.tw_valid:
 *         raise RuntimeError("TWISS table invalid for {!r}".format(sequence_name))
 *     return _str(seq.tw_table.name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_seq->tw_table->name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":271
 * 
 * 
 * def get_sequence_twiss_table_name(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the last calculated twiss table for the given sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx.get_sequence_twiss_table_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":287
 * 
 * 
 * def get_sequence_beam(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the beam associated to the sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_29get_sequence_beam(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_28get_sequence_beam[] = "get_sequence_beam(sequence_name)\n\n    Get the beam associated to the sequence.\n\n    :param str sequence_name: sequence name\n    :returns: beam properties as set with the BEAM command (and some more)\n    :rtype: dict\n    :raises ValueError: if the sequence name is invalid\n    :raises RuntimeError: if the sequence has no associated beam\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_29get_sequence_beam = {"get_sequence_beam", (PyCFunction)__pyx_pw_6cpymad_7libmadx_29get_sequence_beam, METH_O, __pyx_doc_6cpymad_7libmadx_28get_sequence_beam};
static PyObject *__pyx_pw_6cpymad_7libmadx_29get_sequence_beam(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_sequence_beam (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_28get_sequence_beam(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_28get_sequence_beam(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("get_sequence_beam", 0);

  /* "cpymad/libmadx.pyx":297
 *     :raises RuntimeError: if the sequence has no associated beam
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     if seq.beam is NULL or not seq.beam.beam_def:
 *         raise RuntimeError("No beam attached to {!r}".format(sequence_name))
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 297, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":298
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if seq.beam is NULL or not seq.beam.beam_def:             # <<<<<<<<<<<<<<
 *         raise RuntimeError("No beam attached to {!r}".format(sequence_name))
 *     return _parse_command(seq.beam)
 */
  __pyx_t_3 = ((__pyx_v_seq->beam == NULL) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((!(__pyx_v_seq->beam->beam_def != 0)) != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cpymad/libmadx.pyx":299
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if seq.beam is NULL or not seq.beam.beam_def:
 *         raise RuntimeError("No beam attached to {!r}".format(sequence_name))             # <<<<<<<<<<<<<<
 *     return _parse_command(seq.beam)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_beam_attached_to_r, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_sequence_name) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_sequence_name);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 299, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":298
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if seq.beam is NULL or not seq.beam.beam_def:             # <<<<<<<<<<<<<<
 *         raise RuntimeError("No beam attached to {!r}".format(sequence_name))
 *     return _parse_command(seq.beam)
 */
  }

  /* "cpymad/libmadx.pyx":300
 *     if seq.beam is NULL or not seq.beam.beam_def:
 *         raise RuntimeError("No beam attached to {!r}".format(sequence_name))
 *     return _parse_command(seq.beam)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_f_6cpymad_7libmadx__parse_command(__pyx_v_seq->beam); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":287
 * 
 * 
 * def get_sequence_beam(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the beam associated to the sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpymad.libmadx.get_sequence_beam", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":303
 * 
 * 
 * def get_active_sequence_name():             # <<<<<<<<<<<<<<
 *     """
 *     Get the name of the active sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_31get_active_sequence_name(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_30get_active_sequence_name[] = "get_active_sequence_name()\n\n    Get the name of the active sequence.\n\n    :returns: name of active sequence\n    :rtype: str\n    :raises RuntimeError: if no sequence is activated\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_31get_active_sequence_name = {"get_active_sequence_name", (PyCFunction)__pyx_pw_6cpymad_7libmadx_31get_active_sequence_name, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_30get_active_sequence_name};
static PyObject *__pyx_pw_6cpymad_7libmadx_31get_active_sequence_name(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_active_sequence_name (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_30get_active_sequence_name(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_30get_active_sequence_name(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_active_sequence_name", 0);

  /* "cpymad/libmadx.pyx":311
 *     :raises RuntimeError: if no sequence is activated
 *     """
 *     if clib.current_sequ is NULL:             # <<<<<<<<<<<<<<
 *         raise RuntimeError("No active sequence!")
 *     return _str(clib.current_sequ.name)
 */
  __pyx_t_1 = ((current_sequ == NULL) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cpymad/libmadx.pyx":312
 *     """
 *     if clib.current_sequ is NULL:
 *         raise RuntimeError("No active sequence!")             # <<<<<<<<<<<<<<
 *     return _str(clib.current_sequ.name)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 312, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":311
 *     :raises RuntimeError: if no sequence is activated
 *     """
 *     if clib.current_sequ is NULL:             # <<<<<<<<<<<<<<
 *         raise RuntimeError("No active sequence!")
 *     return _str(clib.current_sequ.name)
 */
  }

  /* "cpymad/libmadx.pyx":313
 *     if clib.current_sequ is NULL:
 *         raise RuntimeError("No active sequence!")
 *     return _str(clib.current_sequ.name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__str(current_sequ->name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":303
 * 
 * 
 * def get_active_sequence_name():             # <<<<<<<<<<<<<<
 *     """
 *     Get the name of the active sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.get_active_sequence_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":316
 * 
 * 
 * def get_sequence_names():             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all sequences currently in memory.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_33get_sequence_names(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_32get_sequence_names[] = "get_sequence_names()\n\n    Get a list of all sequences currently in memory.\n\n    :returns: sequence names\n    :rtype: list\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_33get_sequence_names = {"get_sequence_names", (PyCFunction)__pyx_pw_6cpymad_7libmadx_33get_sequence_names, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_32get_sequence_names};
static PyObject *__pyx_pw_6cpymad_7libmadx_33get_sequence_names(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_sequence_names (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_32get_sequence_names(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_32get_sequence_names(CYTHON_UNUSED PyObject *__pyx_self) {
  struct sequence_list *__pyx_v_seqs;
  int __pyx_7genexpr__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("get_sequence_names", 0);

  /* "cpymad/libmadx.pyx":323
 *     :rtype: list
 *     """
 *     cdef clib.sequence_list* seqs = clib.madextern_get_sequence_list()             # <<<<<<<<<<<<<<
 *     cdef int i
 *     return [_str(seqs.sequs[i].name)
 */
  __pyx_v_seqs = madextern_get_sequence_list();

  /* "cpymad/libmadx.pyx":325
 *     cdef clib.sequence_list* seqs = clib.madextern_get_sequence_list()
 *     cdef int i
 *     return [_str(seqs.sequs[i].name)             # <<<<<<<<<<<<<<
 *             for i in range(seqs.curr)]
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cpymad/libmadx.pyx":326
 *     cdef int i
 *     return [_str(seqs.sequs[i].name)
 *             for i in range(seqs.curr)]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_2 = __pyx_v_seqs->curr;
    __pyx_t_3 = __pyx_t_2;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_7genexpr__pyx_v_i = __pyx_t_4;

      /* "cpymad/libmadx.pyx":325
 *     cdef clib.sequence_list* seqs = clib.madextern_get_sequence_list()
 *     cdef int i
 *     return [_str(seqs.sequs[i].name)             # <<<<<<<<<<<<<<
 *             for i in range(seqs.curr)]
 * 
 */
      __pyx_t_5 = __pyx_f_6cpymad_7libmadx__str((__pyx_v_seqs->sequs[__pyx_7genexpr__pyx_v_i])->name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 325, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 325, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  } /* exit inner scope */
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":316
 * 
 * 
 * def get_sequence_names():             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all sequences currently in memory.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx.get_sequence_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":329
 * 
 * 
 * def get_sequence_count():             # <<<<<<<<<<<<<<
 *     """
 *     Get the number of all sequences currently in memory.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_35get_sequence_count(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_34get_sequence_count[] = "get_sequence_count()\n\n    Get the number of all sequences currently in memory.\n\n    :returns: number of sequences\n    :rtype: int\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_35get_sequence_count = {"get_sequence_count", (PyCFunction)__pyx_pw_6cpymad_7libmadx_35get_sequence_count, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_34get_sequence_count};
static PyObject *__pyx_pw_6cpymad_7libmadx_35get_sequence_count(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_sequence_count (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_34get_sequence_count(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_34get_sequence_count(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_sequence_count", 0);

  /* "cpymad/libmadx.pyx":336
 *     :rtype: int
 *     """
 *     return clib.madextern_get_sequence_list().curr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(madextern_get_sequence_list()->curr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":329
 * 
 * 
 * def get_sequence_count():             # <<<<<<<<<<<<<<
 *     """
 *     Get the number of all sequences currently in memory.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.get_sequence_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":339
 * 
 * 
 * def table_exists(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check if the table exists.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_37table_exists(PyObject *__pyx_self, PyObject *__pyx_v_table_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_36table_exists[] = "table_exists(table_name)\n\n    Check if the table exists.\n\n    :param str table: table name\n    :returns: True if the table exists\n    :rtype: bool\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_37table_exists = {"table_exists", (PyCFunction)__pyx_pw_6cpymad_7libmadx_37table_exists, METH_O, __pyx_doc_6cpymad_7libmadx_36table_exists};
static PyObject *__pyx_pw_6cpymad_7libmadx_37table_exists(PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("table_exists (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_36table_exists(__pyx_self, ((PyObject *)__pyx_v_table_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_36table_exists(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_v__table_name = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("table_exists", 0);

  /* "cpymad/libmadx.pyx":347
 *     :rtype: bool
 *     """
 *     cdef bytes _table_name = _cstr(table_name)             # <<<<<<<<<<<<<<
 *     return bool(clib.table_exists(_table_name))
 * 
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_table_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__table_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":348
 *     """
 *     cdef bytes _table_name = _cstr(table_name)
 *     return bool(clib.table_exists(_table_name))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v__table_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 348, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v__table_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 348, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyInt_From_int(table_exists(__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":339
 * 
 * 
 * def table_exists(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check if the table exists.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.table_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__table_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":351
 * 
 * 
 * def get_table_names():             # <<<<<<<<<<<<<<
 *     """
 *     Return list of all table names.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_39get_table_names(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_38get_table_names[] = "get_table_names()\n\n    Return list of all table names.\n\n    :returns: table names\n    :rtype: list\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_39get_table_names = {"get_table_names", (PyCFunction)__pyx_pw_6cpymad_7libmadx_39get_table_names, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_38get_table_names};
static PyObject *__pyx_pw_6cpymad_7libmadx_39get_table_names(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_names (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_38get_table_names(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_38get_table_names(CYTHON_UNUSED PyObject *__pyx_self) {
  int __pyx_8genexpr1__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("get_table_names", 0);

  /* "cpymad/libmadx.pyx":358
 *     :rtype: list
 *     """
 *     return [_str(clib.table_register.names.names[i])             # <<<<<<<<<<<<<<
 *             for i in range(clib.table_register.names.curr)]
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cpymad/libmadx.pyx":359
 *     """
 *     return [_str(clib.table_register.names.names[i])
 *             for i in range(clib.table_register.names.curr)]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_2 = table_register->names->curr;
    __pyx_t_3 = __pyx_t_2;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_8genexpr1__pyx_v_i = __pyx_t_4;

      /* "cpymad/libmadx.pyx":358
 *     :rtype: list
 *     """
 *     return [_str(clib.table_register.names.names[i])             # <<<<<<<<<<<<<<
 *             for i in range(clib.table_register.names.curr)]
 * 
 */
      __pyx_t_5 = __pyx_f_6cpymad_7libmadx__str((table_register->names->names[__pyx_8genexpr1__pyx_v_i])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 358, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 358, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  } /* exit inner scope */
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":351
 * 
 * 
 * def get_table_names():             # <<<<<<<<<<<<<<
 *     """
 *     Return list of all table names.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":362
 * 
 * 
 * def get_table_count():             # <<<<<<<<<<<<<<
 *     """
 *     Return number of existing tables.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_41get_table_count(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_40get_table_count[] = "get_table_count()\n\n    Return number of existing tables.\n\n    :returns: number of tables in memory\n    :rtype: int\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_41get_table_count = {"get_table_count", (PyCFunction)__pyx_pw_6cpymad_7libmadx_41get_table_count, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_40get_table_count};
static PyObject *__pyx_pw_6cpymad_7libmadx_41get_table_count(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_count (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_40get_table_count(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_40get_table_count(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_table_count", 0);

  /* "cpymad/libmadx.pyx":369
 *     :rtype: int
 *     """
 *     return clib.table_register.names.curr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(table_register->names->curr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":362
 * 
 * 
 * def get_table_count():             # <<<<<<<<<<<<<<
 *     """
 *     Return number of existing tables.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":372
 * 
 * 
 * def get_table_summary(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get table summary.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_43get_table_summary(PyObject *__pyx_self, PyObject *__pyx_v_table_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_42get_table_summary[] = "get_table_summary(table_name)\n\n    Get table summary.\n\n    :param str table_name: table name\n    :returns: mapping of {column: value}\n    :rtype: dict\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_43get_table_summary = {"get_table_summary", (PyCFunction)__pyx_pw_6cpymad_7libmadx_43get_table_summary, METH_O, __pyx_doc_6cpymad_7libmadx_42get_table_summary};
static PyObject *__pyx_pw_6cpymad_7libmadx_43get_table_summary(PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_summary (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_42get_table_summary(__pyx_self, ((PyObject *)__pyx_v_table_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_42get_table_summary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_v__table_name = 0;
  struct char_p_array *__pyx_v_header;
  int __pyx_8genexpr2__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("get_table_summary", 0);

  /* "cpymad/libmadx.pyx":380
 *     :rtype: dict
 *     """
 *     cdef bytes _table_name = _cstr(table_name)             # <<<<<<<<<<<<<<
 *     cdef clib.char_p_array* header = clib.table_get_header(_table_name)
 *     cdef int i
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_table_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__table_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":381
 *     """
 *     cdef bytes _table_name = _cstr(table_name)
 *     cdef clib.char_p_array* header = clib.table_get_header(_table_name)             # <<<<<<<<<<<<<<
 *     cdef int i
 *     if header is NULL:
 */
  if (unlikely(__pyx_v__table_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 381, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v__table_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 381, __pyx_L1_error)
  __pyx_v_header = table_get_header(__pyx_t_2);

  /* "cpymad/libmadx.pyx":383
 *     cdef clib.char_p_array* header = clib.table_get_header(_table_name)
 *     cdef int i
 *     if header is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError("No summary for table: {!r}".format(table_name))
 *     return dict([_split_header_line(header.p[i])
 */
  __pyx_t_3 = ((__pyx_v_header == NULL) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "cpymad/libmadx.pyx":384
 *     cdef int i
 *     if header is NULL:
 *         raise ValueError("No summary for table: {!r}".format(table_name))             # <<<<<<<<<<<<<<
 *     return dict([_split_header_line(header.p[i])
 *                  for i in range(header.curr)])
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_summary_for_table_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 384, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_table_name) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_table_name);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 384, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 384, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":383
 *     cdef clib.char_p_array* header = clib.table_get_header(_table_name)
 *     cdef int i
 *     if header is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError("No summary for table: {!r}".format(table_name))
 *     return dict([_split_header_line(header.p[i])
 */
  }

  /* "cpymad/libmadx.pyx":385
 *     if header is NULL:
 *         raise ValueError("No summary for table: {!r}".format(table_name))
 *     return dict([_split_header_line(header.p[i])             # <<<<<<<<<<<<<<
 *                  for i in range(header.curr)])
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "cpymad/libmadx.pyx":386
 *         raise ValueError("No summary for table: {!r}".format(table_name))
 *     return dict([_split_header_line(header.p[i])
 *                  for i in range(header.curr)])             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_6 = __pyx_v_header->curr;
    __pyx_t_7 = __pyx_t_6;
    for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
      __pyx_8genexpr2__pyx_v_i = __pyx_t_8;

      /* "cpymad/libmadx.pyx":385
 *     if header is NULL:
 *         raise ValueError("No summary for table: {!r}".format(table_name))
 *     return dict([_split_header_line(header.p[i])             # <<<<<<<<<<<<<<
 *                  for i in range(header.curr)])
 * 
 */
      __pyx_t_1 = __Pyx_PyBytes_FromString((__pyx_v_header->p[__pyx_8genexpr2__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __pyx_f_6cpymad_7libmadx__split_header_line(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 385, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  } /* exit inner scope */
  __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":372
 * 
 * 
 * def get_table_summary(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get table summary.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_summary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__table_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":389
 * 
 * 
 * def get_table_column_names(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all column names in the table that were selected for output.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_45get_table_column_names(PyObject *__pyx_self, PyObject *__pyx_v_table_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_44get_table_column_names[] = "get_table_column_names(table_name)\n\n    Get a list of all column names in the table that were selected for output.\n\n    :param str table_name: table name\n    :returns: column names\n    :rtype: list\n    :raises ValueError: if the table name is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_45get_table_column_names = {"get_table_column_names", (PyCFunction)__pyx_pw_6cpymad_7libmadx_45get_table_column_names, METH_O, __pyx_doc_6cpymad_7libmadx_44get_table_column_names};
static PyObject *__pyx_pw_6cpymad_7libmadx_45get_table_column_names(PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_column_names (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_44get_table_column_names(__pyx_self, ((PyObject *)__pyx_v_table_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_44get_table_column_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  struct table *__pyx_v_table;
  PyObject *__pyx_v_indices = NULL;
  int __pyx_8genexpr3__pyx_v_i;
  PyObject *__pyx_8genexpr4__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct table *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  __Pyx_RefNannySetupContext("get_table_column_names", 0);

  /* "cpymad/libmadx.pyx":398
 *     :raises ValueError: if the table name is invalid
 *     """
 *     cdef clib.table* table = _find_table(table_name)             # <<<<<<<<<<<<<<
 *     indices = [table.col_out.i[i] for i in range(table.col_out.curr)]
 *     # NOTE: we can't enforce lower-case on the column names here, since this
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_table(__pyx_v_table_name); if (unlikely(__pyx_t_1 == ((struct table *)NULL))) __PYX_ERR(0, 398, __pyx_L1_error)
  __pyx_v_table = __pyx_t_1;

  /* "cpymad/libmadx.pyx":399
 *     """
 *     cdef clib.table* table = _find_table(table_name)
 *     indices = [table.col_out.i[i] for i in range(table.col_out.curr)]             # <<<<<<<<<<<<<<
 *     # NOTE: we can't enforce lower-case on the column names here, since this
 *     # breaks their usage with get_table_column():
 */
  { /* enter inner scope */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_v_table->col_out->curr;
    __pyx_t_4 = __pyx_t_3;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_8genexpr3__pyx_v_i = __pyx_t_5;
      __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_table->col_out->i[__pyx_8genexpr3__pyx_v_i])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  } /* exit inner scope */
  __pyx_v_indices = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":402
 *     # NOTE: we can't enforce lower-case on the column names here, since this
 *     # breaks their usage with get_table_column():
 *     return [_str(table.columns.names[i]) for i in indices]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
    for (;;) {
      if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_8); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 402, __pyx_L7_error)
      #else
      __pyx_t_8 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 402, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_8);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_i, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_8genexpr4__pyx_v_i); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 402, __pyx_L7_error)
      __pyx_t_8 = __pyx_f_6cpymad_7libmadx__str((__pyx_v_table->columns->names[__pyx_t_9])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 402, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 402, __pyx_L7_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_i); __pyx_8genexpr4__pyx_v_i = 0;
    goto __pyx_L10_exit_scope;
    __pyx_L7_error:;
    __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_i); __pyx_8genexpr4__pyx_v_i = 0;
    goto __pyx_L1_error;
    __pyx_L10_exit_scope:;
  } /* exit inner scope */
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":389
 * 
 * 
 * def get_table_column_names(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all column names in the table that were selected for output.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_column_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":405
 * 
 * 
 * def get_table_column_names_all(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all column names in the table.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_47get_table_column_names_all(PyObject *__pyx_self, PyObject *__pyx_v_table_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_46get_table_column_names_all[] = "get_table_column_names_all(table_name)\n\n    Get a list of all column names in the table.\n\n    :param str table_name: table name\n    :returns: column names\n    :rtype: list\n    :raises ValueError: if the table name is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_47get_table_column_names_all = {"get_table_column_names_all", (PyCFunction)__pyx_pw_6cpymad_7libmadx_47get_table_column_names_all, METH_O, __pyx_doc_6cpymad_7libmadx_46get_table_column_names_all};
static PyObject *__pyx_pw_6cpymad_7libmadx_47get_table_column_names_all(PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_column_names_all (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_46get_table_column_names_all(__pyx_self, ((PyObject *)__pyx_v_table_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_46get_table_column_names_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  struct table *__pyx_v_table;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct table *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_table_column_names_all", 0);

  /* "cpymad/libmadx.pyx":414
 *     :raises ValueError: if the table name is invalid
 *     """
 *     cdef clib.table* table = _find_table(table_name)             # <<<<<<<<<<<<<<
 *     # NOTE: we can't enforce lower-case on the column names here, since this
 *     # breaks their usage with get_table_column():
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_table(__pyx_v_table_name); if (unlikely(__pyx_t_1 == ((struct table *)NULL))) __PYX_ERR(0, 414, __pyx_L1_error)
  __pyx_v_table = __pyx_t_1;

  /* "cpymad/libmadx.pyx":417
 *     # NOTE: we can't enforce lower-case on the column names here, since this
 *     # breaks their usage with get_table_column():
 *     return _name_list(table.columns)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__name_list(__pyx_v_table->columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":405
 * 
 * 
 * def get_table_column_names_all(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all column names in the table.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_column_names_all", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":420
 * 
 * 
 * def get_table_column_count(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a number of columns selected for display in the table.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_49get_table_column_count(PyObject *__pyx_self, PyObject *__pyx_v_table_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_48get_table_column_count[] = "get_table_column_count(table_name)\n\n    Get a number of columns selected for display in the table.\n\n    :param str table_name: table name\n    :returns: number of columns\n    :rtype: int\n    :raises ValueError: if the table name is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_49get_table_column_count = {"get_table_column_count", (PyCFunction)__pyx_pw_6cpymad_7libmadx_49get_table_column_count, METH_O, __pyx_doc_6cpymad_7libmadx_48get_table_column_count};
static PyObject *__pyx_pw_6cpymad_7libmadx_49get_table_column_count(PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_column_count (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_48get_table_column_count(__pyx_self, ((PyObject *)__pyx_v_table_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_48get_table_column_count(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  struct table *__pyx_v_table;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct table *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_table_column_count", 0);

  /* "cpymad/libmadx.pyx":429
 *     :raises ValueError: if the table name is invalid
 *     """
 *     cdef clib.table* table = _find_table(table_name)             # <<<<<<<<<<<<<<
 *     return table.col_out.curr
 * 
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_table(__pyx_v_table_name); if (unlikely(__pyx_t_1 == ((struct table *)NULL))) __PYX_ERR(0, 429, __pyx_L1_error)
  __pyx_v_table = __pyx_t_1;

  /* "cpymad/libmadx.pyx":430
 *     """
 *     cdef clib.table* table = _find_table(table_name)
 *     return table.col_out.curr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_table->col_out->curr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":420
 * 
 * 
 * def get_table_column_count(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a number of columns selected for display in the table.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_column_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":433
 * 
 * 
 * def get_table_column_count_all(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a number of columns in the table.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_51get_table_column_count_all(PyObject *__pyx_self, PyObject *__pyx_v_table_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_50get_table_column_count_all[] = "get_table_column_count_all(table_name)\n\n    Get a number of columns in the table.\n\n    :param str table_name: table name\n    :returns: number of columns\n    :rtype: int\n    :raises ValueError: if the table name is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_51get_table_column_count_all = {"get_table_column_count_all", (PyCFunction)__pyx_pw_6cpymad_7libmadx_51get_table_column_count_all, METH_O, __pyx_doc_6cpymad_7libmadx_50get_table_column_count_all};
static PyObject *__pyx_pw_6cpymad_7libmadx_51get_table_column_count_all(PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_column_count_all (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_50get_table_column_count_all(__pyx_self, ((PyObject *)__pyx_v_table_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_50get_table_column_count_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  struct table *__pyx_v_table;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct table *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_table_column_count_all", 0);

  /* "cpymad/libmadx.pyx":442
 *     :raises ValueError: if the table name is invalid
 *     """
 *     cdef clib.table* table = _find_table(table_name)             # <<<<<<<<<<<<<<
 *     return table.columns.curr
 * 
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_table(__pyx_v_table_name); if (unlikely(__pyx_t_1 == ((struct table *)NULL))) __PYX_ERR(0, 442, __pyx_L1_error)
  __pyx_v_table = __pyx_t_1;

  /* "cpymad/libmadx.pyx":443
 *     """
 *     cdef clib.table* table = _find_table(table_name)
 *     return table.columns.curr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_table->columns->curr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":433
 * 
 * 
 * def get_table_column_count_all(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a number of columns in the table.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_column_count_all", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":446
 * 
 * 
 * def get_table_column(table_name, column_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get data from the specified table.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_53get_table_column(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_52get_table_column[] = "get_table_column(table_name, column_name)\n\n    Get data from the specified table.\n\n    :param str table_name: table name\n    :param str column_name: column name\n    :returns: the data in the requested column\n    :rtype: numpy.array\n    :raises ValueError: if the column cannot be found in the table\n    :raises RuntimeError: if the column has unknown type\n\n    CAUTION: Numeric data is wrapped in numpy arrays but not copied. Make\n    sure to copy all data before invoking any further MAD-X commands! This\n    is done automatically for you if using libmadx in a remote service\n    (pickle serialization effectively copies the data).\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_53get_table_column = {"get_table_column", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_53get_table_column, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_52get_table_column};
static PyObject *__pyx_pw_6cpymad_7libmadx_53get_table_column(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_table_name = 0;
  PyObject *__pyx_v_column_name = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_column (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_table_name,&__pyx_n_s_column_name,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_table_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_column_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_table_column", 1, 2, 2, 1); __PYX_ERR(0, 446, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_table_column") < 0)) __PYX_ERR(0, 446, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_table_name = values[0];
    __pyx_v_column_name = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_table_column", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 446, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_table_column", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_52get_table_column(__pyx_self, __pyx_v_table_name, __pyx_v_column_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_52get_table_column(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name, PyObject *__pyx_v_column_name) {
  char **__pyx_v_char_tmp;
  PyObject *__pyx_v__tab_name = 0;
  PyObject *__pyx_v__col_name = 0;
  struct column_info __pyx_v_info;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_size = NULL;
  Py_intptr_t __pyx_v_addr;
  PyObject *__pyx_v_array_type = NULL;
  PyObject *__pyx_v_array_data = NULL;
  int __pyx_8genexpr5__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  char *__pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  char const *__pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("get_table_column", 0);

  /* "cpymad/libmadx.pyx":463
 *     """
 *     cdef char** char_tmp
 *     cdef bytes _tab_name = _cstr(table_name)             # <<<<<<<<<<<<<<
 *     cdef bytes _col_name = _cstr(column_name)
 *     cdef clib.column_info info = clib.table_get_column(_tab_name, _col_name)
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_table_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__tab_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":464
 *     cdef char** char_tmp
 *     cdef bytes _tab_name = _cstr(table_name)
 *     cdef bytes _col_name = _cstr(column_name)             # <<<<<<<<<<<<<<
 *     cdef clib.column_info info = clib.table_get_column(_tab_name, _col_name)
 *     dtype = <bytes> info.datatype
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_column_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__col_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":465
 *     cdef bytes _tab_name = _cstr(table_name)
 *     cdef bytes _col_name = _cstr(column_name)
 *     cdef clib.column_info info = clib.table_get_column(_tab_name, _col_name)             # <<<<<<<<<<<<<<
 *     dtype = <bytes> info.datatype
 *     size = <int> info.length
 */
  if (unlikely(__pyx_v__tab_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 465, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v__tab_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 465, __pyx_L1_error)
  if (unlikely(__pyx_v__col_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 465, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v__col_name); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 465, __pyx_L1_error)
  __pyx_v_info = table_get_column(__pyx_t_2, __pyx_t_3);

  /* "cpymad/libmadx.pyx":466
 *     cdef bytes _col_name = _cstr(column_name)
 *     cdef clib.column_info info = clib.table_get_column(_tab_name, _col_name)
 *     dtype = <bytes> info.datatype             # <<<<<<<<<<<<<<
 *     size = <int> info.length
 *     addr = <Py_intptr_t> info.data
 */
  __pyx_t_1 = PyBytes_FromStringAndSize(&__pyx_v_info.datatype, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_dtype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":467
 *     cdef clib.column_info info = clib.table_get_column(_tab_name, _col_name)
 *     dtype = <bytes> info.datatype
 *     size = <int> info.length             # <<<<<<<<<<<<<<
 *     addr = <Py_intptr_t> info.data
 *     # double:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_v_info.length)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":468
 *     dtype = <bytes> info.datatype
 *     size = <int> info.length
 *     addr = <Py_intptr_t> info.data             # <<<<<<<<<<<<<<
 *     # double:
 *     if dtype == b'i' or dtype == b'd':
 */
  __pyx_v_addr = ((Py_intptr_t)__pyx_v_info.data);

  /* "cpymad/libmadx.pyx":470
 *     addr = <Py_intptr_t> info.data
 *     # double:
 *     if dtype == b'i' or dtype == b'd':             # <<<<<<<<<<<<<<
 *         # YES, integers are internally stored as doubles in MAD-X:
 *         array_type = ctypes.c_double * size
 */
  __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_v_dtype, __pyx_n_b_i, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 470, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = (__Pyx_PyBytes_Equals(__pyx_v_dtype, __pyx_n_b_d, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 470, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "cpymad/libmadx.pyx":472
 *     if dtype == b'i' or dtype == b'd':
 *         # YES, integers are internally stored as doubles in MAD-X:
 *         array_type = ctypes.c_double * size             # <<<<<<<<<<<<<<
 *         array_data = array_type.from_address(addr)
 *         return np.ctypeslib.as_array(array_data)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_c_double); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_7, __pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_array_type = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cpymad/libmadx.pyx":473
 *         # YES, integers are internally stored as doubles in MAD-X:
 *         array_type = ctypes.c_double * size
 *         array_data = array_type.from_address(addr)             # <<<<<<<<<<<<<<
 *         return np.ctypeslib.as_array(array_data)
 *     # string:
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_array_type, __pyx_n_s_from_address); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_addr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_array_data = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cpymad/libmadx.pyx":474
 *         array_type = ctypes.c_double * size
 *         array_data = array_type.from_address(addr)
 *         return np.ctypeslib.as_array(array_data)             # <<<<<<<<<<<<<<
 *     # string:
 *     elif dtype == b'S':
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_ctypeslib); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 474, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_as_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_v_array_data) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_array_data);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 474, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":470
 *     addr = <Py_intptr_t> info.data
 *     # double:
 *     if dtype == b'i' or dtype == b'd':             # <<<<<<<<<<<<<<
 *         # YES, integers are internally stored as doubles in MAD-X:
 *         array_type = ctypes.c_double * size
 */
  }

  /* "cpymad/libmadx.pyx":476
 *         return np.ctypeslib.as_array(array_data)
 *     # string:
 *     elif dtype == b'S':             # <<<<<<<<<<<<<<
 *         char_tmp = <char**> info.data
 *         return np.array([_str(char_tmp[i]) for i in range(info.length)])
 */
  __pyx_t_4 = (__Pyx_PyBytes_Equals(__pyx_v_dtype, __pyx_n_b_S, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 476, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "cpymad/libmadx.pyx":477
 *     # string:
 *     elif dtype == b'S':
 *         char_tmp = <char**> info.data             # <<<<<<<<<<<<<<
 *         return np.array([_str(char_tmp[i]) for i in range(info.length)])
 *     # invalid:
 */
    __pyx_v_char_tmp = ((char **)__pyx_v_info.data);

    /* "cpymad/libmadx.pyx":478
 *     elif dtype == b'S':
 *         char_tmp = <char**> info.data
 *         return np.array([_str(char_tmp[i]) for i in range(info.length)])             # <<<<<<<<<<<<<<
 *     # invalid:
 *     elif dtype == b'V':
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_array); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    { /* enter inner scope */
      __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 478, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = __pyx_v_info.length;
      __pyx_t_11 = __pyx_t_10;
      for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
        __pyx_8genexpr5__pyx_v_i = __pyx_t_12;
        __pyx_t_9 = __pyx_f_6cpymad_7libmadx__str((__pyx_v_char_tmp[__pyx_8genexpr5__pyx_v_i])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 478, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 478, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    } /* exit inner scope */
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":476
 *         return np.ctypeslib.as_array(array_data)
 *     # string:
 *     elif dtype == b'S':             # <<<<<<<<<<<<<<
 *         char_tmp = <char**> info.data
 *         return np.array([_str(char_tmp[i]) for i in range(info.length)])
 */
  }

  /* "cpymad/libmadx.pyx":480
 *         return np.array([_str(char_tmp[i]) for i in range(info.length)])
 *     # invalid:
 *     elif dtype == b'V':             # <<<<<<<<<<<<<<
 *         raise ValueError("Column {!r} is not in table {!r}."
 *                          .format(column_name, table_name))
 */
  __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_v_dtype, __pyx_n_b_V, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 480, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "cpymad/libmadx.pyx":482
 *     elif dtype == b'V':
 *         raise ValueError("Column {!r} is not in table {!r}."
 *                          .format(column_name, table_name))             # <<<<<<<<<<<<<<
 *     # unknown:
 *     else:
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Column_r_is_not_in_table_r, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_column_name, __pyx_v_table_name};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_column_name, __pyx_v_table_name};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 482, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_column_name);
      __Pyx_GIVEREF(__pyx_v_column_name);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_v_column_name);
      __Pyx_INCREF(__pyx_v_table_name);
      __Pyx_GIVEREF(__pyx_v_table_name);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_v_table_name);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cpymad/libmadx.pyx":481
 *     # invalid:
 *     elif dtype == b'V':
 *         raise ValueError("Column {!r} is not in table {!r}."             # <<<<<<<<<<<<<<
 *                          .format(column_name, table_name))
 *     # unknown:
 */
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 481, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(0, 481, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":480
 *         return np.array([_str(char_tmp[i]) for i in range(info.length)])
 *     # invalid:
 *     elif dtype == b'V':             # <<<<<<<<<<<<<<
 *         raise ValueError("Column {!r} is not in table {!r}."
 *                          .format(column_name, table_name))
 */
  }

  /* "cpymad/libmadx.pyx":485
 *     # unknown:
 *     else:
 *         raise RuntimeError("Unknown datatype {!r} in column {!r}."             # <<<<<<<<<<<<<<
 *                            .format(_str(dtype), column_name))
 * 
 */
  /*else*/ {

    /* "cpymad/libmadx.pyx":486
 *     else:
 *         raise RuntimeError("Unknown datatype {!r} in column {!r}."
 *                            .format(_str(dtype), column_name))             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Unknown_datatype_r_in_column_r, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__pyx_v_dtype == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 486, __pyx_L1_error)
    }
    __pyx_t_13 = __Pyx_PyBytes_AsString(__pyx_v_dtype); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L1_error)
    __pyx_t_9 = __pyx_f_6cpymad_7libmadx__str(__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_7 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_9, __pyx_v_column_name};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 486, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_9, __pyx_v_column_name};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 486, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 486, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_10, __pyx_t_9);
      __Pyx_INCREF(__pyx_v_column_name);
      __Pyx_GIVEREF(__pyx_v_column_name);
      PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_10, __pyx_v_column_name);
      __pyx_t_9 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 486, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cpymad/libmadx.pyx":485
 *     # unknown:
 *     else:
 *         raise RuntimeError("Unknown datatype {!r} in column {!r}."             # <<<<<<<<<<<<<<
 *                            .format(_str(dtype), column_name))
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 485, __pyx_L1_error)
  }

  /* "cpymad/libmadx.pyx":446
 * 
 * 
 * def get_table_column(table_name, column_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get data from the specified table.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_column", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__tab_name);
  __Pyx_XDECREF(__pyx_v__col_name);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_size);
  __Pyx_XDECREF(__pyx_v_array_type);
  __Pyx_XDECREF(__pyx_v_array_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":489
 * 
 * 
 * def get_table_row(table_name, row_index, columns='selected'):             # <<<<<<<<<<<<<<
 *     """
 *     Return row as tuple of values.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_55get_table_row(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_54get_table_row[] = "get_table_row(table_name, row_index, columns=u'selected')\n\n    Return row as tuple of values.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_55get_table_row = {"get_table_row", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_55get_table_row, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_54get_table_row};
static PyObject *__pyx_pw_6cpymad_7libmadx_55get_table_row(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_table_name = 0;
  PyObject *__pyx_v_row_index = 0;
  PyObject *__pyx_v_columns = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_row (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_table_name,&__pyx_n_s_row_index,&__pyx_n_s_columns,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_n_u_selected);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_table_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_row_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_table_row", 0, 2, 3, 1); __PYX_ERR(0, 489, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_columns);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_table_row") < 0)) __PYX_ERR(0, 489, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_table_name = values[0];
    __pyx_v_row_index = values[1];
    __pyx_v_columns = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_table_row", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 489, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_table_row", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_54get_table_row(__pyx_self, __pyx_v_table_name, __pyx_v_row_index, __pyx_v_columns);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":501
 *         row_index += table.curr
 * 
 *     def fetch_value(col_index):             # <<<<<<<<<<<<<<
 *         inform = table.columns.inform[col_index]
 *         if inform == clib.PARAM_TYPE_INTEGER:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_13get_table_row_1fetch_value(PyObject *__pyx_self, PyObject *__pyx_v_col_index); /*proto*/
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_13get_table_row_1fetch_value = {"fetch_value", (PyCFunction)__pyx_pw_6cpymad_7libmadx_13get_table_row_1fetch_value, METH_O, 0};
static PyObject *__pyx_pw_6cpymad_7libmadx_13get_table_row_1fetch_value(PyObject *__pyx_self, PyObject *__pyx_v_col_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fetch_value (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_13get_table_row_fetch_value(__pyx_self, ((PyObject *)__pyx_v_col_index));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_13get_table_row_fetch_value(PyObject *__pyx_self, PyObject *__pyx_v_col_index) {
  struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *__pyx_cur_scope;
  struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *__pyx_outer_scope;
  PyObject *__pyx_v_inform = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("fetch_value", 0);
  __pyx_outer_scope = (struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "cpymad/libmadx.pyx":502
 * 
 *     def fetch_value(col_index):
 *         inform = table.columns.inform[col_index]             # <<<<<<<<<<<<<<
 *         if inform == clib.PARAM_TYPE_INTEGER:
 *             return int(table.d_cols[col_index][row_index])
 */
  __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_col_index); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 502, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_cur_scope->__pyx_v_table->columns->inform[__pyx_t_1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_inform = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":503
 *     def fetch_value(col_index):
 *         inform = table.columns.inform[col_index]
 *         if inform == clib.PARAM_TYPE_INTEGER:             # <<<<<<<<<<<<<<
 *             return int(table.d_cols[col_index][row_index])
 *         elif inform == clib.PARAM_TYPE_DOUBLE:
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_6cpymad_8clibmadx_PARAM_TYPE_INTEGER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_inform, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 503, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cpymad/libmadx.pyx":504
 *         inform = table.columns.inform[col_index]
 *         if inform == clib.PARAM_TYPE_INTEGER:
 *             return int(table.d_cols[col_index][row_index])             # <<<<<<<<<<<<<<
 *         elif inform == clib.PARAM_TYPE_DOUBLE:
 *             return table.d_cols[col_index][row_index]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_col_index); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 504, __pyx_L1_error)
    if (unlikely(!__pyx_cur_scope->__pyx_v_row_index)) { __Pyx_RaiseClosureNameError("row_index"); __PYX_ERR(0, 504, __pyx_L1_error) }
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_cur_scope->__pyx_v_row_index); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 504, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyInt_FromDouble(((__pyx_cur_scope->__pyx_v_table->d_cols[__pyx_t_1])[__pyx_t_5])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":503
 *     def fetch_value(col_index):
 *         inform = table.columns.inform[col_index]
 *         if inform == clib.PARAM_TYPE_INTEGER:             # <<<<<<<<<<<<<<
 *             return int(table.d_cols[col_index][row_index])
 *         elif inform == clib.PARAM_TYPE_DOUBLE:
 */
  }

  /* "cpymad/libmadx.pyx":505
 *         if inform == clib.PARAM_TYPE_INTEGER:
 *             return int(table.d_cols[col_index][row_index])
 *         elif inform == clib.PARAM_TYPE_DOUBLE:             # <<<<<<<<<<<<<<
 *             return table.d_cols[col_index][row_index]
 *         elif inform == clib.PARAM_TYPE_STRING:
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_6cpymad_8clibmadx_PARAM_TYPE_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_inform, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cpymad/libmadx.pyx":506
 *             return int(table.d_cols[col_index][row_index])
 *         elif inform == clib.PARAM_TYPE_DOUBLE:
 *             return table.d_cols[col_index][row_index]             # <<<<<<<<<<<<<<
 *         elif inform == clib.PARAM_TYPE_STRING:
 *             return _str(table.s_cols[col_index][row_index])
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_col_index); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 506, __pyx_L1_error)
    if (unlikely(!__pyx_cur_scope->__pyx_v_row_index)) { __Pyx_RaiseClosureNameError("row_index"); __PYX_ERR(0, 506, __pyx_L1_error) }
    __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_cur_scope->__pyx_v_row_index); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 506, __pyx_L1_error)
    __pyx_t_2 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_table->d_cols[__pyx_t_5])[__pyx_t_1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":505
 *         if inform == clib.PARAM_TYPE_INTEGER:
 *             return int(table.d_cols[col_index][row_index])
 *         elif inform == clib.PARAM_TYPE_DOUBLE:             # <<<<<<<<<<<<<<
 *             return table.d_cols[col_index][row_index]
 *         elif inform == clib.PARAM_TYPE_STRING:
 */
  }

  /* "cpymad/libmadx.pyx":507
 *         elif inform == clib.PARAM_TYPE_DOUBLE:
 *             return table.d_cols[col_index][row_index]
 *         elif inform == clib.PARAM_TYPE_STRING:             # <<<<<<<<<<<<<<
 *             return _str(table.s_cols[col_index][row_index])
 *         raise RuntimeError("Unknown datatype {!r} in column {!r}."
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_6cpymad_8clibmadx_PARAM_TYPE_STRING); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_inform, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cpymad/libmadx.pyx":508
 *             return table.d_cols[col_index][row_index]
 *         elif inform == clib.PARAM_TYPE_STRING:
 *             return _str(table.s_cols[col_index][row_index])             # <<<<<<<<<<<<<<
 *         raise RuntimeError("Unknown datatype {!r} in column {!r}."
 *                            .format(inform, table.columns.names[col_index]))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_col_index); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 508, __pyx_L1_error)
    if (unlikely(!__pyx_cur_scope->__pyx_v_row_index)) { __Pyx_RaiseClosureNameError("row_index"); __PYX_ERR(0, 508, __pyx_L1_error) }
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_cur_scope->__pyx_v_row_index); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 508, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6cpymad_7libmadx__str(((__pyx_cur_scope->__pyx_v_table->s_cols[__pyx_t_1])[__pyx_t_5])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":507
 *         elif inform == clib.PARAM_TYPE_DOUBLE:
 *             return table.d_cols[col_index][row_index]
 *         elif inform == clib.PARAM_TYPE_STRING:             # <<<<<<<<<<<<<<
 *             return _str(table.s_cols[col_index][row_index])
 *         raise RuntimeError("Unknown datatype {!r} in column {!r}."
 */
  }

  /* "cpymad/libmadx.pyx":510
 *             return _str(table.s_cols[col_index][row_index])
 *         raise RuntimeError("Unknown datatype {!r} in column {!r}."
 *                            .format(inform, table.columns.names[col_index]))             # <<<<<<<<<<<<<<
 * 
 *     if columns == 'all':
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Unknown_datatype_r_in_column_r, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_col_index); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 510, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyBytes_FromString((__pyx_cur_scope->__pyx_v_table->columns->names[__pyx_t_5])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_inform, __pyx_t_6};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 510, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_inform, __pyx_t_6};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 510, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_v_inform);
    __Pyx_GIVEREF(__pyx_v_inform);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_inform);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":509
 *         elif inform == clib.PARAM_TYPE_STRING:
 *             return _str(table.s_cols[col_index][row_index])
 *         raise RuntimeError("Unknown datatype {!r} in column {!r}."             # <<<<<<<<<<<<<<
 *                            .format(inform, table.columns.names[col_index]))
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __PYX_ERR(0, 509, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":501
 *         row_index += table.curr
 * 
 *     def fetch_value(col_index):             # <<<<<<<<<<<<<<
 *         inform = table.columns.inform[col_index]
 *         if inform == clib.PARAM_TYPE_INTEGER:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_row.fetch_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_inform);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":489
 * 
 * 
 * def get_table_row(table_name, row_index, columns='selected'):             # <<<<<<<<<<<<<<
 *     """
 *     Return row as tuple of values.
 */

static PyObject *__pyx_pf_6cpymad_7libmadx_54get_table_row(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name, PyObject *__pyx_v_row_index, PyObject *__pyx_v_columns) {
  struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *__pyx_cur_scope;
  PyObject *__pyx_v_fetch_value = 0;
  PyObject *__pyx_v_indices = NULL;
  PyObject *__pyx_v_col = NULL;
  int __pyx_v_idx;
  int __pyx_8genexpr6__pyx_v_i;
  PyObject *__pyx_8genexpr7__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct table *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  char *__pyx_t_16;
  Py_ssize_t __pyx_t_17;
  __Pyx_RefNannySetupContext("get_table_row", 0);
  __pyx_cur_scope = (struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *)__pyx_tp_new_6cpymad_7libmadx___pyx_scope_struct__get_table_row(__pyx_ptype_6cpymad_7libmadx___pyx_scope_struct__get_table_row, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 489, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_row_index = __pyx_v_row_index;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_row_index);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_row_index);

  /* "cpymad/libmadx.pyx":493
 *     Return row as tuple of values.
 *     """
 *     cdef clib.table* table = _find_table(table_name)             # <<<<<<<<<<<<<<
 * 
 *     if row_index < -table.curr or row_index >= table.curr:
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_table(__pyx_v_table_name); if (unlikely(__pyx_t_1 == ((struct table *)NULL))) __PYX_ERR(0, 493, __pyx_L1_error)
  __pyx_cur_scope->__pyx_v_table = __pyx_t_1;

  /* "cpymad/libmadx.pyx":495
 *     cdef clib.table* table = _find_table(table_name)
 * 
 *     if row_index < -table.curr or row_index >= table.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(row_index, table.curr))
 */
  __pyx_t_3 = __Pyx_PyInt_From_int((-__pyx_cur_scope->__pyx_v_table->curr)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_row_index, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_table->curr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_row_index, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cpymad/libmadx.pyx":497
 *     if row_index < -table.curr or row_index >= table.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(row_index, table.curr))             # <<<<<<<<<<<<<<
 *     if row_index < 0:
 *         row_index += table.curr
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Index_out_of_range_0_element_cou, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_table->curr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_row_index, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 497, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_row_index, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 497, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 497, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_row_index);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_row_index);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_cur_scope->__pyx_v_row_index);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 497, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":496
 * 
 *     if row_index < -table.curr or row_index >= table.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"             # <<<<<<<<<<<<<<
 *                          .format(row_index, table.curr))
 *     if row_index < 0:
 */
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 496, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":495
 *     cdef clib.table* table = _find_table(table_name)
 * 
 *     if row_index < -table.curr or row_index >= table.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(row_index, table.curr))
 */
  }

  /* "cpymad/libmadx.pyx":498
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(row_index, table.curr))
 *     if row_index < 0:             # <<<<<<<<<<<<<<
 *         row_index += table.curr
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_row_index, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 498, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 498, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cpymad/libmadx.pyx":499
 *                          .format(row_index, table.curr))
 *     if row_index < 0:
 *         row_index += table.curr             # <<<<<<<<<<<<<<
 * 
 *     def fetch_value(col_index):
 */
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_table->curr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 499, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_cur_scope->__pyx_v_row_index, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 499, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_row_index);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_row_index, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cpymad/libmadx.pyx":498
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(row_index, table.curr))
 *     if row_index < 0:             # <<<<<<<<<<<<<<
 *         row_index += table.curr
 * 
 */
  }

  /* "cpymad/libmadx.pyx":501
 *         row_index += table.curr
 * 
 *     def fetch_value(col_index):             # <<<<<<<<<<<<<<
 *         inform = table.columns.inform[col_index]
 *         if inform == clib.PARAM_TYPE_INTEGER:
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_13get_table_row_1fetch_value, 0, __pyx_n_s_get_table_row_locals_fetch_value, ((PyObject*)__pyx_cur_scope), __pyx_n_s_cpymad_libmadx, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_fetch_value = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpymad/libmadx.pyx":512
 *                            .format(inform, table.columns.names[col_index]))
 * 
 *     if columns == 'all':             # <<<<<<<<<<<<<<
 *         indices = range(table.columns.curr)
 *     elif columns == 'selected':
 */
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_columns, __pyx_n_u_all, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 512, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "cpymad/libmadx.pyx":513
 * 
 *     if columns == 'all':
 *         indices = range(table.columns.curr)             # <<<<<<<<<<<<<<
 *     elif columns == 'selected':
 *         indices = [table.col_out.i[i] for i in range(table.col_out.curr)]
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_table->columns->curr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_indices = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":512
 *                            .format(inform, table.columns.names[col_index]))
 * 
 *     if columns == 'all':             # <<<<<<<<<<<<<<
 *         indices = range(table.columns.curr)
 *     elif columns == 'selected':
 */
    goto __pyx_L7;
  }

  /* "cpymad/libmadx.pyx":514
 *     if columns == 'all':
 *         indices = range(table.columns.curr)
 *     elif columns == 'selected':             # <<<<<<<<<<<<<<
 *         indices = [table.col_out.i[i] for i in range(table.col_out.curr)]
 *         # fallback if selection missing:
 */
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_columns, __pyx_n_u_selected, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 514, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "cpymad/libmadx.pyx":515
 *         indices = range(table.columns.curr)
 *     elif columns == 'selected':
 *         indices = [table.col_out.i[i] for i in range(table.col_out.curr)]             # <<<<<<<<<<<<<<
 *         # fallback if selection missing:
 *         indices = indices or range(table.columns.curr)
 */
    { /* enter inner scope */
      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 515, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __pyx_cur_scope->__pyx_v_table->col_out->curr;
      __pyx_t_10 = __pyx_t_8;
      for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
        __pyx_8genexpr6__pyx_v_i = __pyx_t_11;
        __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_cur_scope->__pyx_v_table->col_out->i[__pyx_8genexpr6__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 515, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 515, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    } /* exit inner scope */
    __pyx_v_indices = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":517
 *         indices = [table.col_out.i[i] for i in range(table.col_out.curr)]
 *         # fallback if selection missing:
 *         indices = indices or range(table.columns.curr)             # <<<<<<<<<<<<<<
 *     else:
 *         indices = []
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_indices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
    if (!__pyx_t_2) {
    } else {
      __Pyx_INCREF(__pyx_v_indices);
      __pyx_t_4 = __pyx_v_indices;
      goto __pyx_L10_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_table->columns->curr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_t_9);
    __pyx_t_4 = __pyx_t_9;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_L10_bool_binop_done:;
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":514
 *     if columns == 'all':
 *         indices = range(table.columns.curr)
 *     elif columns == 'selected':             # <<<<<<<<<<<<<<
 *         indices = [table.col_out.i[i] for i in range(table.col_out.curr)]
 *         # fallback if selection missing:
 */
    goto __pyx_L7;
  }

  /* "cpymad/libmadx.pyx":519
 *         indices = indices or range(table.columns.curr)
 *     else:
 *         indices = []             # <<<<<<<<<<<<<<
 *         for col in columns:
 *             if isinstance(col, int):
 */
  /*else*/ {
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_indices = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":520
 *     else:
 *         indices = []
 *         for col in columns:             # <<<<<<<<<<<<<<
 *             if isinstance(col, int):
 *                 if col < 0 or col > table.columns.curr:
 */
    if (likely(PyList_CheckExact(__pyx_v_columns)) || PyTuple_CheckExact(__pyx_v_columns)) {
      __pyx_t_4 = __pyx_v_columns; __Pyx_INCREF(__pyx_t_4); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 520, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 520, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_9); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 520, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 520, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_9); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 520, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 520, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_13(__pyx_t_4);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 520, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_col, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "cpymad/libmadx.pyx":521
 *         indices = []
 *         for col in columns:
 *             if isinstance(col, int):             # <<<<<<<<<<<<<<
 *                 if col < 0 or col > table.columns.curr:
 *                     raise IndexError(
 */
      __pyx_t_2 = PyInt_Check(__pyx_v_col); 
      __pyx_t_5 = (__pyx_t_2 != 0);
      if (__pyx_t_5) {

        /* "cpymad/libmadx.pyx":522
 *         for col in columns:
 *             if isinstance(col, int):
 *                 if col < 0 or col > table.columns.curr:             # <<<<<<<<<<<<<<
 *                     raise IndexError(
 *                         "Column index out of range: {0} (column count is {1})"
 */
        __pyx_t_9 = PyObject_RichCompare(__pyx_v_col, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 522, __pyx_L1_error)
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 522, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (!__pyx_t_2) {
        } else {
          __pyx_t_5 = __pyx_t_2;
          goto __pyx_L16_bool_binop_done;
        }
        __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_table->columns->curr); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 522, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_3 = PyObject_RichCompare(__pyx_v_col, __pyx_t_9, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 522, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 522, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_5 = __pyx_t_2;
        __pyx_L16_bool_binop_done:;
        if (unlikely(__pyx_t_5)) {

          /* "cpymad/libmadx.pyx":525
 *                     raise IndexError(
 *                         "Column index out of range: {0} (column count is {1})"
 *                         .format(col, table.columns.curr))             # <<<<<<<<<<<<<<
 *                 indices.append(col)
 *             else:
 */
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Column_index_out_of_range_0_colu, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 525, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_table->columns->curr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 525, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = NULL;
          __pyx_t_8 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
            if (likely(__pyx_t_7)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_9, function);
              __pyx_t_8 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_col, __pyx_t_6};
            __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 525, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_col, __pyx_t_6};
            __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 525, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          } else
          #endif
          {
            __pyx_t_14 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 525, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
            if (__pyx_t_7) {
              __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_7); __pyx_t_7 = NULL;
            }
            __Pyx_INCREF(__pyx_v_col);
            __Pyx_GIVEREF(__pyx_v_col);
            PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_8, __pyx_v_col);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_8, __pyx_t_6);
            __pyx_t_6 = 0;
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 525, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          }
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

          /* "cpymad/libmadx.pyx":523
 *             if isinstance(col, int):
 *                 if col < 0 or col > table.columns.curr:
 *                     raise IndexError(             # <<<<<<<<<<<<<<
 *                         "Column index out of range: {0} (column count is {1})"
 *                         .format(col, table.columns.curr))
 */
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 523, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_Raise(__pyx_t_9, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __PYX_ERR(0, 523, __pyx_L1_error)

          /* "cpymad/libmadx.pyx":522
 *         for col in columns:
 *             if isinstance(col, int):
 *                 if col < 0 or col > table.columns.curr:             # <<<<<<<<<<<<<<
 *                     raise IndexError(
 *                         "Column index out of range: {0} (column count is {1})"
 */
        }

        /* "cpymad/libmadx.pyx":526
 *                         "Column index out of range: {0} (column count is {1})"
 *                         .format(col, table.columns.curr))
 *                 indices.append(col)             # <<<<<<<<<<<<<<
 *             else:
 *                 idx = clib.name_list_pos(_cstr(col), table.columns)
 */
        __pyx_t_15 = __Pyx_PyObject_Append(__pyx_v_indices, __pyx_v_col); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 526, __pyx_L1_error)

        /* "cpymad/libmadx.pyx":521
 *         indices = []
 *         for col in columns:
 *             if isinstance(col, int):             # <<<<<<<<<<<<<<
 *                 if col < 0 or col > table.columns.curr:
 *                     raise IndexError(
 */
        goto __pyx_L14;
      }

      /* "cpymad/libmadx.pyx":528
 *                 indices.append(col)
 *             else:
 *                 idx = clib.name_list_pos(_cstr(col), table.columns)             # <<<<<<<<<<<<<<
 *                 if idx < 0:
 *                     raise ValueError("Column not found: {0!r}".format(col))
 */
      /*else*/ {
        __pyx_t_9 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_col); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 528, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (unlikely(__pyx_t_9 == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
          __PYX_ERR(0, 528, __pyx_L1_error)
        }
        __pyx_t_16 = __Pyx_PyBytes_AsWritableString(__pyx_t_9); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 528, __pyx_L1_error)
        __pyx_v_idx = name_list_pos(__pyx_t_16, __pyx_cur_scope->__pyx_v_table->columns);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "cpymad/libmadx.pyx":529
 *             else:
 *                 idx = clib.name_list_pos(_cstr(col), table.columns)
 *                 if idx < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Column not found: {0!r}".format(col))
 *                 indices.append(idx)
 */
        __pyx_t_5 = ((__pyx_v_idx < 0) != 0);
        if (unlikely(__pyx_t_5)) {

          /* "cpymad/libmadx.pyx":530
 *                 idx = clib.name_list_pos(_cstr(col), table.columns)
 *                 if idx < 0:
 *                     raise ValueError("Column not found: {0!r}".format(col))             # <<<<<<<<<<<<<<
 *                 indices.append(idx)
 * 
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Column_not_found_0_r, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 530, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_14 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_14)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_14);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          __pyx_t_9 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_14, __pyx_v_col) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_col);
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 530, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 530, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __PYX_ERR(0, 530, __pyx_L1_error)

          /* "cpymad/libmadx.pyx":529
 *             else:
 *                 idx = clib.name_list_pos(_cstr(col), table.columns)
 *                 if idx < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Column not found: {0!r}".format(col))
 *                 indices.append(idx)
 */
        }

        /* "cpymad/libmadx.pyx":531
 *                 if idx < 0:
 *                     raise ValueError("Column not found: {0!r}".format(col))
 *                 indices.append(idx)             # <<<<<<<<<<<<<<
 * 
 *     return {
 */
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 531, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_15 = __Pyx_PyObject_Append(__pyx_v_indices, __pyx_t_3); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 531, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __pyx_L14:;

      /* "cpymad/libmadx.pyx":520
 *     else:
 *         indices = []
 *         for col in columns:             # <<<<<<<<<<<<<<
 *             if isinstance(col, int):
 *                 if col < 0 or col > table.columns.curr:
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L7:;

  /* "cpymad/libmadx.pyx":533
 *                 indices.append(idx)
 * 
 *     return {             # <<<<<<<<<<<<<<
 *         _str(table.columns.names[i]): fetch_value(i)
 *         for i in indices
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 533, __pyx_L21_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "cpymad/libmadx.pyx":535
 *     return {
 *         _str(table.columns.names[i]): fetch_value(i)
 *         for i in indices             # <<<<<<<<<<<<<<
 *     }
 * 
 */
    if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
      __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_13 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 535, __pyx_L21_error)
    }
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_12); __Pyx_INCREF(__pyx_t_9); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 535, __pyx_L21_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 535, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_12); __Pyx_INCREF(__pyx_t_9); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 535, __pyx_L21_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 535, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_13(__pyx_t_3);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 535, __pyx_L21_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_i, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "cpymad/libmadx.pyx":534
 * 
 *     return {
 *         _str(table.columns.names[i]): fetch_value(i)             # <<<<<<<<<<<<<<
 *         for i in indices
 *     }
 */
      __pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_8genexpr7__pyx_v_i); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 534, __pyx_L21_error)
      __pyx_t_9 = __pyx_f_6cpymad_7libmadx__str((__pyx_cur_scope->__pyx_v_table->columns->names[__pyx_t_17])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 534, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_14 = __pyx_pf_6cpymad_7libmadx_13get_table_row_fetch_value(__pyx_v_fetch_value, __pyx_8genexpr7__pyx_v_i); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 534, __pyx_L21_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (unlikely(PyDict_SetItem(__pyx_t_4, (PyObject*)__pyx_t_9, (PyObject*)__pyx_t_14))) __PYX_ERR(0, 534, __pyx_L21_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "cpymad/libmadx.pyx":535
 *     return {
 *         _str(table.columns.names[i]): fetch_value(i)
 *         for i in indices             # <<<<<<<<<<<<<<
 *     }
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_i); __pyx_8genexpr7__pyx_v_i = 0;
    goto __pyx_L24_exit_scope;
    __pyx_L21_error:;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_i); __pyx_8genexpr7__pyx_v_i = 0;
    goto __pyx_L1_error;
    __pyx_L24_exit_scope:;
  } /* exit inner scope */
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":489
 * 
 * 
 * def get_table_row(table_name, row_index, columns='selected'):             # <<<<<<<<<<<<<<
 *     """
 *     Return row as tuple of values.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_row", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fetch_value);
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XDECREF(__pyx_v_col);
  __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_i);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":539
 * 
 * 
 * def get_table_row_count(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return total number of rows in the table.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_57get_table_row_count(PyObject *__pyx_self, PyObject *__pyx_v_table_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_56get_table_row_count[] = "get_table_row_count(table_name)\n\n    Return total number of rows in the table.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_57get_table_row_count = {"get_table_row_count", (PyCFunction)__pyx_pw_6cpymad_7libmadx_57get_table_row_count, METH_O, __pyx_doc_6cpymad_7libmadx_56get_table_row_count};
static PyObject *__pyx_pw_6cpymad_7libmadx_57get_table_row_count(PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_row_count (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_56get_table_row_count(__pyx_self, ((PyObject *)__pyx_v_table_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_56get_table_row_count(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct table *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_table_row_count", 0);

  /* "cpymad/libmadx.pyx":543
 *     Return total number of rows in the table.
 *     """
 *     return _find_table(table_name).curr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_table(__pyx_v_table_name); if (unlikely(__pyx_t_1 == ((struct table *)NULL))) __PYX_ERR(0, 543, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1->curr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":539
 * 
 * 
 * def get_table_row_count(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return total number of rows in the table.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_row_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":546
 * 
 * 
 * def get_table_row_names(table_name, indices=None):             # <<<<<<<<<<<<<<
 *     """
 *     Return row names for every index (row number) in the list.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_59get_table_row_names(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_58get_table_row_names[] = "get_table_row_names(table_name, indices=None)\n\n    Return row names for every index (row number) in the list.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_59get_table_row_names = {"get_table_row_names", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_59get_table_row_names, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_58get_table_row_names};
static PyObject *__pyx_pw_6cpymad_7libmadx_59get_table_row_names(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_table_name = 0;
  PyObject *__pyx_v_indices = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_table_row_names (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_table_name,&__pyx_n_s_indices,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_table_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_indices);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_table_row_names") < 0)) __PYX_ERR(0, 546, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_table_name = values[0];
    __pyx_v_indices = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_table_row_names", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 546, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_table_row_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_58get_table_row_names(__pyx_self, __pyx_v_table_name, __pyx_v_indices);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_58get_table_row_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name, PyObject *__pyx_v_indices) {
  struct table *__pyx_v_table;
  PyObject *__pyx_8genexpr8__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct table *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("get_table_row_names", 0);
  __Pyx_INCREF(__pyx_v_indices);

  /* "cpymad/libmadx.pyx":550
 *     Return row names for every index (row number) in the list.
 *     """
 *     cdef clib.table* table = _find_table(table_name)             # <<<<<<<<<<<<<<
 *     if isinstance(indices, int):
 *         return _get_table_row_name(table, indices)
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_table(__pyx_v_table_name); if (unlikely(__pyx_t_1 == ((struct table *)NULL))) __PYX_ERR(0, 550, __pyx_L1_error)
  __pyx_v_table = __pyx_t_1;

  /* "cpymad/libmadx.pyx":551
 *     """
 *     cdef clib.table* table = _find_table(table_name)
 *     if isinstance(indices, int):             # <<<<<<<<<<<<<<
 *         return _get_table_row_name(table, indices)
 *     elif indices is None:
 */
  __pyx_t_2 = PyInt_Check(__pyx_v_indices); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cpymad/libmadx.pyx":552
 *     cdef clib.table* table = _find_table(table_name)
 *     if isinstance(indices, int):
 *         return _get_table_row_name(table, indices)             # <<<<<<<<<<<<<<
 *     elif indices is None:
 *         indices = range(table.curr)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_indices); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 552, __pyx_L1_error)
    __pyx_t_5 = __pyx_f_6cpymad_7libmadx__get_table_row_name(__pyx_v_table, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":551
 *     """
 *     cdef clib.table* table = _find_table(table_name)
 *     if isinstance(indices, int):             # <<<<<<<<<<<<<<
 *         return _get_table_row_name(table, indices)
 *     elif indices is None:
 */
  }

  /* "cpymad/libmadx.pyx":553
 *     if isinstance(indices, int):
 *         return _get_table_row_name(table, indices)
 *     elif indices is None:             # <<<<<<<<<<<<<<
 *         indices = range(table.curr)
 *     return [_get_table_row_name(table, i) for i in indices]
 */
  __pyx_t_3 = (__pyx_v_indices == Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cpymad/libmadx.pyx":554
 *         return _get_table_row_name(table, indices)
 *     elif indices is None:
 *         indices = range(table.curr)             # <<<<<<<<<<<<<<
 *     return [_get_table_row_name(table, i) for i in indices]
 * 
 */
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_table->curr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cpymad/libmadx.pyx":553
 *     if isinstance(indices, int):
 *         return _get_table_row_name(table, indices)
 *     elif indices is None:             # <<<<<<<<<<<<<<
 *         indices = range(table.curr)
 *     return [_get_table_row_name(table, i) for i in indices]
 */
  }

  /* "cpymad/libmadx.pyx":555
 *     elif indices is None:
 *         indices = range(table.curr)
 *     return [_get_table_row_name(table, i) for i in indices]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 555, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
      __pyx_t_5 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 555, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 555, __pyx_L6_error)
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 555, __pyx_L6_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 555, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 555, __pyx_L6_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 555, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_8(__pyx_t_5);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 555, __pyx_L6_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr8__pyx_v_i, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_8genexpr8__pyx_v_i); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 555, __pyx_L6_error)
      __pyx_t_9 = __pyx_f_6cpymad_7libmadx__get_table_row_name(__pyx_v_table, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 555, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 555, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_i); __pyx_8genexpr8__pyx_v_i = 0;
    goto __pyx_L9_exit_scope;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_i); __pyx_8genexpr8__pyx_v_i = 0;
    goto __pyx_L1_error;
    __pyx_L9_exit_scope:;
  } /* exit inner scope */
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":546
 * 
 * 
 * def get_table_row_names(table_name, indices=None):             # <<<<<<<<<<<<<<
 *     """
 *     Return row names for every index (row number) in the list.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpymad.libmadx.get_table_row_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":558
 * 
 * 
 * def apply_table_selections(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Apply the SELECT/DESELECT commands for table columns/rows.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_61apply_table_selections(PyObject *__pyx_self, PyObject *__pyx_v_table_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_60apply_table_selections[] = "apply_table_selections(table_name)\n\n    Apply the SELECT/DESELECT commands for table columns/rows.\n\n    Needed as replacement for the missing ``out_table`` call for initializing\n    ``t.row_out``, ``t.col_out`` if the twiss command was performed without a\n    filename.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_61apply_table_selections = {"apply_table_selections", (PyCFunction)__pyx_pw_6cpymad_7libmadx_61apply_table_selections, METH_O, __pyx_doc_6cpymad_7libmadx_60apply_table_selections};
static PyObject *__pyx_pw_6cpymad_7libmadx_61apply_table_selections(PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("apply_table_selections (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_60apply_table_selections(__pyx_self, ((PyObject *)__pyx_v_table_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_60apply_table_selections(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_table_name) {
  struct table *__pyx_v_t;
  PyObject *__pyx_v_version_info = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct table *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  char *__pyx_t_7;
  __Pyx_RefNannySetupContext("apply_table_selections", 0);

  /* "cpymad/libmadx.pyx":566
 *     filename.
 *     """
 *     cdef clib.table* t = _find_table(table_name)             # <<<<<<<<<<<<<<
 *     version_info = tuple(map(int, get_version_number().split('.')))
 *     if version_info > (5,3,7):       # will crash before
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_table(__pyx_v_table_name); if (unlikely(__pyx_t_1 == ((struct table *)NULL))) __PYX_ERR(0, 566, __pyx_L1_error)
  __pyx_v_t = __pyx_t_1;

  /* "cpymad/libmadx.pyx":567
 *     """
 *     cdef clib.table* t = _find_table(table_name)
 *     version_info = tuple(map(int, get_version_number().split('.')))             # <<<<<<<<<<<<<<
 *     if version_info > (5,3,7):       # will crash before
 *         clib.out_table(_cstr(table_name), t, NULL)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_get_version_number); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_kp_u__7) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__7);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_version_info = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cpymad/libmadx.pyx":568
 *     cdef clib.table* t = _find_table(table_name)
 *     version_info = tuple(map(int, get_version_number().split('.')))
 *     if version_info > (5,3,7):       # will crash before             # <<<<<<<<<<<<<<
 *         clib.out_table(_cstr(table_name), t, NULL)
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_version_info, __pyx_tuple__8, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 568, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 568, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "cpymad/libmadx.pyx":569
 *     version_info = tuple(map(int, get_version_number().split('.')))
 *     if version_info > (5,3,7):       # will crash before
 *         clib.out_table(_cstr(table_name), t, NULL)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_4 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_table_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__pyx_t_4 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 569, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_t_4); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 569, __pyx_L1_error)
    out_table(__pyx_t_7, __pyx_v_t, NULL);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":568
 *     cdef clib.table* t = _find_table(table_name)
 *     version_info = tuple(map(int, get_version_number().split('.')))
 *     if version_info > (5,3,7):       # will crash before             # <<<<<<<<<<<<<<
 *         clib.out_table(_cstr(table_name), t, NULL)
 * 
 */
  }

  /* "cpymad/libmadx.pyx":558
 * 
 * 
 * def apply_table_selections(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Apply the SELECT/DESELECT commands for table columns/rows.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx.apply_table_selections", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_version_info);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":572
 * 
 * 
 * def get_element(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the original sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_63get_element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_62get_element[] = "get_element(sequence_name, element_index)\n\n    Return requested element in the original sequence.\n\n    :param str sequence_name: sequence name\n    :param int element_index: element index\n    :returns: the element with the specified index\n    :rtype: dict\n    :raises ValueError: if the sequence is invalid\n    :raises IndexError: if the index is out of range\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_63get_element = {"get_element", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_63get_element, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_62get_element};
static PyObject *__pyx_pw_6cpymad_7libmadx_63get_element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence_name = 0;
  PyObject *__pyx_v_element_index = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_element (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence_name,&__pyx_n_s_element_index,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_element", 1, 2, 2, 1); __PYX_ERR(0, 572, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_element") < 0)) __PYX_ERR(0, 572, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sequence_name = values[0];
    __pyx_v_element_index = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_element", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 572, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_element", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_62get_element(__pyx_self, __pyx_v_sequence_name, __pyx_v_element_index);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_62get_element(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_index) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  __Pyx_RefNannySetupContext("get_element", 0);

  /* "cpymad/libmadx.pyx":583
 *     :raises IndexError: if the index is out of range
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     if element_index < 0 or element_index >= seq.nodes.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 583, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":584
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index >= seq.nodes.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, seq.nodes.curr))
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_element_index, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 584, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_seq->nodes->curr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_element_index, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cpymad/libmadx.pyx":586
 *     if element_index < 0 or element_index >= seq.nodes.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, seq.nodes.curr))             # <<<<<<<<<<<<<<
 *     return _get_node(seq.nodes.nodes[element_index], seq.ref_flag, seq.n_nodes > 0, seq.line)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Index_out_of_range_0_element_cou, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_seq->nodes->curr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_element_index, __pyx_t_6};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 586, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_element_index, __pyx_t_6};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 586, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_v_element_index);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cpymad/libmadx.pyx":585
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index >= seq.nodes.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"             # <<<<<<<<<<<<<<
 *                          .format(element_index, seq.nodes.curr))
 *     return _get_node(seq.nodes.nodes[element_index], seq.ref_flag, seq.n_nodes > 0, seq.line)
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 585, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":584
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index >= seq.nodes.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, seq.nodes.curr))
 */
  }

  /* "cpymad/libmadx.pyx":587
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, seq.nodes.curr))
 *     return _get_node(seq.nodes.nodes[element_index], seq.ref_flag, seq.n_nodes > 0, seq.line)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_element_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 587, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__get_node((__pyx_v_seq->nodes->nodes[__pyx_t_10]), __pyx_v_seq->ref_flag, (__pyx_v_seq->n_nodes > 0), __pyx_v_seq->line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":572
 * 
 * 
 * def get_element(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the original sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpymad.libmadx.get_element", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":590
 * 
 * 
 * def get_element_positions(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with positions of all elements of a specific sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_65get_element_positions(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_64get_element_positions[] = "get_element_positions(sequence_name)\n\n    Get list with positions of all elements of a specific sequence.\n\n    :param str sequence_name: sequence name\n    :returns: positions of all elements in the sequence\n    :rtype: list\n    :raises ValueError: if the sequence is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_65get_element_positions = {"get_element_positions", (PyCFunction)__pyx_pw_6cpymad_7libmadx_65get_element_positions, METH_O, __pyx_doc_6cpymad_7libmadx_64get_element_positions};
static PyObject *__pyx_pw_6cpymad_7libmadx_65get_element_positions(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_element_positions (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_64get_element_positions(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_64get_element_positions(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  struct node **__pyx_v_nodes;
  int __pyx_8genexpr9__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  struct node **__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get_element_positions", 0);

  /* "cpymad/libmadx.pyx":599
 *     :raises ValueError: if the sequence is invalid
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef int i
 *     cdef clib.node** nodes = seq.nodes.nodes
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 599, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":601
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef int i
 *     cdef clib.node** nodes = seq.nodes.nodes             # <<<<<<<<<<<<<<
 *     return [_get_node_entry_pos(nodes[i], seq.ref_flag, seq.n_nodes > 0)
 *             for i in range(seq.nodes.curr)]
 */
  __pyx_t_2 = __pyx_v_seq->nodes->nodes;
  __pyx_v_nodes = __pyx_t_2;

  /* "cpymad/libmadx.pyx":602
 *     cdef int i
 *     cdef clib.node** nodes = seq.nodes.nodes
 *     return [_get_node_entry_pos(nodes[i], seq.ref_flag, seq.n_nodes > 0)             # <<<<<<<<<<<<<<
 *             for i in range(seq.nodes.curr)]
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cpymad/libmadx.pyx":603
 *     cdef clib.node** nodes = seq.nodes.nodes
 *     return [_get_node_entry_pos(nodes[i], seq.ref_flag, seq.n_nodes > 0)
 *             for i in range(seq.nodes.curr)]             # <<<<<<<<<<<<<<
 * 
 * def get_element_names(sequence_name):
 */
    __pyx_t_4 = __pyx_v_seq->nodes->curr;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_8genexpr9__pyx_v_i = __pyx_t_6;

      /* "cpymad/libmadx.pyx":602
 *     cdef int i
 *     cdef clib.node** nodes = seq.nodes.nodes
 *     return [_get_node_entry_pos(nodes[i], seq.ref_flag, seq.n_nodes > 0)             # <<<<<<<<<<<<<<
 *             for i in range(seq.nodes.curr)]
 * 
 */
      __pyx_t_7 = PyFloat_FromDouble(__pyx_f_6cpymad_7libmadx__get_node_entry_pos((__pyx_v_nodes[__pyx_8genexpr9__pyx_v_i]), __pyx_v_seq->ref_flag, (__pyx_v_seq->n_nodes > 0))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 602, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 602, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  } /* exit inner scope */
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":590
 * 
 * 
 * def get_element_positions(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with positions of all elements of a specific sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpymad.libmadx.get_element_positions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":605
 *             for i in range(seq.nodes.curr)]
 * 
 * def get_element_names(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_67get_element_names(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_66get_element_names[] = "get_element_names(sequence_name)\n\n    Get list with the names of all elements of a specific sequence.\n\n    :param str sequence_name: sequence name\n    :returns: names of all elements in the sequence\n    :rtype: list\n    :raises ValueError: if the sequence is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_67get_element_names = {"get_element_names", (PyCFunction)__pyx_pw_6cpymad_7libmadx_67get_element_names, METH_O, __pyx_doc_6cpymad_7libmadx_66get_element_names};
static PyObject *__pyx_pw_6cpymad_7libmadx_67get_element_names(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_element_names (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_66get_element_names(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_66get_element_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  int __pyx_9genexpr10__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("get_element_names", 0);

  /* "cpymad/libmadx.pyx":614
 *     :raises ValueError: if the sequence is invalid
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef int i
 *     return [_node_name(seq.nodes.nodes[i])
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 614, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":616
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef int i
 *     return [_node_name(seq.nodes.nodes[i])             # <<<<<<<<<<<<<<
 *             for i in range(seq.nodes.curr)]
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cpymad/libmadx.pyx":617
 *     cdef int i
 *     return [_node_name(seq.nodes.nodes[i])
 *             for i in range(seq.nodes.curr)]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __pyx_v_seq->nodes->curr;
    __pyx_t_4 = __pyx_t_3;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_9genexpr10__pyx_v_i = __pyx_t_5;

      /* "cpymad/libmadx.pyx":616
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef int i
 *     return [_node_name(seq.nodes.nodes[i])             # <<<<<<<<<<<<<<
 *             for i in range(seq.nodes.curr)]
 * 
 */
      __pyx_t_6 = __pyx_f_6cpymad_7libmadx__node_name((__pyx_v_seq->nodes->nodes[__pyx_9genexpr10__pyx_v_i])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 616, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 616, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  } /* exit inner scope */
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":605
 *             for i in range(seq.nodes.curr)]
 * 
 * def get_element_names(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpymad.libmadx.get_element_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":620
 * 
 * 
 * def get_element_name(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_69get_element_name(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_68get_element_name[] = "get_element_name(sequence_name, element_index)\n\n    Get list with the names of all elements of a specific sequence.\n\n    :param str sequence_name: sequence name\n    :param int element_index: element index\n    :returns: the name of the element with the specified index\n    :rtype: str\n    :raises ValueError: if the sequence is invalid\n    :raises IndexError: if the index is out of range\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_69get_element_name = {"get_element_name", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_69get_element_name, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_68get_element_name};
static PyObject *__pyx_pw_6cpymad_7libmadx_69get_element_name(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence_name = 0;
  PyObject *__pyx_v_element_index = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_element_name (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence_name,&__pyx_n_s_element_index,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_element_name", 1, 2, 2, 1); __PYX_ERR(0, 620, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_element_name") < 0)) __PYX_ERR(0, 620, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sequence_name = values[0];
    __pyx_v_element_index = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_element_name", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 620, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_element_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_68get_element_name(__pyx_self, __pyx_v_sequence_name, __pyx_v_element_index);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_68get_element_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_index) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  __Pyx_RefNannySetupContext("get_element_name", 0);

  /* "cpymad/libmadx.pyx":631
 *     :raises IndexError: if the index is out of range
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     if element_index < 0 or element_index >= seq.nodes.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 631, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":632
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index >= seq.nodes.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, seq.nodes.curr))
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_element_index, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 632, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_seq->nodes->curr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_element_index, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 632, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 632, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cpymad/libmadx.pyx":634
 *     if element_index < 0 or element_index >= seq.nodes.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, seq.nodes.curr))             # <<<<<<<<<<<<<<
 *     return _node_name(seq.nodes.nodes[element_index])
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Index_out_of_range_0_element_cou, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_seq->nodes->curr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_element_index, __pyx_t_6};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_element_index, __pyx_t_6};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_v_element_index);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cpymad/libmadx.pyx":633
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index >= seq.nodes.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"             # <<<<<<<<<<<<<<
 *                          .format(element_index, seq.nodes.curr))
 *     return _node_name(seq.nodes.nodes[element_index])
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 633, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":632
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index >= seq.nodes.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, seq.nodes.curr))
 */
  }

  /* "cpymad/libmadx.pyx":635
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, seq.nodes.curr))
 *     return _node_name(seq.nodes.nodes[element_index])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_element_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 635, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__node_name((__pyx_v_seq->nodes->nodes[__pyx_t_10])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":620
 * 
 * 
 * def get_element_name(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpymad.libmadx.get_element_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":638
 * 
 * 
 * def get_element_index(sequence_name, element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the original sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_71get_element_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_70get_element_index[] = "get_element_index(sequence_name, element_name)\n\n    Return index of element with specified name in the original sequence.\n\n    :param str sequence_name: sequence name\n    :param str element_name: element index\n    :returns: the index of the specified element\n    :rtype: int\n    :raises ValueError: if the sequence or element name is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_71get_element_index = {"get_element_index", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_71get_element_index, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_70get_element_index};
static PyObject *__pyx_pw_6cpymad_7libmadx_71get_element_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence_name = 0;
  PyObject *__pyx_v_element_name = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_element_index (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence_name,&__pyx_n_s_element_name,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_element_index", 1, 2, 2, 1); __PYX_ERR(0, 638, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_element_index") < 0)) __PYX_ERR(0, 638, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sequence_name = values[0];
    __pyx_v_element_name = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_element_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 638, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_element_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_70get_element_index(__pyx_self, __pyx_v_sequence_name, __pyx_v_element_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_70get_element_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_name) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_v__element_name = 0;
  int __pyx_v_index;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  char *__pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("get_element_index", 0);

  /* "cpymad/libmadx.pyx":648
 *     :raises ValueError: if the sequence or element name is invalid
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))
 *     cdef int index = clib.name_list_pos(_element_name, seq.nodes.list)
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 648, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":649
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))             # <<<<<<<<<<<<<<
 *     cdef int index = clib.name_list_pos(_element_name, seq.nodes.list)
 *     if index == -1:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_name_to_internal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_element_name) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_element_name);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v__element_name = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpymad/libmadx.pyx":650
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))
 *     cdef int index = clib.name_list_pos(_element_name, seq.nodes.list)             # <<<<<<<<<<<<<<
 *     if index == -1:
 *         raise ValueError("Element name not found: {0!r}".format(element_name))
 */
  if (unlikely(__pyx_v__element_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 650, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyBytes_AsWritableString(__pyx_v__element_name); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 650, __pyx_L1_error)
  __pyx_v_index = name_list_pos(__pyx_t_5, __pyx_v_seq->nodes->list);

  /* "cpymad/libmadx.pyx":651
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))
 *     cdef int index = clib.name_list_pos(_element_name, seq.nodes.list)
 *     if index == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError("Element name not found: {0!r}".format(element_name))
 *     return index
 */
  __pyx_t_6 = ((__pyx_v_index == -1L) != 0);
  if (unlikely(__pyx_t_6)) {

    /* "cpymad/libmadx.pyx":652
 *     cdef int index = clib.name_list_pos(_element_name, seq.nodes.list)
 *     if index == -1:
 *         raise ValueError("Element name not found: {0!r}".format(element_name))             # <<<<<<<<<<<<<<
 *     return index
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Element_name_not_found_0_r, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_element_name) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_element_name);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 652, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":651
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))
 *     cdef int index = clib.name_list_pos(_element_name, seq.nodes.list)
 *     if index == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError("Element name not found: {0!r}".format(element_name))
 *     return index
 */
  }

  /* "cpymad/libmadx.pyx":653
 *     if index == -1:
 *         raise ValueError("Element name not found: {0!r}".format(element_name))
 *     return index             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":638
 * 
 * 
 * def get_element_index(sequence_name, element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the original sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpymad.libmadx.get_element_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__element_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":656
 * 
 * 
 * def get_element_index_by_position(sequence_name, position):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element at specified position in the original sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_73get_element_index_by_position(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_72get_element_index_by_position[] = "get_element_index_by_position(sequence_name, position)\n\n    Return index of element at specified position in the original sequence.\n\n    :param str sequence_name: sequence name\n    :param double position: position (S coordinate)\n    :returns: the index of an element at that position, -1 if not found\n    :rtype: int\n    :raises ValueError: if the sequence or element name is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_73get_element_index_by_position = {"get_element_index_by_position", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_73get_element_index_by_position, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_72get_element_index_by_position};
static PyObject *__pyx_pw_6cpymad_7libmadx_73get_element_index_by_position(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence_name = 0;
  PyObject *__pyx_v_position = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_element_index_by_position (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence_name,&__pyx_n_s_position,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_position)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_element_index_by_position", 1, 2, 2, 1); __PYX_ERR(0, 656, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_element_index_by_position") < 0)) __PYX_ERR(0, 656, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sequence_name = values[0];
    __pyx_v_position = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_element_index_by_position", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 656, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_element_index_by_position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_72get_element_index_by_position(__pyx_self, __pyx_v_sequence_name, __pyx_v_position);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_72get_element_index_by_position(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_position) {
  struct sequence *__pyx_v_seq;
  double __pyx_v__position;
  struct node *__pyx_v_elem;
  double __pyx_v_at;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  double __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("get_element_index_by_position", 0);

  /* "cpymad/libmadx.pyx":669
 *     # algorithm. If you want more, you need to copy the elements over and use
 *     # a suitable ordered data type.
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef double _position = position
 *     cdef clib.node* elem
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 669, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":670
 *     # a suitable ordered data type.
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef double _position = position             # <<<<<<<<<<<<<<
 *     cdef clib.node* elem
 *     cdef double at
 */
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_position); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 670, __pyx_L1_error)
  __pyx_v__position = __pyx_t_2;

  /* "cpymad/libmadx.pyx":673
 *     cdef clib.node* elem
 *     cdef double at
 *     for i in range(seq.nodes.curr):             # <<<<<<<<<<<<<<
 *         elem = seq.nodes.nodes[i]
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 */
  __pyx_t_3 = __pyx_v_seq->nodes->curr;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cpymad/libmadx.pyx":674
 *     cdef double at
 *     for i in range(seq.nodes.curr):
 *         elem = seq.nodes.nodes[i]             # <<<<<<<<<<<<<<
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 *         if _position >= at and _position <= at+elem.length:
 */
    __pyx_v_elem = (__pyx_v_seq->nodes->nodes[__pyx_v_i]);

    /* "cpymad/libmadx.pyx":675
 *     for i in range(seq.nodes.curr):
 *         elem = seq.nodes.nodes[i]
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)             # <<<<<<<<<<<<<<
 *         if _position >= at and _position <= at+elem.length:
 *             return i
 */
    __pyx_v_at = __pyx_f_6cpymad_7libmadx__get_node_entry_pos(__pyx_v_elem, __pyx_v_seq->ref_flag, (__pyx_v_seq->n_nodes > 0));

    /* "cpymad/libmadx.pyx":676
 *         elem = seq.nodes.nodes[i]
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 *         if _position >= at and _position <= at+elem.length:             # <<<<<<<<<<<<<<
 *             return i
 *     raise ValueError("No element found at position: {0}".format(position))
 */
    __pyx_t_7 = ((__pyx_v__position >= __pyx_v_at) != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v__position <= (__pyx_v_at + __pyx_v_elem->length)) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_6) {

      /* "cpymad/libmadx.pyx":677
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 *         if _position >= at and _position <= at+elem.length:
 *             return i             # <<<<<<<<<<<<<<
 *     raise ValueError("No element found at position: {0}".format(position))
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_r = __pyx_t_8;
      __pyx_t_8 = 0;
      goto __pyx_L0;

      /* "cpymad/libmadx.pyx":676
 *         elem = seq.nodes.nodes[i]
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 *         if _position >= at and _position <= at+elem.length:             # <<<<<<<<<<<<<<
 *             return i
 *     raise ValueError("No element found at position: {0}".format(position))
 */
    }
  }

  /* "cpymad/libmadx.pyx":678
 *         if _position >= at and _position <= at+elem.length:
 *             return i
 *     raise ValueError("No element found at position: {0}".format(position))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_element_found_at_position_0, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  __pyx_t_8 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_v_position) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_position);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_Raise(__pyx_t_9, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __PYX_ERR(0, 678, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":656
 * 
 * 
 * def get_element_index_by_position(sequence_name, position):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element at specified position in the original sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cpymad.libmadx.get_element_index_by_position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":681
 * 
 * 
 * def get_element_count(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return number of elements in the original sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_75get_element_count(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_74get_element_count[] = "get_element_count(sequence_name)\n\n    Return number of elements in the original sequence.\n\n    :param str sequence_name: sequence name\n    :returns: number of elements in the original sequence\n    :rtype: int\n    :raises ValueError: if the sequence is invalid.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_75get_element_count = {"get_element_count", (PyCFunction)__pyx_pw_6cpymad_7libmadx_75get_element_count, METH_O, __pyx_doc_6cpymad_7libmadx_74get_element_count};
static PyObject *__pyx_pw_6cpymad_7libmadx_75get_element_count(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_element_count (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_74get_element_count(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_74get_element_count(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_element_count", 0);

  /* "cpymad/libmadx.pyx":690
 *     :raises ValueError: if the sequence is invalid.
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     return seq.nodes.curr
 * 
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 690, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":691
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     return seq.nodes.curr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_seq->nodes->curr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 691, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":681
 * 
 * 
 * def get_element_count(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return number of elements in the original sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.get_element_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":694
 * 
 * 
 * def get_expanded_element(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the expanded sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_77get_expanded_element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_76get_expanded_element[] = "get_expanded_element(sequence_name, element_index)\n\n    Return requested element in the expanded sequence.\n\n    :param str sequence_name: sequence name\n    :param int element_index: element index\n    :returns: the element with the specified index\n    :rtype: dict\n    :raises ValueError: if the sequence is invalid\n    :raises IndexError: if the index is out of range\n\n    NOTE: this function may currently return elements beyond the end of the\n    expanded sequence if requested to do so.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_77get_expanded_element = {"get_expanded_element", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_77get_expanded_element, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_76get_expanded_element};
static PyObject *__pyx_pw_6cpymad_7libmadx_77get_expanded_element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence_name = 0;
  PyObject *__pyx_v_element_index = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_expanded_element (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence_name,&__pyx_n_s_element_index,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_expanded_element", 1, 2, 2, 1); __PYX_ERR(0, 694, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_expanded_element") < 0)) __PYX_ERR(0, 694, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sequence_name = values[0];
    __pyx_v_element_index = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_expanded_element", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 694, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_76get_expanded_element(__pyx_self, __pyx_v_sequence_name, __pyx_v_element_index);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_76get_expanded_element(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_index) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  __Pyx_RefNannySetupContext("get_expanded_element", 0);

  /* "cpymad/libmadx.pyx":708
 *     expanded sequence if requested to do so.
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     if element_index < 0 or element_index > seq.n_nodes:
 *         raise IndexError(
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 708, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":709
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index > seq.n_nodes:             # <<<<<<<<<<<<<<
 *         raise IndexError(
 *             "Index out of range: {0} (element count is {1})"
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_element_index, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 709, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_seq->n_nodes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_element_index, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cpymad/libmadx.pyx":712
 *         raise IndexError(
 *             "Index out of range: {0} (element count is {1})"
 *             .format(element_index, seq.n_nodes))             # <<<<<<<<<<<<<<
 *     return _get_node(seq.all_nodes[element_index], seq.ref_flag, seq.n_nodes > 0, seq.line)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Index_out_of_range_0_element_cou, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_seq->n_nodes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 712, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_element_index, __pyx_t_6};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 712, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_element_index, __pyx_t_6};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 712, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 712, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_v_element_index);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 712, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cpymad/libmadx.pyx":710
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index > seq.n_nodes:
 *         raise IndexError(             # <<<<<<<<<<<<<<
 *             "Index out of range: {0} (element count is {1})"
 *             .format(element_index, seq.n_nodes))
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 710, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":709
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index > seq.n_nodes:             # <<<<<<<<<<<<<<
 *         raise IndexError(
 *             "Index out of range: {0} (element count is {1})"
 */
  }

  /* "cpymad/libmadx.pyx":713
 *             "Index out of range: {0} (element count is {1})"
 *             .format(element_index, seq.n_nodes))
 *     return _get_node(seq.all_nodes[element_index], seq.ref_flag, seq.n_nodes > 0, seq.line)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_element_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 713, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__get_node((__pyx_v_seq->all_nodes[__pyx_t_10]), __pyx_v_seq->ref_flag, (__pyx_v_seq->n_nodes > 0), __pyx_v_seq->line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":694
 * 
 * 
 * def get_expanded_element(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the expanded sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":716
 * 
 * 
 * def get_expanded_element_positions(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with positions of all elements of a specific sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_79get_expanded_element_positions(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_78get_expanded_element_positions[] = "get_expanded_element_positions(sequence_name)\n\n    Get list with positions of all elements of a specific sequence.\n\n    :param str sequence_name: sequence name\n    :returns: positions of all elements in the sequence\n    :rtype: list\n    :raises ValueError: if the sequence is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_79get_expanded_element_positions = {"get_expanded_element_positions", (PyCFunction)__pyx_pw_6cpymad_7libmadx_79get_expanded_element_positions, METH_O, __pyx_doc_6cpymad_7libmadx_78get_expanded_element_positions};
static PyObject *__pyx_pw_6cpymad_7libmadx_79get_expanded_element_positions(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_expanded_element_positions (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_78get_expanded_element_positions(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_78get_expanded_element_positions(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  struct node **__pyx_v_nodes;
  int __pyx_9genexpr11__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  struct node **__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("get_expanded_element_positions", 0);

  /* "cpymad/libmadx.pyx":725
 *     :raises ValueError: if the sequence is invalid
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef int i
 *     cdef clib.node** nodes = seq.all_nodes
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 725, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":727
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef int i
 *     cdef clib.node** nodes = seq.all_nodes             # <<<<<<<<<<<<<<
 *     return [_get_node_entry_pos(nodes[i], seq.ref_flag, seq.n_nodes > 0)
 *             for i in range(seq.n_nodes)]
 */
  __pyx_t_2 = __pyx_v_seq->all_nodes;
  __pyx_v_nodes = __pyx_t_2;

  /* "cpymad/libmadx.pyx":728
 *     cdef int i
 *     cdef clib.node** nodes = seq.all_nodes
 *     return [_get_node_entry_pos(nodes[i], seq.ref_flag, seq.n_nodes > 0)             # <<<<<<<<<<<<<<
 *             for i in range(seq.n_nodes)]
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cpymad/libmadx.pyx":729
 *     cdef clib.node** nodes = seq.all_nodes
 *     return [_get_node_entry_pos(nodes[i], seq.ref_flag, seq.n_nodes > 0)
 *             for i in range(seq.n_nodes)]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_4 = __pyx_v_seq->n_nodes;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_9genexpr11__pyx_v_i = __pyx_t_6;

      /* "cpymad/libmadx.pyx":728
 *     cdef int i
 *     cdef clib.node** nodes = seq.all_nodes
 *     return [_get_node_entry_pos(nodes[i], seq.ref_flag, seq.n_nodes > 0)             # <<<<<<<<<<<<<<
 *             for i in range(seq.n_nodes)]
 * 
 */
      __pyx_t_7 = PyFloat_FromDouble(__pyx_f_6cpymad_7libmadx__get_node_entry_pos((__pyx_v_nodes[__pyx_9genexpr11__pyx_v_i]), __pyx_v_seq->ref_flag, (__pyx_v_seq->n_nodes > 0))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  } /* exit inner scope */
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":716
 * 
 * 
 * def get_expanded_element_positions(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with positions of all elements of a specific sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_positions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":732
 * 
 * 
 * def get_expanded_element_names(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_81get_expanded_element_names(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_80get_expanded_element_names[] = "get_expanded_element_names(sequence_name)\n\n    Get list with the names of all elements of a specific sequence.\n\n    :param str sequence_name: sequence name\n    :returns: names of all elements in the sequence\n    :rtype: list\n    :raises ValueError: if the sequence is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_81get_expanded_element_names = {"get_expanded_element_names", (PyCFunction)__pyx_pw_6cpymad_7libmadx_81get_expanded_element_names, METH_O, __pyx_doc_6cpymad_7libmadx_80get_expanded_element_names};
static PyObject *__pyx_pw_6cpymad_7libmadx_81get_expanded_element_names(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_expanded_element_names (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_80get_expanded_element_names(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_80get_expanded_element_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  int __pyx_9genexpr12__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("get_expanded_element_names", 0);

  /* "cpymad/libmadx.pyx":741
 *     :raises ValueError: if the sequence is invalid
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef int i
 *     return [_node_name(seq.all_nodes[i])
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 741, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":743
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef int i
 *     return [_node_name(seq.all_nodes[i])             # <<<<<<<<<<<<<<
 *             for i in range(seq.n_nodes)]
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cpymad/libmadx.pyx":744
 *     cdef int i
 *     return [_node_name(seq.all_nodes[i])
 *             for i in range(seq.n_nodes)]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __pyx_v_seq->n_nodes;
    __pyx_t_4 = __pyx_t_3;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_9genexpr12__pyx_v_i = __pyx_t_5;

      /* "cpymad/libmadx.pyx":743
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef int i
 *     return [_node_name(seq.all_nodes[i])             # <<<<<<<<<<<<<<
 *             for i in range(seq.n_nodes)]
 * 
 */
      __pyx_t_6 = __pyx_f_6cpymad_7libmadx__node_name((__pyx_v_seq->all_nodes[__pyx_9genexpr12__pyx_v_i])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 743, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 743, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  } /* exit inner scope */
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":732
 * 
 * 
 * def get_expanded_element_names(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":747
 * 
 * 
 * def get_expanded_element_name(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_83get_expanded_element_name(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_82get_expanded_element_name[] = "get_expanded_element_name(sequence_name, element_index)\n\n    Get list with the names of all elements of a specific sequence.\n\n    :param str sequence_name: sequence name\n    :param int element_index: element index\n    :returns: the name of the element with the specified index\n    :rtype: str\n    :raises ValueError: if the sequence is invalid\n    :raises IndexError: if the index is out of range\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_83get_expanded_element_name = {"get_expanded_element_name", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_83get_expanded_element_name, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_82get_expanded_element_name};
static PyObject *__pyx_pw_6cpymad_7libmadx_83get_expanded_element_name(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence_name = 0;
  PyObject *__pyx_v_element_index = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_expanded_element_name (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence_name,&__pyx_n_s_element_index,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_expanded_element_name", 1, 2, 2, 1); __PYX_ERR(0, 747, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_expanded_element_name") < 0)) __PYX_ERR(0, 747, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sequence_name = values[0];
    __pyx_v_element_index = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_expanded_element_name", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 747, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_82get_expanded_element_name(__pyx_self, __pyx_v_sequence_name, __pyx_v_element_index);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_82get_expanded_element_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_index) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  __Pyx_RefNannySetupContext("get_expanded_element_name", 0);

  /* "cpymad/libmadx.pyx":758
 *     :raises IndexError: if the index is out of range
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     if element_index < 0 or element_index > seq.n_nodes:
 *         raise IndexError(
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 758, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":759
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index > seq.n_nodes:             # <<<<<<<<<<<<<<
 *         raise IndexError(
 *             "Index out of range: {0} (element count is {1})"
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_element_index, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_seq->n_nodes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_element_index, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cpymad/libmadx.pyx":762
 *         raise IndexError(
 *             "Index out of range: {0} (element count is {1})"
 *             .format(element_index, seq.n_nodes))             # <<<<<<<<<<<<<<
 *     return _node_name(seq.all_nodes[element_index])
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Index_out_of_range_0_element_cou, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_seq->n_nodes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 762, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_element_index, __pyx_t_6};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_element_index, __pyx_t_6};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_v_element_index);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cpymad/libmadx.pyx":760
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index > seq.n_nodes:
 *         raise IndexError(             # <<<<<<<<<<<<<<
 *             "Index out of range: {0} (element count is {1})"
 *             .format(element_index, seq.n_nodes))
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 760, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":759
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     if element_index < 0 or element_index > seq.n_nodes:             # <<<<<<<<<<<<<<
 *         raise IndexError(
 *             "Index out of range: {0} (element count is {1})"
 */
  }

  /* "cpymad/libmadx.pyx":763
 *             "Index out of range: {0} (element count is {1})"
 *             .format(element_index, seq.n_nodes))
 *     return _node_name(seq.all_nodes[element_index])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_element_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 763, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__node_name((__pyx_v_seq->all_nodes[__pyx_t_10])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 763, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":747
 * 
 * 
 * def get_expanded_element_name(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":766
 * 
 * 
 * def get_expanded_element_index(sequence_name, element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the expanded sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_85get_expanded_element_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_84get_expanded_element_index[] = "get_expanded_element_index(sequence_name, element_name)\n\n    Return index of element with specified name in the expanded sequence.\n\n    NOTE: this is the brute-force linear-time algorithm and therefore not\n    recommended for frequent execution.\n\n    :param str sequence_name: sequence name\n    :param str element_name: element index\n    :returns: the index of the specified element, -1 if not found\n    :rtype: int\n    :raises ValueError: if the sequence is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_85get_expanded_element_index = {"get_expanded_element_index", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_85get_expanded_element_index, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_84get_expanded_element_index};
static PyObject *__pyx_pw_6cpymad_7libmadx_85get_expanded_element_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence_name = 0;
  PyObject *__pyx_v_element_name = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_expanded_element_index (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence_name,&__pyx_n_s_element_name,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_element_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_expanded_element_index", 1, 2, 2, 1); __PYX_ERR(0, 766, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_expanded_element_index") < 0)) __PYX_ERR(0, 766, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sequence_name = values[0];
    __pyx_v_element_name = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_expanded_element_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 766, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_84get_expanded_element_index(__pyx_self, __pyx_v_sequence_name, __pyx_v_element_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_84get_expanded_element_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_element_name) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_v__element_name = 0;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("get_expanded_element_index", 0);

  /* "cpymad/libmadx.pyx":781
 *     # Unfortunately, there is no name_list for the expanded list. Therefore,
 *     # Therefore, we can only provide a linear-time lookup.
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))
 *     for i in range(seq.n_nodes):
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 781, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":782
 *     # Therefore, we can only provide a linear-time lookup.
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))             # <<<<<<<<<<<<<<
 *     for i in range(seq.n_nodes):
 *         if seq.all_nodes[i].name == _element_name:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_name_to_internal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_element_name) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_element_name);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v__element_name = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpymad/libmadx.pyx":783
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))
 *     for i in range(seq.n_nodes):             # <<<<<<<<<<<<<<
 *         if seq.all_nodes[i].name == _element_name:
 *             return i
 */
  __pyx_t_5 = __pyx_v_seq->n_nodes;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "cpymad/libmadx.pyx":784
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))
 *     for i in range(seq.n_nodes):
 *         if seq.all_nodes[i].name == _element_name:             # <<<<<<<<<<<<<<
 *             return i
 *     raise ValueError("Element name not found: {0!r}".format(element_name))
 */
    __pyx_t_3 = __Pyx_PyObject_FromString((__pyx_v_seq->all_nodes[__pyx_v_i])->name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = (__Pyx_PyBytes_Equals(__pyx_t_3, __pyx_v__element_name, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_8) {

      /* "cpymad/libmadx.pyx":785
 *     for i in range(seq.n_nodes):
 *         if seq.all_nodes[i].name == _element_name:
 *             return i             # <<<<<<<<<<<<<<
 *     raise ValueError("Element name not found: {0!r}".format(element_name))
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 785, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "cpymad/libmadx.pyx":784
 *     cdef bytes _element_name = _cstr(name_to_internal(element_name))
 *     for i in range(seq.n_nodes):
 *         if seq.all_nodes[i].name == _element_name:             # <<<<<<<<<<<<<<
 *             return i
 *     raise ValueError("Element name not found: {0!r}".format(element_name))
 */
    }
  }

  /* "cpymad/libmadx.pyx":786
 *         if seq.all_nodes[i].name == _element_name:
 *             return i
 *     raise ValueError("Element name not found: {0!r}".format(element_name))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Element_name_not_found_0_r, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_element_name) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_element_name);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __PYX_ERR(0, 786, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":766
 * 
 * 
 * def get_expanded_element_index(sequence_name, element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the expanded sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__element_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":789
 * 
 * 
 * def get_expanded_element_index_by_position(sequence_name, position):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element at specified position in the expanded sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_87get_expanded_element_index_by_position(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_86get_expanded_element_index_by_position[] = "get_expanded_element_index_by_position(sequence_name, position)\n\n    Return index of element at specified position in the expanded sequence.\n\n    :param str sequence_name: sequence name\n    :param double position: position (S coordinate)\n    :returns: the index of an element at that position\n    :rtype: int\n    :raises ValueError: if the sequence or element name is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_87get_expanded_element_index_by_position = {"get_expanded_element_index_by_position", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6cpymad_7libmadx_87get_expanded_element_index_by_position, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cpymad_7libmadx_86get_expanded_element_index_by_position};
static PyObject *__pyx_pw_6cpymad_7libmadx_87get_expanded_element_index_by_position(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sequence_name = 0;
  PyObject *__pyx_v_position = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_expanded_element_index_by_position (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence_name,&__pyx_n_s_position,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_position)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_expanded_element_index_by_position", 1, 2, 2, 1); __PYX_ERR(0, 789, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_expanded_element_index_by_position") < 0)) __PYX_ERR(0, 789, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sequence_name = values[0];
    __pyx_v_position = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_expanded_element_index_by_position", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 789, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_index_by_position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cpymad_7libmadx_86get_expanded_element_index_by_position(__pyx_self, __pyx_v_sequence_name, __pyx_v_position);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_86get_expanded_element_index_by_position(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name, PyObject *__pyx_v_position) {
  struct sequence *__pyx_v_seq;
  double __pyx_v__position;
  struct node *__pyx_v_elem;
  double __pyx_v_at;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  double __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("get_expanded_element_index_by_position", 0);

  /* "cpymad/libmadx.pyx":802
 *     # algorithm. If you want more, you need to copy the elements over and use
 *     # a suitable ordered data type.
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef double _position = position
 *     cdef clib.node* elem
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 802, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":803
 *     # a suitable ordered data type.
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     cdef double _position = position             # <<<<<<<<<<<<<<
 *     cdef clib.node* elem
 *     cdef double at
 */
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_position); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 803, __pyx_L1_error)
  __pyx_v__position = __pyx_t_2;

  /* "cpymad/libmadx.pyx":806
 *     cdef clib.node* elem
 *     cdef double at
 *     for i in range(seq.n_nodes):             # <<<<<<<<<<<<<<
 *         elem = seq.all_nodes[i]
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 */
  __pyx_t_3 = __pyx_v_seq->n_nodes;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cpymad/libmadx.pyx":807
 *     cdef double at
 *     for i in range(seq.n_nodes):
 *         elem = seq.all_nodes[i]             # <<<<<<<<<<<<<<
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 *         if _position >= at and _position <= at+elem.length:
 */
    __pyx_v_elem = (__pyx_v_seq->all_nodes[__pyx_v_i]);

    /* "cpymad/libmadx.pyx":808
 *     for i in range(seq.n_nodes):
 *         elem = seq.all_nodes[i]
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)             # <<<<<<<<<<<<<<
 *         if _position >= at and _position <= at+elem.length:
 *             return i
 */
    __pyx_v_at = __pyx_f_6cpymad_7libmadx__get_node_entry_pos(__pyx_v_elem, __pyx_v_seq->ref_flag, (__pyx_v_seq->n_nodes > 0));

    /* "cpymad/libmadx.pyx":809
 *         elem = seq.all_nodes[i]
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 *         if _position >= at and _position <= at+elem.length:             # <<<<<<<<<<<<<<
 *             return i
 *     raise ValueError("No element found at position: {0}".format(position))
 */
    __pyx_t_7 = ((__pyx_v__position >= __pyx_v_at) != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v__position <= (__pyx_v_at + __pyx_v_elem->length)) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_6) {

      /* "cpymad/libmadx.pyx":810
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 *         if _position >= at and _position <= at+elem.length:
 *             return i             # <<<<<<<<<<<<<<
 *     raise ValueError("No element found at position: {0}".format(position))
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 810, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_r = __pyx_t_8;
      __pyx_t_8 = 0;
      goto __pyx_L0;

      /* "cpymad/libmadx.pyx":809
 *         elem = seq.all_nodes[i]
 *         at = _get_node_entry_pos(elem, seq.ref_flag, seq.n_nodes > 0)
 *         if _position >= at and _position <= at+elem.length:             # <<<<<<<<<<<<<<
 *             return i
 *     raise ValueError("No element found at position: {0}".format(position))
 */
    }
  }

  /* "cpymad/libmadx.pyx":811
 *         if _position >= at and _position <= at+elem.length:
 *             return i
 *     raise ValueError("No element found at position: {0}".format(position))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_element_found_at_position_0, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  __pyx_t_8 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_v_position) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_position);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_Raise(__pyx_t_9, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __PYX_ERR(0, 811, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":789
 * 
 * 
 * def get_expanded_element_index_by_position(sequence_name, position):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element at specified position in the expanded sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_index_by_position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":814
 * 
 * 
 * def get_expanded_element_count(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return number of elements in the expanded sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_89get_expanded_element_count(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_88get_expanded_element_count[] = "get_expanded_element_count(sequence_name)\n\n    Return number of elements in the expanded sequence.\n\n    :param str sequence_name: sequence name\n    :returns: number of elements in the expanded sequence\n    :rtype: int\n    :raises ValueError: if the sequence is invalid.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_89get_expanded_element_count = {"get_expanded_element_count", (PyCFunction)__pyx_pw_6cpymad_7libmadx_89get_expanded_element_count, METH_O, __pyx_doc_6cpymad_7libmadx_88get_expanded_element_count};
static PyObject *__pyx_pw_6cpymad_7libmadx_89get_expanded_element_count(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_expanded_element_count (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_88get_expanded_element_count(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_88get_expanded_element_count(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("get_expanded_element_count", 0);

  /* "cpymad/libmadx.pyx":823
 *     :raises ValueError: if the sequence is invalid.
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     return seq.n_nodes
 * 
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 823, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":824
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     return seq.n_nodes             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_seq->n_nodes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 824, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":814
 * 
 * 
 * def get_expanded_element_count(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return number of elements in the expanded sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.get_expanded_element_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":827
 * 
 * 
 * def get_global_element(element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the expanded sequence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_91get_global_element(PyObject *__pyx_self, PyObject *__pyx_v_element_index); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_90get_global_element[] = "get_global_element(element_index)\n\n    Return requested element in the expanded sequence.\n\n    :param int element_index: element index\n    :returns: the element with the specified index\n    :rtype: dict\n    :raises IndexError: if the index is out of range\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_91get_global_element = {"get_global_element", (PyCFunction)__pyx_pw_6cpymad_7libmadx_91get_global_element, METH_O, __pyx_doc_6cpymad_7libmadx_90get_global_element};
static PyObject *__pyx_pw_6cpymad_7libmadx_91get_global_element(PyObject *__pyx_self, PyObject *__pyx_v_element_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_global_element (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_90get_global_element(__pyx_self, ((PyObject *)__pyx_v_element_index));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_90get_global_element(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_element_index) {
  struct el_list *__pyx_v_elems;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  __Pyx_RefNannySetupContext("get_global_element", 0);

  /* "cpymad/libmadx.pyx":836
 *     :raises IndexError: if the index is out of range
 *     """
 *     cdef clib.el_list* elems = clib.element_list             # <<<<<<<<<<<<<<
 *     if element_index < 0 or element_index >= elems.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 */
  __pyx_v_elems = element_list;

  /* "cpymad/libmadx.pyx":837
 *     """
 *     cdef clib.el_list* elems = clib.element_list
 *     if element_index < 0 or element_index >= elems.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, elems.curr))
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_element_index, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 837, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 837, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_elems->curr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 837, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_element_index, __pyx_t_2, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 837, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 837, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "cpymad/libmadx.pyx":839
 *     if element_index < 0 or element_index >= elems.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, elems.curr))             # <<<<<<<<<<<<<<
 *     return _get_element(elems.elem[element_index])
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Index_out_of_range_0_element_cou, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 839, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_elems->curr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 839, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_element_index, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 839, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_element_index, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 839, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 839, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_v_element_index);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 839, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cpymad/libmadx.pyx":838
 *     cdef clib.el_list* elems = clib.element_list
 *     if element_index < 0 or element_index >= elems.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"             # <<<<<<<<<<<<<<
 *                          .format(element_index, elems.curr))
 *     return _get_element(elems.elem[element_index])
 */
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 838, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":837
 *     """
 *     cdef clib.el_list* elems = clib.element_list
 *     if element_index < 0 or element_index >= elems.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, elems.curr))
 */
  }

  /* "cpymad/libmadx.pyx":840
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, elems.curr))
 *     return _get_element(elems.elem[element_index])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_element_index); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 840, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__get_element((__pyx_v_elems->elem[__pyx_t_9])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":827
 * 
 * 
 * def get_global_element(element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the expanded sequence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpymad.libmadx.get_global_element", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":843
 * 
 * 
 * def get_global_element_name(element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return name of element.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_93get_global_element_name(PyObject *__pyx_self, PyObject *__pyx_v_element_index); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_92get_global_element_name[] = "get_global_element_name(element_index)\n\n    Return name of element.\n\n    :param int element_index: element index\n    :returns: element name\n    :rtype: str\n    :raises IndexError: if the index is out of range\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_93get_global_element_name = {"get_global_element_name", (PyCFunction)__pyx_pw_6cpymad_7libmadx_93get_global_element_name, METH_O, __pyx_doc_6cpymad_7libmadx_92get_global_element_name};
static PyObject *__pyx_pw_6cpymad_7libmadx_93get_global_element_name(PyObject *__pyx_self, PyObject *__pyx_v_element_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_global_element_name (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_92get_global_element_name(__pyx_self, ((PyObject *)__pyx_v_element_index));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_92get_global_element_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_element_index) {
  struct el_list *__pyx_v_elems;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  __Pyx_RefNannySetupContext("get_global_element_name", 0);

  /* "cpymad/libmadx.pyx":852
 *     :raises IndexError: if the index is out of range
 *     """
 *     cdef clib.el_list* elems = clib.element_list             # <<<<<<<<<<<<<<
 *     if element_index < 0 or element_index >= elems.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 */
  __pyx_v_elems = element_list;

  /* "cpymad/libmadx.pyx":853
 *     """
 *     cdef clib.el_list* elems = clib.element_list
 *     if element_index < 0 or element_index >= elems.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, elems.curr))
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_element_index, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 853, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_elems->curr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_element_index, __pyx_t_2, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "cpymad/libmadx.pyx":855
 *     if element_index < 0 or element_index >= elems.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, elems.curr))             # <<<<<<<<<<<<<<
 *     return _str(elems.list.names[element_index])
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Index_out_of_range_0_element_cou, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_elems->curr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_element_index, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_element_index, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_v_element_index);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_element_index);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cpymad/libmadx.pyx":854
 *     cdef clib.el_list* elems = clib.element_list
 *     if element_index < 0 or element_index >= elems.curr:
 *         raise IndexError("Index out of range: {0} (element count is {1})"             # <<<<<<<<<<<<<<
 *                          .format(element_index, elems.curr))
 *     return _str(elems.list.names[element_index])
 */
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 854, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":853
 *     """
 *     cdef clib.el_list* elems = clib.element_list
 *     if element_index < 0 or element_index >= elems.curr:             # <<<<<<<<<<<<<<
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, elems.curr))
 */
  }

  /* "cpymad/libmadx.pyx":856
 *         raise IndexError("Index out of range: {0} (element count is {1})"
 *                          .format(element_index, elems.curr))
 *     return _str(elems.list.names[element_index])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_element_index); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 856, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__str((__pyx_v_elems->list->names[__pyx_t_9])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 856, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":843
 * 
 * 
 * def get_global_element_name(element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return name of element.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpymad.libmadx.get_global_element_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":859
 * 
 * 
 * def get_global_element_index(element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the global element list.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_95get_global_element_index(PyObject *__pyx_self, PyObject *__pyx_v_element_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_94get_global_element_index[] = "get_global_element_index(element_name)\n\n    Return index of element with specified name in the global element list.\n\n    :param str element_name: element index\n    :returns: the index of the specified element, -1 if not found\n    :rtype: int\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_95get_global_element_index = {"get_global_element_index", (PyCFunction)__pyx_pw_6cpymad_7libmadx_95get_global_element_index, METH_O, __pyx_doc_6cpymad_7libmadx_94get_global_element_index};
static PyObject *__pyx_pw_6cpymad_7libmadx_95get_global_element_index(PyObject *__pyx_self, PyObject *__pyx_v_element_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_global_element_index (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_94get_global_element_index(__pyx_self, ((PyObject *)__pyx_v_element_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_94get_global_element_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_element_name) {
  PyObject *__pyx_v__element_name = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  __Pyx_RefNannySetupContext("get_global_element_index", 0);

  /* "cpymad/libmadx.pyx":867
 *     :rtype: int
 *     """
 *     cdef bytes _element_name = _cstr(element_name)             # <<<<<<<<<<<<<<
 *     return clib.name_list_pos(_element_name, clib.element_list.list)
 * 
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_element_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__element_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":868
 *     """
 *     cdef bytes _element_name = _cstr(element_name)
 *     return clib.name_list_pos(_element_name, clib.element_list.list)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v__element_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 868, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v__element_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 868, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyInt_From_int(name_list_pos(__pyx_t_2, element_list->list)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":859
 * 
 * 
 * def get_global_element_index(element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the global element list.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.get_global_element_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__element_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":871
 * 
 * 
 * def get_global_element_count():             # <<<<<<<<<<<<<<
 *     """
 *     Return number of globally visible elements.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_97get_global_element_count(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_96get_global_element_count[] = "get_global_element_count()\n\n    Return number of globally visible elements.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_97get_global_element_count = {"get_global_element_count", (PyCFunction)__pyx_pw_6cpymad_7libmadx_97get_global_element_count, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_96get_global_element_count};
static PyObject *__pyx_pw_6cpymad_7libmadx_97get_global_element_count(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_global_element_count (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_96get_global_element_count(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_96get_global_element_count(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_global_element_count", 0);

  /* "cpymad/libmadx.pyx":875
 *     Return number of globally visible elements.
 *     """
 *     return clib.element_list.curr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(element_list->curr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":871
 * 
 * 
 * def get_global_element_count():             # <<<<<<<<<<<<<<
 *     """
 *     Return number of globally visible elements.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.get_global_element_count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":878
 * 
 * 
 * def get_base_type_names():             # <<<<<<<<<<<<<<
 *     """
 *     Return list of element names for base types.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_99get_base_type_names(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_98get_base_type_names[] = "get_base_type_names()\n\n    Return list of element names for base types.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_99get_base_type_names = {"get_base_type_names", (PyCFunction)__pyx_pw_6cpymad_7libmadx_99get_base_type_names, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_98get_base_type_names};
static PyObject *__pyx_pw_6cpymad_7libmadx_99get_base_type_names(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_base_type_names (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_98get_base_type_names(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_98get_base_type_names(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_base_type_names", 0);

  /* "cpymad/libmadx.pyx":882
 *     Return list of element names for base types.
 *     """
 *     return _name_list(clib.base_type_list.list)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__name_list(base_type_list->list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":878
 * 
 * 
 * def get_base_type_names():             # <<<<<<<<<<<<<<
 *     """
 *     Return list of element names for base types.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.get_base_type_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":885
 * 
 * 
 * def get_defined_command(command_name):             # <<<<<<<<<<<<<<
 *     """Return MAD-X command as dict of values."""
 *     cdef bytes _command_name = _cstr(command_name)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_101get_defined_command(PyObject *__pyx_self, PyObject *__pyx_v_command_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_100get_defined_command[] = "get_defined_command(command_name)\nReturn MAD-X command as dict of values.";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_101get_defined_command = {"get_defined_command", (PyCFunction)__pyx_pw_6cpymad_7libmadx_101get_defined_command, METH_O, __pyx_doc_6cpymad_7libmadx_100get_defined_command};
static PyObject *__pyx_pw_6cpymad_7libmadx_101get_defined_command(PyObject *__pyx_self, PyObject *__pyx_v_command_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_defined_command (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_100get_defined_command(__pyx_self, ((PyObject *)__pyx_v_command_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_100get_defined_command(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_command_name) {
  PyObject *__pyx_v__command_name = 0;
  int __pyx_v_index;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("get_defined_command", 0);

  /* "cpymad/libmadx.pyx":887
 * def get_defined_command(command_name):
 *     """Return MAD-X command as dict of values."""
 *     cdef bytes _command_name = _cstr(command_name)             # <<<<<<<<<<<<<<
 *     cdef int index = clib.name_list_pos(_command_name, clib.defined_commands.list)
 *     if index == -1:
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_command_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 887, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__command_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":888
 *     """Return MAD-X command as dict of values."""
 *     cdef bytes _command_name = _cstr(command_name)
 *     cdef int index = clib.name_list_pos(_command_name, clib.defined_commands.list)             # <<<<<<<<<<<<<<
 *     if index == -1:
 *         raise ValueError("Invalid command: {!r}".format(command_name))
 */
  if (unlikely(__pyx_v__command_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 888, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v__command_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 888, __pyx_L1_error)
  __pyx_v_index = name_list_pos(__pyx_t_2, defined_commands->list);

  /* "cpymad/libmadx.pyx":889
 *     cdef bytes _command_name = _cstr(command_name)
 *     cdef int index = clib.name_list_pos(_command_name, clib.defined_commands.list)
 *     if index == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid command: {!r}".format(command_name))
 *     return _parse_command(clib.defined_commands.commands[index])
 */
  __pyx_t_3 = ((__pyx_v_index == -1L) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "cpymad/libmadx.pyx":890
 *     cdef int index = clib.name_list_pos(_command_name, clib.defined_commands.list)
 *     if index == -1:
 *         raise ValueError("Invalid command: {!r}".format(command_name))             # <<<<<<<<<<<<<<
 *     return _parse_command(clib.defined_commands.commands[index])
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Invalid_command_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 890, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_command_name) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_command_name);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 890, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 890, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 890, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":889
 *     cdef bytes _command_name = _cstr(command_name)
 *     cdef int index = clib.name_list_pos(_command_name, clib.defined_commands.list)
 *     if index == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid command: {!r}".format(command_name))
 *     return _parse_command(clib.defined_commands.commands[index])
 */
  }

  /* "cpymad/libmadx.pyx":891
 *     if index == -1:
 *         raise ValueError("Invalid command: {!r}".format(command_name))
 *     return _parse_command(clib.defined_commands.commands[index])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_6cpymad_7libmadx__parse_command((defined_commands->commands[__pyx_v_index])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":885
 * 
 * 
 * def get_defined_command(command_name):             # <<<<<<<<<<<<<<
 *     """Return MAD-X command as dict of values."""
 *     cdef bytes _command_name = _cstr(command_name)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx.get_defined_command", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__command_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":894
 * 
 * 
 * def get_defined_command_names():             # <<<<<<<<<<<<<<
 *     """Return list of MAD-X command names."""
 *     return _name_list(clib.defined_commands.list)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_103get_defined_command_names(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_102get_defined_command_names[] = "get_defined_command_names()\nReturn list of MAD-X command names.";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_103get_defined_command_names = {"get_defined_command_names", (PyCFunction)__pyx_pw_6cpymad_7libmadx_103get_defined_command_names, METH_NOARGS, __pyx_doc_6cpymad_7libmadx_102get_defined_command_names};
static PyObject *__pyx_pw_6cpymad_7libmadx_103get_defined_command_names(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_defined_command_names (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_102get_defined_command_names(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_102get_defined_command_names(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_defined_command_names", 0);

  /* "cpymad/libmadx.pyx":896
 * def get_defined_command_names():
 *     """Return list of MAD-X command names."""
 *     return _name_list(clib.defined_commands.list)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__name_list(defined_commands->list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":894
 * 
 * 
 * def get_defined_command_names():             # <<<<<<<<<<<<<<
 *     """Return list of MAD-X command names."""
 *     return _name_list(clib.defined_commands.list)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx.get_defined_command_names", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":899
 * 
 * 
 * def is_sequence_expanded(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check whether a sequence has already been expanded.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_105is_sequence_expanded(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_104is_sequence_expanded[] = "is_sequence_expanded(sequence_name)\n\n    Check whether a sequence has already been expanded.\n\n    :param str sequence_name: sequence name\n    :returns: expanded state of the sequence\n    :rtype: bool\n    :raises ValueError: if the sequence is invalid\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_105is_sequence_expanded = {"is_sequence_expanded", (PyCFunction)__pyx_pw_6cpymad_7libmadx_105is_sequence_expanded, METH_O, __pyx_doc_6cpymad_7libmadx_104is_sequence_expanded};
static PyObject *__pyx_pw_6cpymad_7libmadx_105is_sequence_expanded(PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_sequence_expanded (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_104is_sequence_expanded(__pyx_self, ((PyObject *)__pyx_v_sequence_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_104is_sequence_expanded(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence_name) {
  struct sequence *__pyx_v_seq;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct sequence *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("is_sequence_expanded", 0);

  /* "cpymad/libmadx.pyx":908
 *     :raises ValueError: if the sequence is invalid
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)             # <<<<<<<<<<<<<<
 *     return seq.n_nodes > 0
 * 
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__find_sequence(__pyx_v_sequence_name); if (unlikely(__pyx_t_1 == ((struct sequence *)NULL))) __PYX_ERR(0, 908, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_1;

  /* "cpymad/libmadx.pyx":909
 *     """
 *     cdef clib.sequence* seq = _find_sequence(sequence_name)
 *     return seq.n_nodes > 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyBool_FromLong((__pyx_v_seq->n_nodes > 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 909, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":899
 * 
 * 
 * def is_sequence_expanded(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check whether a sequence has already been expanded.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx.is_sequence_expanded", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":912
 * 
 * 
 * def eval(expression):             # <<<<<<<<<<<<<<
 *     """
 *     Evaluates an expression and returns the result as double.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_107eval(PyObject *__pyx_self, PyObject *__pyx_v_expression); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_106eval[] = "eval(expression)\n\n    Evaluates an expression and returns the result as double.\n\n    :param str expression: symbolic expression to evaluate\n    :returns: numeric value of the expression\n    :rtype: float\n\n    NOTE: This function does not perform rigorous input validation! It uses\n    nothing but the MAD-X builtin rather incompetent error checks. This means\n    invalid input such as '+' can lead to program crashes! If you're looking\n    for more secure validation, see :func:`cpymad.util.check_expression`.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_107eval = {"eval", (PyCFunction)__pyx_pw_6cpymad_7libmadx_107eval, METH_O, __pyx_doc_6cpymad_7libmadx_106eval};
static PyObject *__pyx_pw_6cpymad_7libmadx_107eval(PyObject *__pyx_self, PyObject *__pyx_v_expression) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("eval (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_106eval(__pyx_self, ((PyObject *)__pyx_v_expression));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_106eval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_expression) {
  struct expression *__pyx_v_expr;
  double __pyx_v_value;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("eval", 0);

  /* "cpymad/libmadx.pyx":925
 *     for more secure validation, see :func:`cpymad.util.check_expression`.
 *     """
 *     cdef clib.expression* expr = _make_expr(expression)             # <<<<<<<<<<<<<<
 *     if expr == NULL:
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 */
  __pyx_v_expr = __pyx_f_6cpymad_7libmadx__make_expr(__pyx_v_expression);

  /* "cpymad/libmadx.pyx":926
 *     """
 *     cdef clib.expression* expr = _make_expr(expression)
 *     if expr == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 *     value = clib.expression_value(expr, 2)
 */
  __pyx_t_1 = ((__pyx_v_expr == NULL) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cpymad/libmadx.pyx":927
 *     cdef clib.expression* expr = _make_expr(expression)
 *     if expr == NULL:
 *         raise ValueError("Invalid expression: {!r}".format(expression))             # <<<<<<<<<<<<<<
 *     value = clib.expression_value(expr, 2)
 *     clib.delete_expression(expr)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Invalid_expression_r, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_expression) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_expression);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 927, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":926
 *     """
 *     cdef clib.expression* expr = _make_expr(expression)
 *     if expr == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 *     value = clib.expression_value(expr, 2)
 */
  }

  /* "cpymad/libmadx.pyx":928
 *     if expr == NULL:
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 *     value = clib.expression_value(expr, 2)             # <<<<<<<<<<<<<<
 *     clib.delete_expression(expr)
 *     return value
 */
  __pyx_v_value = expression_value(__pyx_v_expr, 2);

  /* "cpymad/libmadx.pyx":929
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 *     value = clib.expression_value(expr, 2)
 *     clib.delete_expression(expr)             # <<<<<<<<<<<<<<
 *     return value
 * 
 */
  (void)(delete_expression(__pyx_v_expr));

  /* "cpymad/libmadx.pyx":930
 *     value = clib.expression_value(expr, 2)
 *     clib.delete_expression(expr)
 *     return value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":912
 * 
 * 
 * def eval(expression):             # <<<<<<<<<<<<<<
 *     """
 *     Evaluates an expression and returns the result as double.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpymad.libmadx.eval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":933
 * 
 * 
 * def expression_vars(expression):             # <<<<<<<<<<<<<<
 *     """
 *     Returns all the variables in an expression.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6cpymad_7libmadx_109expression_vars(PyObject *__pyx_self, PyObject *__pyx_v_expression); /*proto*/
static char __pyx_doc_6cpymad_7libmadx_108expression_vars[] = "expression_vars(expression)\n\n    Returns all the variables in an expression.\n\n    :param str expression: symbolic expression\n    :returns: set of variables\n    :rtype: set\n\n    NOTE: This function does not perform rigorous input validation! It uses\n    nothing but the MAD-X builtin rather incompetent error checks. This means\n    invalid input such as '+' can lead to program crashes! If you're looking\n    for more secure validation, see :func:`cpymad.util.check_expression`.\n    ";
static PyMethodDef __pyx_mdef_6cpymad_7libmadx_109expression_vars = {"expression_vars", (PyCFunction)__pyx_pw_6cpymad_7libmadx_109expression_vars, METH_O, __pyx_doc_6cpymad_7libmadx_108expression_vars};
static PyObject *__pyx_pw_6cpymad_7libmadx_109expression_vars(PyObject *__pyx_self, PyObject *__pyx_v_expression) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("expression_vars (wrapper)", 0);
  __pyx_r = __pyx_pf_6cpymad_7libmadx_108expression_vars(__pyx_self, ((PyObject *)__pyx_v_expression));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6cpymad_7libmadx_108expression_vars(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_expression) {
  struct expression *__pyx_v_expr;
  PyObject *__pyx_v_vars = NULL;
  int __pyx_9genexpr13__pyx_v_i;
  PyObject *__pyx_9genexpr13__pyx_v_k = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  __Pyx_RefNannySetupContext("expression_vars", 0);

  /* "cpymad/libmadx.pyx":946
 *     for more secure validation, see :func:`cpymad.util.check_expression`.
 *     """
 *     cdef clib.expression* expr = _make_expr(expression)             # <<<<<<<<<<<<<<
 *     if expr == NULL:
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 */
  __pyx_v_expr = __pyx_f_6cpymad_7libmadx__make_expr(__pyx_v_expression);

  /* "cpymad/libmadx.pyx":947
 *     """
 *     cdef clib.expression* expr = _make_expr(expression)
 *     if expr == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 *     cdef int i
 */
  __pyx_t_1 = ((__pyx_v_expr == NULL) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cpymad/libmadx.pyx":948
 *     cdef clib.expression* expr = _make_expr(expression)
 *     if expr == NULL:
 *         raise ValueError("Invalid expression: {!r}".format(expression))             # <<<<<<<<<<<<<<
 *     cdef int i
 *     vars = {_str(clib.expr_chunks.names[k % 100000000])
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Invalid_expression_r, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 948, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_expression) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_expression);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 948, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 948, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 948, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":947
 *     """
 *     cdef clib.expression* expr = _make_expr(expression)
 *     if expr == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 *     cdef int i
 */
  }

  /* "cpymad/libmadx.pyx":950
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 *     cdef int i
 *     vars = {_str(clib.expr_chunks.names[k % 100000000])             # <<<<<<<<<<<<<<
 *             for i in range(expr.polish.curr)
 *             for k in [expr.polish.i[i]]
 */
  { /* enter inner scope */
    __pyx_t_3 = PySet_New(NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 950, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cpymad/libmadx.pyx":951
 *     cdef int i
 *     vars = {_str(clib.expr_chunks.names[k % 100000000])
 *             for i in range(expr.polish.curr)             # <<<<<<<<<<<<<<
 *             for k in [expr.polish.i[i]]
 *             if k // 100000000 == 1}
 */
    __pyx_t_5 = __pyx_v_expr->polish->curr;
    __pyx_t_6 = __pyx_t_5;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_9genexpr13__pyx_v_i = __pyx_t_7;

      /* "cpymad/libmadx.pyx":952
 *     vars = {_str(clib.expr_chunks.names[k % 100000000])
 *             for i in range(expr.polish.curr)
 *             for k in [expr.polish.i[i]]             # <<<<<<<<<<<<<<
 *             if k // 100000000 == 1}
 *     clib.delete_expression(expr)
 */
      __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_expr->polish->i[__pyx_9genexpr13__pyx_v_i])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 952, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 952, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      for (;;) {
        if (__pyx_t_8 >= 1) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 952, __pyx_L6_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 952, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
        __Pyx_XDECREF_SET(__pyx_9genexpr13__pyx_v_k, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "cpymad/libmadx.pyx":953
 *             for i in range(expr.polish.curr)
 *             for k in [expr.polish.i[i]]
 *             if k // 100000000 == 1}             # <<<<<<<<<<<<<<
 *     clib.delete_expression(expr)
 *     return vars
 */
        __pyx_t_4 = __Pyx_PyInt_FloorDivideObjC(__pyx_9genexpr13__pyx_v_k, __pyx_int_100000000, 0x5F5E100, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 953, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_9 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 953, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 953, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (__pyx_t_1) {

          /* "cpymad/libmadx.pyx":950
 *         raise ValueError("Invalid expression: {!r}".format(expression))
 *     cdef int i
 *     vars = {_str(clib.expr_chunks.names[k % 100000000])             # <<<<<<<<<<<<<<
 *             for i in range(expr.polish.curr)
 *             for k in [expr.polish.i[i]]
 */
          __pyx_t_9 = __Pyx_PyInt_RemainderObjC(__pyx_9genexpr13__pyx_v_k, __pyx_int_100000000, 0x5F5E100, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 950, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 950, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __pyx_f_6cpymad_7libmadx__str((expr_chunks->names[__pyx_t_10])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 950, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (unlikely(PySet_Add(__pyx_t_3, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 950, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

          /* "cpymad/libmadx.pyx":953
 *             for i in range(expr.polish.curr)
 *             for k in [expr.polish.i[i]]
 *             if k // 100000000 == 1}             # <<<<<<<<<<<<<<
 *     clib.delete_expression(expr)
 *     return vars
 */
        }

        /* "cpymad/libmadx.pyx":952
 *     vars = {_str(clib.expr_chunks.names[k % 100000000])
 *             for i in range(expr.polish.curr)
 *             for k in [expr.polish.i[i]]             # <<<<<<<<<<<<<<
 *             if k // 100000000 == 1}
 *     clib.delete_expression(expr)
 */
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_9genexpr13__pyx_v_k); __pyx_9genexpr13__pyx_v_k = 0;
    goto __pyx_L12_exit_scope;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_9genexpr13__pyx_v_k); __pyx_9genexpr13__pyx_v_k = 0;
    goto __pyx_L1_error;
    __pyx_L12_exit_scope:;
  } /* exit inner scope */
  __pyx_v_vars = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpymad/libmadx.pyx":954
 *             for k in [expr.polish.i[i]]
 *             if k // 100000000 == 1}
 *     clib.delete_expression(expr)             # <<<<<<<<<<<<<<
 *     return vars
 * 
 */
  (void)(delete_expression(__pyx_v_expr));

  /* "cpymad/libmadx.pyx":955
 *             if k // 100000000 == 1}
 *     clib.delete_expression(expr)
 *     return vars             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_vars);
  __pyx_r = __pyx_v_vars;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":933
 * 
 * 
 * def expression_vars(expression):             # <<<<<<<<<<<<<<
 *     """
 *     Returns all the variables in an expression.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpymad.libmadx.expression_vars", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_vars);
  __Pyx_XDECREF(__pyx_9genexpr13__pyx_v_k);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":965
 * 
 * 
 * cdef clib.expression* _make_expr(expression):             # <<<<<<<<<<<<<<
 *     # TODO: This function uses global variables as temporaries - which is in
 *     # general an *extremely* bad design choice. Even though MAD-X uses global
 */

static struct expression *__pyx_f_6cpymad_7libmadx__make_expr(PyObject *__pyx_v_expression) {
  PyObject *__pyx_v__expr = 0;
  int __pyx_v_start;
  int __pyx_v_stop;
  int __pyx_v_etype;
  struct expression *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_make_expr", 0);

  /* "cpymad/libmadx.pyx":971
 *     # behaviour.
 *     # TODO: not sure about the flags (the magic constants 0, 2)
 *     cdef bytes _expr = _cstr(expression.lower())             # <<<<<<<<<<<<<<
 *     clib.pre_split(_expr, clib.c_dum, 0)
 *     clib.mysplit(clib.c_dum.c, clib.tmp_p_array)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_expression, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v__expr = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":972
 *     # TODO: not sure about the flags (the magic constants 0, 2)
 *     cdef bytes _expr = _cstr(expression.lower())
 *     clib.pre_split(_expr, clib.c_dum, 0)             # <<<<<<<<<<<<<<
 *     clib.mysplit(clib.c_dum.c, clib.tmp_p_array)
 *     # NOTE: `loc_expr` is mostly useless for input validation. It even accepts
 */
  if (unlikely(__pyx_v__expr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 972, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyBytes_AsWritableString(__pyx_v__expr); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 972, __pyx_L1_error)
  pre_split(__pyx_t_4, c_dum, 0);

  /* "cpymad/libmadx.pyx":973
 *     cdef bytes _expr = _cstr(expression.lower())
 *     clib.pre_split(_expr, clib.c_dum, 0)
 *     clib.mysplit(clib.c_dum.c, clib.tmp_p_array)             # <<<<<<<<<<<<<<
 *     # NOTE: `loc_expr` is mostly useless for input validation. It even accepts
 *     # stuff such as '+' that will lead to program crashes on evaluation. We
 */
  (void)(mysplit(c_dum->c, tmp_p_array));

  /* "cpymad/libmadx.pyx":978
 *     # use it nevertheless to get a minimal amount of error-checking. Not using
 *     # cpymad.util.check_expression for simplicity and performance.
 *     cdef int start=0, stop             # <<<<<<<<<<<<<<
 *     etype = clib.loc_expr(clib.tmp_p_array.p,
 *                           clib.tmp_p_array.curr,
 */
  __pyx_v_start = 0;

  /* "cpymad/libmadx.pyx":979
 *     # cpymad.util.check_expression for simplicity and performance.
 *     cdef int start=0, stop
 *     etype = clib.loc_expr(clib.tmp_p_array.p,             # <<<<<<<<<<<<<<
 *                           clib.tmp_p_array.curr,
 *                           start, &stop)
 */
  __pyx_v_etype = loc_expr(tmp_p_array->p, tmp_p_array->curr, __pyx_v_start, (&__pyx_v_stop));

  /* "cpymad/libmadx.pyx":982
 *                           clib.tmp_p_array.curr,
 *                           start, &stop)
 *     if etype == 0 or stop+1 < clib.tmp_p_array.curr:             # <<<<<<<<<<<<<<
 *         return NULL
 *     return clib.make_expression(clib.tmp_p_array.curr, clib.tmp_p_array.p)
 */
  __pyx_t_6 = ((__pyx_v_etype == 0) != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = (((__pyx_v_stop + 1) < tmp_p_array->curr) != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_5) {

    /* "cpymad/libmadx.pyx":983
 *                           start, &stop)
 *     if etype == 0 or stop+1 < clib.tmp_p_array.curr:
 *         return NULL             # <<<<<<<<<<<<<<
 *     return clib.make_expression(clib.tmp_p_array.curr, clib.tmp_p_array.p)
 * 
 */
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":982
 *                           clib.tmp_p_array.curr,
 *                           start, &stop)
 *     if etype == 0 or stop+1 < clib.tmp_p_array.curr:             # <<<<<<<<<<<<<<
 *         return NULL
 *     return clib.make_expression(clib.tmp_p_array.curr, clib.tmp_p_array.p)
 */
  }

  /* "cpymad/libmadx.pyx":984
 *     if etype == 0 or stop+1 < clib.tmp_p_array.curr:
 *         return NULL
 *     return clib.make_expression(clib.tmp_p_array.curr, clib.tmp_p_array.p)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = make_expression(tmp_p_array->curr, tmp_p_array->p);
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":965
 * 
 * 
 * cdef clib.expression* _make_expr(expression):             # <<<<<<<<<<<<<<
 *     # TODO: This function uses global variables as temporaries - which is in
 *     # general an *extremely* bad design choice. Even though MAD-X uses global
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("cpymad.libmadx._make_expr", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__expr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":989
 * _expr_types = [bool, int, float]
 * 
 * cdef _expr(clib.expression* expr,             # <<<<<<<<<<<<<<
 *            double value,
 *            int typeid=clib.PARAM_TYPE_DOUBLE):
 */

static PyObject *__pyx_f_6cpymad_7libmadx__expr(struct expression *__pyx_v_expr, double __pyx_v_value, struct __pyx_opt_args_6cpymad_7libmadx__expr *__pyx_optional_args) {
  int __pyx_v_typeid = __pyx_k__9;
  PyObject *__pyx_v__type = NULL;
  PyObject *__pyx_v__value = NULL;
  PyObject *__pyx_v__expr = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("_expr", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_typeid = __pyx_optional_args->typeid;
    }
  }

  /* "cpymad/libmadx.pyx":993
 *            int typeid=clib.PARAM_TYPE_DOUBLE):
 *     """Return a parameter value with an appropriate type."""
 *     _type = _expr_types[typeid]             # <<<<<<<<<<<<<<
 *     _value = _type(value)
 *     if expr is NULL or expr.string is NULL:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_expr_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 993, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_typeid, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 993, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v__type = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":994
 *     """Return a parameter value with an appropriate type."""
 *     _type = _expr_types[typeid]
 *     _value = _type(value)             # <<<<<<<<<<<<<<
 *     if expr is NULL or expr.string is NULL:
 *         return _value, None
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v__type);
  __pyx_t_3 = __pyx_v__type; __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v__value = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":995
 *     _type = _expr_types[typeid]
 *     _value = _type(value)
 *     if expr is NULL or expr.string is NULL:             # <<<<<<<<<<<<<<
 *         return _value, None
 *     _expr = _str(expr.string).strip()
 */
  __pyx_t_6 = ((__pyx_v_expr == NULL) != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = ((__pyx_v_expr->string == NULL) != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_5) {

    /* "cpymad/libmadx.pyx":996
 *     _value = _type(value)
 *     if expr is NULL or expr.string is NULL:
 *         return _value, None             # <<<<<<<<<<<<<<
 *     _expr = _str(expr.string).strip()
 *     if not _expr:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 996, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__value);
    __Pyx_GIVEREF(__pyx_v__value);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__value);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":995
 *     _type = _expr_types[typeid]
 *     _value = _type(value)
 *     if expr is NULL or expr.string is NULL:             # <<<<<<<<<<<<<<
 *         return _value, None
 *     _expr = _str(expr.string).strip()
 */
  }

  /* "cpymad/libmadx.pyx":997
 *     if expr is NULL or expr.string is NULL:
 *         return _value, None
 *     _expr = _str(expr.string).strip()             # <<<<<<<<<<<<<<
 *     if not _expr:
 *         return _value, None
 */
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_expr->string); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v__expr = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":998
 *         return _value, None
 *     _expr = _str(expr.string).strip()
 *     if not _expr:             # <<<<<<<<<<<<<<
 *         return _value, None
 *     try:
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v__expr); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 998, __pyx_L1_error)
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (__pyx_t_6) {

    /* "cpymad/libmadx.pyx":999
 *     _expr = _str(expr.string).strip()
 *     if not _expr:
 *         return _value, None             # <<<<<<<<<<<<<<
 *     try:
 *         return _type(float(_expr)), None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 999, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__value);
    __Pyx_GIVEREF(__pyx_v__value);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__value);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":998
 *         return _value, None
 *     _expr = _str(expr.string).strip()
 *     if not _expr:             # <<<<<<<<<<<<<<
 *         return _value, None
 *     try:
 */
  }

  /* "cpymad/libmadx.pyx":1000
 *     if not _expr:
 *         return _value, None
 *     try:             # <<<<<<<<<<<<<<
 *         return _type(float(_expr)), None
 *     except ValueError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "cpymad/libmadx.pyx":1001
 *         return _value, None
 *     try:
 *         return _type(float(_expr)), None             # <<<<<<<<<<<<<<
 *     except ValueError:
 *         pass
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyNumber_Float(__pyx_v__expr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1001, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v__type);
      __pyx_t_3 = __pyx_v__type; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1001, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1001, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_3, 1, Py_None);
      __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L11_try_return;

      /* "cpymad/libmadx.pyx":1000
 *     if not _expr:
 *         return _value, None
 *     try:             # <<<<<<<<<<<<<<
 *         return _type(float(_expr)), None
 *     except ValueError:
 */
    }
    __pyx_L7_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":1002
 *     try:
 *         return _type(float(_expr)), None
 *     except ValueError:             # <<<<<<<<<<<<<<
 *         pass
 *     value = clib.expression_value(expr, 2)
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
    if (__pyx_t_10) {
      __Pyx_ErrRestore(0,0,0);
      goto __pyx_L8_exception_handled;
    }
    goto __pyx_L9_except_error;
    __pyx_L9_except_error:;

    /* "cpymad/libmadx.pyx":1000
 *     if not _expr:
 *         return _value, None
 *     try:             # <<<<<<<<<<<<<<
 *         return _type(float(_expr)), None
 *     except ValueError:
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L11_try_return:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L0;
    __pyx_L8_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  }

  /* "cpymad/libmadx.pyx":1004
 *     except ValueError:
 *         pass
 *     value = clib.expression_value(expr, 2)             # <<<<<<<<<<<<<<
 *     return _type(value), _expr
 * 
 */
  __pyx_v_value = expression_value(__pyx_v_expr, 2);

  /* "cpymad/libmadx.pyx":1005
 *         pass
 *     value = clib.expression_value(expr, 2)
 *     return _type(value), _expr             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v__type);
  __pyx_t_1 = __pyx_v__type; __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_v__expr);
  __Pyx_GIVEREF(__pyx_v__expr);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v__expr);
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":989
 * _expr_types = [bool, int, float]
 * 
 * cdef _expr(clib.expression* expr,             # <<<<<<<<<<<<<<
 *            double value,
 *            int typeid=clib.PARAM_TYPE_DOUBLE):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpymad.libmadx._expr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__type);
  __Pyx_XDECREF(__pyx_v__value);
  __Pyx_XDECREF(__pyx_v__expr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1008
 * 
 * 
 * cdef _get_param_value(clib.command_parameter* par):             # <<<<<<<<<<<<<<
 * 
 *     """
 */

static PyObject *__pyx_f_6cpymad_7libmadx__get_param_value(struct command_parameter *__pyx_v_par) {
  PyObject *__pyx_v_val = NULL;
  PyObject *__pyx_v_min = NULL;
  PyObject *__pyx_v_max = NULL;
  PyObject *__pyx_v_fields = NULL;
  int __pyx_9genexpr14__pyx_v_i;
  PyObject *__pyx_9genexpr15__pyx_v_f = NULL;
  PyObject *__pyx_9genexpr16__pyx_v_f = NULL;
  int __pyx_9genexpr17__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_6cpymad_7libmadx__expr __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  void *__pyx_t_10;
  Py_ssize_t __pyx_t_11;
  __Pyx_RefNannySetupContext("_get_param_value", 0);

  /* "cpymad/libmadx.pyx":1018
 *     """
 * 
 *     if par.type in (clib.PARAM_TYPE_LOGICAL,             # <<<<<<<<<<<<<<
 *                     clib.PARAM_TYPE_INTEGER,
 *                     clib.PARAM_TYPE_DOUBLE):
 */
  switch (__pyx_v_par->type) {
    case __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_LOGICAL:
    case __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_INTEGER:

    /* "cpymad/libmadx.pyx":1019
 * 
 *     if par.type in (clib.PARAM_TYPE_LOGICAL,
 *                     clib.PARAM_TYPE_INTEGER,             # <<<<<<<<<<<<<<
 *                     clib.PARAM_TYPE_DOUBLE):
 *         return _expr(par.expr, par.double_value, par.type)
 */
    case __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_DOUBLE:

    /* "cpymad/libmadx.pyx":1021
 *                     clib.PARAM_TYPE_INTEGER,
 *                     clib.PARAM_TYPE_DOUBLE):
 *         return _expr(par.expr, par.double_value, par.type)             # <<<<<<<<<<<<<<
 * 
 *     if par.type == clib.PARAM_TYPE_STRING:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2.__pyx_n = 1;
    __pyx_t_2.typeid = __pyx_v_par->type;
    __pyx_t_1 = __pyx_f_6cpymad_7libmadx__expr(__pyx_v_par->expr, __pyx_v_par->double_value, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1018
 *     """
 * 
 *     if par.type in (clib.PARAM_TYPE_LOGICAL,             # <<<<<<<<<<<<<<
 *                     clib.PARAM_TYPE_INTEGER,
 *                     clib.PARAM_TYPE_DOUBLE):
 */
    break;
    default: break;
  }

  /* "cpymad/libmadx.pyx":1023
 *         return _expr(par.expr, par.double_value, par.type)
 * 
 *     if par.type == clib.PARAM_TYPE_STRING:             # <<<<<<<<<<<<<<
 *         return _str(par.string), None
 * 
 */
  __pyx_t_3 = ((__pyx_v_par->type == __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_STRING) != 0);
  if (__pyx_t_3) {

    /* "cpymad/libmadx.pyx":1024
 * 
 *     if par.type == clib.PARAM_TYPE_STRING:
 *         return _str(par.string), None             # <<<<<<<<<<<<<<
 * 
 *     if par.type == clib.PARAM_TYPE_CONSTRAINT:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_par->string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_4, 1, Py_None);
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1023
 *         return _expr(par.expr, par.double_value, par.type)
 * 
 *     if par.type == clib.PARAM_TYPE_STRING:             # <<<<<<<<<<<<<<
 *         return _str(par.string), None
 * 
 */
  }

  /* "cpymad/libmadx.pyx":1026
 *         return _str(par.string), None
 * 
 *     if par.type == clib.PARAM_TYPE_CONSTRAINT:             # <<<<<<<<<<<<<<
 *         val = min = max = (None, None)
 *         if par.c_type == clib.CONSTR_TYPE_NONE: # occurs in defined_commands
 */
  __pyx_t_3 = ((__pyx_v_par->type == __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_CONSTRAINT) != 0);
  if (__pyx_t_3) {

    /* "cpymad/libmadx.pyx":1027
 * 
 *     if par.type == clib.PARAM_TYPE_CONSTRAINT:
 *         val = min = max = (None, None)             # <<<<<<<<<<<<<<
 *         if par.c_type == clib.CONSTR_TYPE_NONE: # occurs in defined_commands
 *             pass
 */
    __Pyx_INCREF(__pyx_tuple__10);
    __pyx_v_val = __pyx_tuple__10;
    __Pyx_INCREF(__pyx_tuple__10);
    __pyx_v_min = __pyx_tuple__10;
    __Pyx_INCREF(__pyx_tuple__10);
    __pyx_v_max = __pyx_tuple__10;

    /* "cpymad/libmadx.pyx":1028
 *     if par.type == clib.PARAM_TYPE_CONSTRAINT:
 *         val = min = max = (None, None)
 *         if par.c_type == clib.CONSTR_TYPE_NONE: # occurs in defined_commands             # <<<<<<<<<<<<<<
 *             pass
 *         if par.c_type == clib.CONSTR_TYPE_MIN:
 */
    __pyx_t_3 = ((__pyx_v_par->c_type == __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_NONE) != 0);
    if (__pyx_t_3) {
    }

    /* "cpymad/libmadx.pyx":1030
 *         if par.c_type == clib.CONSTR_TYPE_NONE: # occurs in defined_commands
 *             pass
 *         if par.c_type == clib.CONSTR_TYPE_MIN:             # <<<<<<<<<<<<<<
 *             min = _expr(par.min_expr, par.c_min)
 *         if par.c_type == clib.CONSTR_TYPE_MAX:
 */
    __pyx_t_3 = ((__pyx_v_par->c_type == __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_MIN) != 0);
    if (__pyx_t_3) {

      /* "cpymad/libmadx.pyx":1031
 *             pass
 *         if par.c_type == clib.CONSTR_TYPE_MIN:
 *             min = _expr(par.min_expr, par.c_min)             # <<<<<<<<<<<<<<
 *         if par.c_type == clib.CONSTR_TYPE_MAX:
 *             max = _expr(par.max_expr, par.c_max)
 */
      __pyx_t_4 = __pyx_f_6cpymad_7libmadx__expr(__pyx_v_par->min_expr, __pyx_v_par->c_min, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1031, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_min, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cpymad/libmadx.pyx":1030
 *         if par.c_type == clib.CONSTR_TYPE_NONE: # occurs in defined_commands
 *             pass
 *         if par.c_type == clib.CONSTR_TYPE_MIN:             # <<<<<<<<<<<<<<
 *             min = _expr(par.min_expr, par.c_min)
 *         if par.c_type == clib.CONSTR_TYPE_MAX:
 */
    }

    /* "cpymad/libmadx.pyx":1032
 *         if par.c_type == clib.CONSTR_TYPE_MIN:
 *             min = _expr(par.min_expr, par.c_min)
 *         if par.c_type == clib.CONSTR_TYPE_MAX:             # <<<<<<<<<<<<<<
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_BOTH:
 */
    __pyx_t_3 = ((__pyx_v_par->c_type == __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_MAX) != 0);
    if (__pyx_t_3) {

      /* "cpymad/libmadx.pyx":1033
 *             min = _expr(par.min_expr, par.c_min)
 *         if par.c_type == clib.CONSTR_TYPE_MAX:
 *             max = _expr(par.max_expr, par.c_max)             # <<<<<<<<<<<<<<
 *         if par.c_type == clib.CONSTR_TYPE_BOTH:
 *             min = _expr(par.min_expr, par.c_min)
 */
      __pyx_t_4 = __pyx_f_6cpymad_7libmadx__expr(__pyx_v_par->max_expr, __pyx_v_par->c_max, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1033, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_max, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cpymad/libmadx.pyx":1032
 *         if par.c_type == clib.CONSTR_TYPE_MIN:
 *             min = _expr(par.min_expr, par.c_min)
 *         if par.c_type == clib.CONSTR_TYPE_MAX:             # <<<<<<<<<<<<<<
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_BOTH:
 */
    }

    /* "cpymad/libmadx.pyx":1034
 *         if par.c_type == clib.CONSTR_TYPE_MAX:
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_BOTH:             # <<<<<<<<<<<<<<
 *             min = _expr(par.min_expr, par.c_min)
 *             max = _expr(par.max_expr, par.c_max)
 */
    __pyx_t_3 = ((__pyx_v_par->c_type == __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_BOTH) != 0);
    if (__pyx_t_3) {

      /* "cpymad/libmadx.pyx":1035
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_BOTH:
 *             min = _expr(par.min_expr, par.c_min)             # <<<<<<<<<<<<<<
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_VALUE:
 */
      __pyx_t_4 = __pyx_f_6cpymad_7libmadx__expr(__pyx_v_par->min_expr, __pyx_v_par->c_min, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1035, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_min, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cpymad/libmadx.pyx":1036
 *         if par.c_type == clib.CONSTR_TYPE_BOTH:
 *             min = _expr(par.min_expr, par.c_min)
 *             max = _expr(par.max_expr, par.c_max)             # <<<<<<<<<<<<<<
 *         if par.c_type == clib.CONSTR_TYPE_VALUE:
 *             val = _expr(par.expr, par.double_value)
 */
      __pyx_t_4 = __pyx_f_6cpymad_7libmadx__expr(__pyx_v_par->max_expr, __pyx_v_par->c_max, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1036, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_max, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cpymad/libmadx.pyx":1034
 *         if par.c_type == clib.CONSTR_TYPE_MAX:
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_BOTH:             # <<<<<<<<<<<<<<
 *             min = _expr(par.min_expr, par.c_min)
 *             max = _expr(par.max_expr, par.c_max)
 */
    }

    /* "cpymad/libmadx.pyx":1037
 *             min = _expr(par.min_expr, par.c_min)
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_VALUE:             # <<<<<<<<<<<<<<
 *             val = _expr(par.expr, par.double_value)
 *         return (Constraint(val=val[0], min=min[0], max=max[0]),
 */
    __pyx_t_3 = ((__pyx_v_par->c_type == __pyx_e_6cpymad_8clibmadx_CONSTR_TYPE_VALUE) != 0);
    if (__pyx_t_3) {

      /* "cpymad/libmadx.pyx":1038
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_VALUE:
 *             val = _expr(par.expr, par.double_value)             # <<<<<<<<<<<<<<
 *         return (Constraint(val=val[0], min=min[0], max=max[0]),
 *                 Constraint(val=val[1], min=min[1], max=max[1]))
 */
      __pyx_t_4 = __pyx_f_6cpymad_7libmadx__expr(__pyx_v_par->expr, __pyx_v_par->double_value, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1038, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_val, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cpymad/libmadx.pyx":1037
 *             min = _expr(par.min_expr, par.c_min)
 *             max = _expr(par.max_expr, par.c_max)
 *         if par.c_type == clib.CONSTR_TYPE_VALUE:             # <<<<<<<<<<<<<<
 *             val = _expr(par.expr, par.double_value)
 *         return (Constraint(val=val[0], min=min[0], max=max[0]),
 */
    }

    /* "cpymad/libmadx.pyx":1039
 *         if par.c_type == clib.CONSTR_TYPE_VALUE:
 *             val = _expr(par.expr, par.double_value)
 *         return (Constraint(val=val[0], min=min[0], max=max[0]),             # <<<<<<<<<<<<<<
 *                 Constraint(val=val[1], min=min[1], max=max[1]))
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Constraint); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_val, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_val, __pyx_t_5) < 0) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_min, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_min, __pyx_t_5) < 0) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_max, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max, __pyx_t_5) < 0) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cpymad/libmadx.pyx":1040
 *             val = _expr(par.expr, par.double_value)
 *         return (Constraint(val=val[0], min=min[0], max=max[0]),
 *                 Constraint(val=val[1], min=min[1], max=max[1]))             # <<<<<<<<<<<<<<
 * 
 *     if par.type in (clib.PARAM_TYPE_INTEGER_ARRAY, clib.PARAM_TYPE_DOUBLE_ARRAY):
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Constraint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_val, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_val, __pyx_t_6) < 0) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_min, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_min, __pyx_t_6) < 0) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_max, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_max, __pyx_t_6) < 0) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":1039
 *         if par.c_type == clib.CONSTR_TYPE_VALUE:
 *             val = _expr(par.expr, par.double_value)
 *         return (Constraint(val=val[0], min=min[0], max=max[0]),             # <<<<<<<<<<<<<<
 *                 Constraint(val=val[1], min=min[1], max=max[1]))
 * 
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1026
 *         return _str(par.string), None
 * 
 *     if par.type == clib.PARAM_TYPE_CONSTRAINT:             # <<<<<<<<<<<<<<
 *         val = min = max = (None, None)
 *         if par.c_type == clib.CONSTR_TYPE_NONE: # occurs in defined_commands
 */
  }

  /* "cpymad/libmadx.pyx":1042
 *                 Constraint(val=val[1], min=min[1], max=max[1]))
 * 
 *     if par.type in (clib.PARAM_TYPE_INTEGER_ARRAY, clib.PARAM_TYPE_DOUBLE_ARRAY):             # <<<<<<<<<<<<<<
 *         fields = [
 *             _expr(NULL if par.expr_list is NULL else par.expr_list.list[i],
 */
  switch (__pyx_v_par->type) {
    case __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_INTEGER_ARRAY:
    case __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_DOUBLE_ARRAY:

    /* "cpymad/libmadx.pyx":1043
 * 
 *     if par.type in (clib.PARAM_TYPE_INTEGER_ARRAY, clib.PARAM_TYPE_DOUBLE_ARRAY):
 *         fields = [             # <<<<<<<<<<<<<<
 *             _expr(NULL if par.expr_list is NULL else par.expr_list.list[i],
 *                   par.double_array.a[i],
 */
    { /* enter inner scope */
      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1043, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);

      /* "cpymad/libmadx.pyx":1047
 *                   par.double_array.a[i],
 *                   par.type - clib.PARAM_TYPE_LOGICAL_ARRAY)
 *             for i in range(par.double_array.curr)             # <<<<<<<<<<<<<<
 *         ]
 *         return ([f[0] for f in fields],
 */
      __pyx_t_7 = __pyx_v_par->double_array->curr;
      __pyx_t_8 = __pyx_t_7;
      for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
        __pyx_9genexpr14__pyx_v_i = __pyx_t_9;

        /* "cpymad/libmadx.pyx":1044
 *     if par.type in (clib.PARAM_TYPE_INTEGER_ARRAY, clib.PARAM_TYPE_DOUBLE_ARRAY):
 *         fields = [
 *             _expr(NULL if par.expr_list is NULL else par.expr_list.list[i],             # <<<<<<<<<<<<<<
 *                   par.double_array.a[i],
 *                   par.type - clib.PARAM_TYPE_LOGICAL_ARRAY)
 */
        if (((__pyx_v_par->expr_list == NULL) != 0)) {
          __pyx_t_10 = NULL;
        } else {
          __pyx_t_10 = (__pyx_v_par->expr_list->list[__pyx_9genexpr14__pyx_v_i]);
        }

        /* "cpymad/libmadx.pyx":1046
 *             _expr(NULL if par.expr_list is NULL else par.expr_list.list[i],
 *                   par.double_array.a[i],
 *                   par.type - clib.PARAM_TYPE_LOGICAL_ARRAY)             # <<<<<<<<<<<<<<
 *             for i in range(par.double_array.curr)
 *         ]
 */
        __pyx_t_2.__pyx_n = 1;
        __pyx_t_2.typeid = (__pyx_v_par->type - __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_LOGICAL_ARRAY);
        __pyx_t_6 = __pyx_f_6cpymad_7libmadx__expr(__pyx_t_10, (__pyx_v_par->double_array->a[__pyx_9genexpr14__pyx_v_i]), &__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1044, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 1043, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    } /* exit inner scope */
    __pyx_v_fields = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":1049
 *             for i in range(par.double_array.curr)
 *         ]
 *         return ([f[0] for f in fields],             # <<<<<<<<<<<<<<
 *                 [f[1] for f in fields])
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    { /* enter inner scope */
      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1049, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_6); __pyx_t_11 = 0;
      for (;;) {
        if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_11); __Pyx_INCREF(__pyx_t_5); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 1049, __pyx_L14_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1049, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
        __Pyx_XDECREF_SET(__pyx_9genexpr15__pyx_v_f, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_GetItemInt(__pyx_9genexpr15__pyx_v_f, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1049, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 1049, __pyx_L14_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_9genexpr15__pyx_v_f); __pyx_9genexpr15__pyx_v_f = 0;
      goto __pyx_L17_exit_scope;
      __pyx_L14_error:;
      __Pyx_XDECREF(__pyx_9genexpr15__pyx_v_f); __pyx_9genexpr15__pyx_v_f = 0;
      goto __pyx_L1_error;
      __pyx_L17_exit_scope:;
    } /* exit inner scope */
    { /* enter inner scope */

      /* "cpymad/libmadx.pyx":1050
 *         ]
 *         return ([f[0] for f in fields],
 *                 [f[1] for f in fields])             # <<<<<<<<<<<<<<
 * 
 *     if par.type == clib.PARAM_TYPE_STRING_ARRAY:
 */
      __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1050, __pyx_L20_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_5); __pyx_t_11 = 0;
      for (;;) {
        if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 1050, __pyx_L20_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1050, __pyx_L20_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_XDECREF_SET(__pyx_9genexpr16__pyx_v_f, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_9genexpr16__pyx_v_f, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1050, __pyx_L20_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1050, __pyx_L20_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_9genexpr16__pyx_v_f); __pyx_9genexpr16__pyx_v_f = 0;
      goto __pyx_L23_exit_scope;
      __pyx_L20_error:;
      __Pyx_XDECREF(__pyx_9genexpr16__pyx_v_f); __pyx_9genexpr16__pyx_v_f = 0;
      goto __pyx_L1_error;
      __pyx_L23_exit_scope:;
    } /* exit inner scope */

    /* "cpymad/libmadx.pyx":1049
 *             for i in range(par.double_array.curr)
 *         ]
 *         return ([f[0] for f in fields],             # <<<<<<<<<<<<<<
 *                 [f[1] for f in fields])
 * 
 */
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
    __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1042
 *                 Constraint(val=val[1], min=min[1], max=max[1]))
 * 
 *     if par.type in (clib.PARAM_TYPE_INTEGER_ARRAY, clib.PARAM_TYPE_DOUBLE_ARRAY):             # <<<<<<<<<<<<<<
 *         fields = [
 *             _expr(NULL if par.expr_list is NULL else par.expr_list.list[i],
 */
    break;
    default: break;
  }

  /* "cpymad/libmadx.pyx":1052
 *                 [f[1] for f in fields])
 * 
 *     if par.type == clib.PARAM_TYPE_STRING_ARRAY:             # <<<<<<<<<<<<<<
 *         return [_str(par.m_string.p[i])
 *                 for i in range(par.m_string.curr)], None
 */
  __pyx_t_3 = ((__pyx_v_par->type == __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_STRING_ARRAY) != 0);
  if (__pyx_t_3) {

    /* "cpymad/libmadx.pyx":1053
 * 
 *     if par.type == clib.PARAM_TYPE_STRING_ARRAY:
 *         return [_str(par.m_string.p[i])             # <<<<<<<<<<<<<<
 *                 for i in range(par.m_string.curr)], None
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    { /* enter inner scope */
      __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1053, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "cpymad/libmadx.pyx":1054
 *     if par.type == clib.PARAM_TYPE_STRING_ARRAY:
 *         return [_str(par.m_string.p[i])
 *                 for i in range(par.m_string.curr)], None             # <<<<<<<<<<<<<<
 * 
 *     raise ValueError("Unknown parameter type: {}".format(par.type))
 */
      __pyx_t_7 = __pyx_v_par->m_string->curr;
      __pyx_t_8 = __pyx_t_7;
      for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
        __pyx_9genexpr17__pyx_v_i = __pyx_t_9;

        /* "cpymad/libmadx.pyx":1053
 * 
 *     if par.type == clib.PARAM_TYPE_STRING_ARRAY:
 *         return [_str(par.m_string.p[i])             # <<<<<<<<<<<<<<
 *                 for i in range(par.m_string.curr)], None
 * 
 */
        __pyx_t_6 = __pyx_f_6cpymad_7libmadx__str((__pyx_v_par->m_string->p[__pyx_9genexpr17__pyx_v_i])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1053, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 1053, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    } /* exit inner scope */

    /* "cpymad/libmadx.pyx":1054
 *     if par.type == clib.PARAM_TYPE_STRING_ARRAY:
 *         return [_str(par.m_string.p[i])
 *                 for i in range(par.m_string.curr)], None             # <<<<<<<<<<<<<<
 * 
 *     raise ValueError("Unknown parameter type: {}".format(par.type))
 */
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1053, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_6, 1, Py_None);
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1052
 *                 [f[1] for f in fields])
 * 
 *     if par.type == clib.PARAM_TYPE_STRING_ARRAY:             # <<<<<<<<<<<<<<
 *         return [_str(par.m_string.p[i])
 *                 for i in range(par.m_string.curr)], None
 */
  }

  /* "cpymad/libmadx.pyx":1056
 *                 for i in range(par.m_string.curr)], None
 * 
 *     raise ValueError("Unknown parameter type: {}".format(par.type))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Unknown_parameter_type, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_par->type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __PYX_ERR(0, 1056, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":1008
 * 
 * 
 * cdef _get_param_value(clib.command_parameter* par):             # <<<<<<<<<<<<<<
 * 
 *     """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpymad.libmadx._get_param_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XDECREF(__pyx_v_min);
  __Pyx_XDECREF(__pyx_v_max);
  __Pyx_XDECREF(__pyx_v_fields);
  __Pyx_XDECREF(__pyx_9genexpr15__pyx_v_f);
  __Pyx_XDECREF(__pyx_9genexpr16__pyx_v_f);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1059
 * 
 * 
 * cdef _parse_command(clib.command* cmd):             # <<<<<<<<<<<<<<
 *     """
 *     Get the values of all parameters of a command.
 */

static PyObject *__pyx_f_6cpymad_7libmadx__parse_command(struct command *__pyx_v_cmd) {
  int __pyx_9genexpr18__pyx_v_i;
  PyObject *__pyx_9genexpr18__pyx_v_name = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_parse_command", 0);

  /* "cpymad/libmadx.pyx":1067
 *     """
 *     cdef int i
 *     return {'name': _str(cmd.name), 'data': {             # <<<<<<<<<<<<<<
 *         # enforce lower-case keys:
 *         name: Parameter(
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1067, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_cmd->name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1067, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_name, __pyx_t_2) < 0) __PYX_ERR(0, 1067, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  { /* enter inner scope */
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1067, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cpymad/libmadx.pyx":1074
 *             dtype=cmd.par.parameters[i].type,
 *             inform=cmd.par_names.inform[i])
 *         for i in range(cmd.par.curr)             # <<<<<<<<<<<<<<
 *         for name in [_str(cmd.par.parameters[i].name).lower()]
 *     }}
 */
    __pyx_t_3 = __pyx_v_cmd->par->curr;
    __pyx_t_4 = __pyx_t_3;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_9genexpr18__pyx_v_i = __pyx_t_5;

      /* "cpymad/libmadx.pyx":1075
 *             inform=cmd.par_names.inform[i])
 *         for i in range(cmd.par.curr)
 *         for name in [_str(cmd.par.parameters[i].name).lower()]             # <<<<<<<<<<<<<<
 *     }}
 * 
 */
      __pyx_t_7 = __pyx_f_6cpymad_7libmadx__str((__pyx_v_cmd->par->parameters[__pyx_9genexpr18__pyx_v_i])->name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1075, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_lower); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1075, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1075, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1075, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __pyx_t_8; __Pyx_INCREF(__pyx_t_6); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      for (;;) {
        if (__pyx_t_9 >= 1) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1075, __pyx_L5_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1075, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_XDECREF_SET(__pyx_9genexpr18__pyx_v_name, __pyx_t_8);
        __pyx_t_8 = 0;

        /* "cpymad/libmadx.pyx":1069
 *     return {'name': _str(cmd.name), 'data': {
 *         # enforce lower-case keys:
 *         name: Parameter(             # <<<<<<<<<<<<<<
 *             name,
 *             *_get_param_value(cmd.par.parameters[i]),
 */
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_Parameter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1069, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_8);

        /* "cpymad/libmadx.pyx":1070
 *         # enforce lower-case keys:
 *         name: Parameter(
 *             name,             # <<<<<<<<<<<<<<
 *             *_get_param_value(cmd.par.parameters[i]),
 *             dtype=cmd.par.parameters[i].type,
 */
        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1069, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_9genexpr18__pyx_v_name);
        __Pyx_GIVEREF(__pyx_9genexpr18__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_9genexpr18__pyx_v_name);

        /* "cpymad/libmadx.pyx":1071
 *         name: Parameter(
 *             name,
 *             *_get_param_value(cmd.par.parameters[i]),             # <<<<<<<<<<<<<<
 *             dtype=cmd.par.parameters[i].type,
 *             inform=cmd.par_names.inform[i])
 */
        __pyx_t_10 = __pyx_f_6cpymad_7libmadx__get_param_value((__pyx_v_cmd->par->parameters[__pyx_9genexpr18__pyx_v_i])); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1071, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);

        /* "cpymad/libmadx.pyx":1069
 *     return {'name': _str(cmd.name), 'data': {
 *         # enforce lower-case keys:
 *         name: Parameter(             # <<<<<<<<<<<<<<
 *             name,
 *             *_get_param_value(cmd.par.parameters[i]),
 */
        __pyx_t_11 = __Pyx_PySequence_Tuple(__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1069, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = PyNumber_Add(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1069, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "cpymad/libmadx.pyx":1072
 *             name,
 *             *_get_param_value(cmd.par.parameters[i]),
 *             dtype=cmd.par.parameters[i].type,             # <<<<<<<<<<<<<<
 *             inform=cmd.par_names.inform[i])
 *         for i in range(cmd.par.curr)
 */
        __pyx_t_11 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1072, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_7 = __Pyx_PyInt_From_int((__pyx_v_cmd->par->parameters[__pyx_9genexpr18__pyx_v_i])->type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1072, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 1072, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cpymad/libmadx.pyx":1073
 *             *_get_param_value(cmd.par.parameters[i]),
 *             dtype=cmd.par.parameters[i].type,
 *             inform=cmd.par_names.inform[i])             # <<<<<<<<<<<<<<
 *         for i in range(cmd.par.curr)
 *         for name in [_str(cmd.par.parameters[i].name).lower()]
 */
        __pyx_t_7 = __Pyx_PyInt_From_int((__pyx_v_cmd->par_names->inform[__pyx_9genexpr18__pyx_v_i])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1073, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_inform, __pyx_t_7) < 0) __PYX_ERR(0, 1072, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cpymad/libmadx.pyx":1069
 *     return {'name': _str(cmd.name), 'data': {
 *         # enforce lower-case keys:
 *         name: Parameter(             # <<<<<<<<<<<<<<
 *             name,
 *             *_get_param_value(cmd.par.parameters[i]),
 */
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1069, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_9genexpr18__pyx_v_name, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 1069, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cpymad/libmadx.pyx":1075
 *             inform=cmd.par_names.inform[i])
 *         for i in range(cmd.par.curr)
 *         for name in [_str(cmd.par.parameters[i].name).lower()]             # <<<<<<<<<<<<<<
 *     }}
 * 
 */
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_XDECREF(__pyx_9genexpr18__pyx_v_name); __pyx_9genexpr18__pyx_v_name = 0;
    goto __pyx_L10_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_9genexpr18__pyx_v_name); __pyx_9genexpr18__pyx_v_name = 0;
    goto __pyx_L1_error;
    __pyx_L10_exit_scope:;
  } /* exit inner scope */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_data, __pyx_t_2) < 0) __PYX_ERR(0, 1067, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1059
 * 
 * 
 * cdef _parse_command(clib.command* cmd):             # <<<<<<<<<<<<<<
 *     """
 *     Get the values of all parameters of a command.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cpymad.libmadx._parse_command", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_9genexpr18__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1082
 * # functions with C return values, see:
 * # http://docs.cython.org/src/userguide/language_basics.html#error-return-values
 * cdef clib.sequence* _find_sequence(sequence_name) except NULL:             # <<<<<<<<<<<<<<
 *     """
 *     Get pointer to the C sequence struct of the specified sequence or NULL.
 */

static struct sequence *__pyx_f_6cpymad_7libmadx__find_sequence(PyObject *__pyx_v_sequence_name) {
  PyObject *__pyx_v__sequence_name = 0;
  struct sequence_list *__pyx_v_seqs;
  int __pyx_v_index;
  struct sequence *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_find_sequence", 0);

  /* "cpymad/libmadx.pyx":1089
 *     :raises ValueError: if the sequence can not be found
 *     """
 *     cdef bytes _sequence_name = _cstr(sequence_name)             # <<<<<<<<<<<<<<
 *     cdef clib.sequence_list* seqs = clib.madextern_get_sequence_list()
 *     cdef int index = clib.name_list_pos(_sequence_name, seqs.list)
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_sequence_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__sequence_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":1090
 *     """
 *     cdef bytes _sequence_name = _cstr(sequence_name)
 *     cdef clib.sequence_list* seqs = clib.madextern_get_sequence_list()             # <<<<<<<<<<<<<<
 *     cdef int index = clib.name_list_pos(_sequence_name, seqs.list)
 *     if index == -1:
 */
  __pyx_v_seqs = madextern_get_sequence_list();

  /* "cpymad/libmadx.pyx":1091
 *     cdef bytes _sequence_name = _cstr(sequence_name)
 *     cdef clib.sequence_list* seqs = clib.madextern_get_sequence_list()
 *     cdef int index = clib.name_list_pos(_sequence_name, seqs.list)             # <<<<<<<<<<<<<<
 *     if index == -1:
 *         raise ValueError("Invalid sequence: {!r}".format(sequence_name))
 */
  if (unlikely(__pyx_v__sequence_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1091, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v__sequence_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 1091, __pyx_L1_error)
  __pyx_v_index = name_list_pos(__pyx_t_2, __pyx_v_seqs->list);

  /* "cpymad/libmadx.pyx":1092
 *     cdef clib.sequence_list* seqs = clib.madextern_get_sequence_list()
 *     cdef int index = clib.name_list_pos(_sequence_name, seqs.list)
 *     if index == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid sequence: {!r}".format(sequence_name))
 *     return seqs.sequs[index]
 */
  __pyx_t_3 = ((__pyx_v_index == -1L) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "cpymad/libmadx.pyx":1093
 *     cdef int index = clib.name_list_pos(_sequence_name, seqs.list)
 *     if index == -1:
 *         raise ValueError("Invalid sequence: {!r}".format(sequence_name))             # <<<<<<<<<<<<<<
 *     return seqs.sequs[index]
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Invalid_sequence_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1093, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_sequence_name) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_sequence_name);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1093, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1093, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1093, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":1092
 *     cdef clib.sequence_list* seqs = clib.madextern_get_sequence_list()
 *     cdef int index = clib.name_list_pos(_sequence_name, seqs.list)
 *     if index == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid sequence: {!r}".format(sequence_name))
 *     return seqs.sequs[index]
 */
  }

  /* "cpymad/libmadx.pyx":1094
 *     if index == -1:
 *         raise ValueError("Invalid sequence: {!r}".format(sequence_name))
 *     return seqs.sequs[index]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (__pyx_v_seqs->sequs[__pyx_v_index]);
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1082
 * # functions with C return values, see:
 * # http://docs.cython.org/src/userguide/language_basics.html#error-return-values
 * cdef clib.sequence* _find_sequence(sequence_name) except NULL:             # <<<<<<<<<<<<<<
 *     """
 *     Get pointer to the C sequence struct of the specified sequence or NULL.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx._find_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__sequence_name);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1097
 * 
 * 
 * cdef clib.table* _find_table(table_name) except NULL:             # <<<<<<<<<<<<<<
 *     cdef bytes _table_name = _cstr(table_name)
 *     cdef int index = clib.name_list_pos(_table_name, clib.table_register.names)
 */

static struct table *__pyx_f_6cpymad_7libmadx__find_table(PyObject *__pyx_v_table_name) {
  PyObject *__pyx_v__table_name = 0;
  int __pyx_v_index;
  struct table *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_find_table", 0);

  /* "cpymad/libmadx.pyx":1098
 * 
 * cdef clib.table* _find_table(table_name) except NULL:
 *     cdef bytes _table_name = _cstr(table_name)             # <<<<<<<<<<<<<<
 *     cdef int index = clib.name_list_pos(_table_name, clib.table_register.names)
 *     if index == -1:
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_v_table_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1098, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__table_name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":1099
 * cdef clib.table* _find_table(table_name) except NULL:
 *     cdef bytes _table_name = _cstr(table_name)
 *     cdef int index = clib.name_list_pos(_table_name, clib.table_register.names)             # <<<<<<<<<<<<<<
 *     if index == -1:
 *         raise ValueError("Invalid table: {!r}".format(table_name))
 */
  if (unlikely(__pyx_v__table_name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1099, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v__table_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 1099, __pyx_L1_error)
  __pyx_v_index = name_list_pos(__pyx_t_2, table_register->names);

  /* "cpymad/libmadx.pyx":1100
 *     cdef bytes _table_name = _cstr(table_name)
 *     cdef int index = clib.name_list_pos(_table_name, clib.table_register.names)
 *     if index == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid table: {!r}".format(table_name))
 *     return clib.table_register.tables[index]
 */
  __pyx_t_3 = ((__pyx_v_index == -1L) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "cpymad/libmadx.pyx":1101
 *     cdef int index = clib.name_list_pos(_table_name, clib.table_register.names)
 *     if index == -1:
 *         raise ValueError("Invalid table: {!r}".format(table_name))             # <<<<<<<<<<<<<<
 *     return clib.table_register.tables[index]
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Invalid_table_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1101, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_table_name) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_table_name);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1101, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1101, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1101, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":1100
 *     cdef bytes _table_name = _cstr(table_name)
 *     cdef int index = clib.name_list_pos(_table_name, clib.table_register.names)
 *     if index == -1:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid table: {!r}".format(table_name))
 *     return clib.table_register.tables[index]
 */
  }

  /* "cpymad/libmadx.pyx":1102
 *     if index == -1:
 *         raise ValueError("Invalid table: {!r}".format(table_name))
 *     return clib.table_register.tables[index]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (table_register->tables[__pyx_v_index]);
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1097
 * 
 * 
 * cdef clib.table* _find_table(table_name) except NULL:             # <<<<<<<<<<<<<<
 *     cdef bytes _table_name = _cstr(table_name)
 *     cdef int index = clib.name_list_pos(_table_name, clib.table_register.names)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx._find_table", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__table_name);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1105
 * 
 * 
 * cdef _split_header_line(header_line):             # <<<<<<<<<<<<<<
 *     """Parse a table header value."""
 *     _, key, kind, value = _str(header_line).split(None, 3)
 */

static PyObject *__pyx_f_6cpymad_7libmadx__split_header_line(PyObject *__pyx_v_header_line) {
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_kind = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("_split_header_line", 0);

  /* "cpymad/libmadx.pyx":1107
 * cdef _split_header_line(header_line):
 *     """Parse a table header value."""
 *     _, key, kind, value = _str(header_line).split(None, 3)             # <<<<<<<<<<<<<<
 *     key = key.lower()
 *     if kind == "%le":
 */
  __pyx_t_1 = __Pyx_PyObject_AsString(__pyx_v_header_line); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 1107, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__str(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1107, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 1107, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6};
    __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_8(__pyx_t_7); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 4) < 0) __PYX_ERR(0, 1107, __pyx_L1_error)
    __pyx_t_8 = NULL;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1107, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v__ = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_key = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_kind = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_value = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cpymad/libmadx.pyx":1108
 *     """Parse a table header value."""
 *     _, key, kind, value = _str(header_line).split(None, 3)
 *     key = key.lower()             # <<<<<<<<<<<<<<
 *     if kind == "%le":
 *         return key, float(value)    # convert to number
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_key, __pyx_n_s_lower); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_key, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1109
 *     _, key, kind, value = _str(header_line).split(None, 3)
 *     key = key.lower()
 *     if kind == "%le":             # <<<<<<<<<<<<<<
 *         return key, float(value)    # convert to number
 *     elif kind.endswith('s'):
 */
  __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_v_kind, __pyx_kp_u_le, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1109, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "cpymad/libmadx.pyx":1110
 *     key = key.lower()
 *     if kind == "%le":
 *         return key, float(value)    # convert to number             # <<<<<<<<<<<<<<
 *     elif kind.endswith('s'):
 *         return key, value[1:-1]     # strip quotes from string
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyNumber_Float(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_key);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1109
 *     _, key, kind, value = _str(header_line).split(None, 3)
 *     key = key.lower()
 *     if kind == "%le":             # <<<<<<<<<<<<<<
 *         return key, float(value)    # convert to number
 *     elif kind.endswith('s'):
 */
  }

  /* "cpymad/libmadx.pyx":1111
 *     if kind == "%le":
 *         return key, float(value)    # convert to number
 *     elif kind.endswith('s'):             # <<<<<<<<<<<<<<
 *         return key, value[1:-1]     # strip quotes from string
 *     else:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kind, __pyx_n_s_endswith); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_6 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_n_u_s) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_s);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1111, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_9) {

    /* "cpymad/libmadx.pyx":1112
 *         return key, float(value)    # convert to number
 *     elif kind.endswith('s'):
 *         return key, value[1:-1]     # strip quotes from string             # <<<<<<<<<<<<<<
 *     else:
 *         return key, value           #
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_value, 1, -1L, NULL, NULL, &__pyx_slice__12, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1111
 *     if kind == "%le":
 *         return key, float(value)    # convert to number
 *     elif kind.endswith('s'):             # <<<<<<<<<<<<<<
 *         return key, value[1:-1]     # strip quotes from string
 *     else:
 */
  }

  /* "cpymad/libmadx.pyx":1114
 *         return key, value[1:-1]     # strip quotes from string
 *     else:
 *         return key, value           #             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "cpymad/libmadx.pyx":1105
 * 
 * 
 * cdef _split_header_line(header_line):             # <<<<<<<<<<<<<<
 *     """Parse a table header value."""
 *     _, key, kind, value = _str(header_line).split(None, 3)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpymad.libmadx._split_header_line", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_kind);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1117
 * 
 * 
 * cdef _name_list(clib.name_list* names):             # <<<<<<<<<<<<<<
 *     """Return a python list of names for the name_list."""
 *     cdef int i
 */

static PyObject *__pyx_f_6cpymad_7libmadx__name_list(struct name_list *__pyx_v_names) {
  int __pyx_9genexpr19__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_name_list", 0);

  /* "cpymad/libmadx.pyx":1120
 *     """Return a python list of names for the name_list."""
 *     cdef int i
 *     return [_str(names.names[i]) for i in range(names.curr)]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1120, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_v_names->curr;
    __pyx_t_3 = __pyx_t_2;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_9genexpr19__pyx_v_i = __pyx_t_4;
      __pyx_t_5 = __pyx_f_6cpymad_7libmadx__str((__pyx_v_names->names[__pyx_9genexpr19__pyx_v_i])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 1120, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  } /* exit inner scope */
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1117
 * 
 * 
 * cdef _name_list(clib.name_list* names):             # <<<<<<<<<<<<<<
 *     """Return a python list of names for the name_list."""
 *     cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx._name_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1125
 * # Leave return type unspecified to avoid cython error with unicode.split(None):
 * # ("TypeError: coercing to Unicode: need string or buffer, NoneType found")
 * cdef _str(const char* s):             # <<<<<<<<<<<<<<
 *     """Decode C string to python string."""
 *     if s is NULL:
 */

static PyObject *__pyx_f_6cpymad_7libmadx__str(char const *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_str", 0);

  /* "cpymad/libmadx.pyx":1127
 * cdef _str(const char* s):
 *     """Decode C string to python string."""
 *     if s is NULL:             # <<<<<<<<<<<<<<
 *         return ""
 *     return s.decode('utf-8')
 */
  __pyx_t_1 = ((__pyx_v_s == NULL) != 0);
  if (__pyx_t_1) {

    /* "cpymad/libmadx.pyx":1128
 *     """Decode C string to python string."""
 *     if s is NULL:
 *         return ""             # <<<<<<<<<<<<<<
 *     return s.decode('utf-8')
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_u__13);
    __pyx_r = __pyx_kp_u__13;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1127
 * cdef _str(const char* s):
 *     """Decode C string to python string."""
 *     if s is NULL:             # <<<<<<<<<<<<<<
 *         return ""
 *     return s.decode('utf-8')
 */
  }

  /* "cpymad/libmadx.pyx":1129
 *     if s is NULL:
 *         return ""
 *     return s.decode('utf-8')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_s, 0, strlen(__pyx_v_s), NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1125
 * # Leave return type unspecified to avoid cython error with unicode.split(None):
 * # ("TypeError: coercing to Unicode: need string or buffer, NoneType found")
 * cdef _str(const char* s):             # <<<<<<<<<<<<<<
 *     """Decode C string to python string."""
 *     if s is NULL:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpymad.libmadx._str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1132
 * 
 * 
 * cdef bytes _cstr(s):             # <<<<<<<<<<<<<<
 *     """Encode python string to C string."""
 *     if s is None:
 */

static PyObject *__pyx_f_6cpymad_7libmadx__cstr(PyObject *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_cstr", 0);

  /* "cpymad/libmadx.pyx":1134
 * cdef bytes _cstr(s):
 *     """Encode python string to C string."""
 *     if s is None:             # <<<<<<<<<<<<<<
 *         return b""
 *     if isinstance(s, bytes):
 */
  __pyx_t_1 = (__pyx_v_s == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cpymad/libmadx.pyx":1135
 *     """Encode python string to C string."""
 *     if s is None:
 *         return b""             # <<<<<<<<<<<<<<
 *     if isinstance(s, bytes):
 *         return <bytes> s
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_b__13);
    __pyx_r = __pyx_kp_b__13;
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1134
 * cdef bytes _cstr(s):
 *     """Encode python string to C string."""
 *     if s is None:             # <<<<<<<<<<<<<<
 *         return b""
 *     if isinstance(s, bytes):
 */
  }

  /* "cpymad/libmadx.pyx":1136
 *     if s is None:
 *         return b""
 *     if isinstance(s, bytes):             # <<<<<<<<<<<<<<
 *         return <bytes> s
 *     return <bytes> s.encode('utf-8')
 */
  __pyx_t_2 = PyBytes_Check(__pyx_v_s); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cpymad/libmadx.pyx":1137
 *         return b""
 *     if isinstance(s, bytes):
 *         return <bytes> s             # <<<<<<<<<<<<<<
 *     return <bytes> s.encode('utf-8')
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject*)__pyx_v_s));
    __pyx_r = ((PyObject*)__pyx_v_s);
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1136
 *     if s is None:
 *         return b""
 *     if isinstance(s, bytes):             # <<<<<<<<<<<<<<
 *         return <bytes> s
 *     return <bytes> s.encode('utf-8')
 */
  }

  /* "cpymad/libmadx.pyx":1138
 *     if isinstance(s, bytes):
 *         return <bytes> s
 *     return <bytes> s.encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_utf_8);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(((PyObject*)__pyx_t_3));
  __pyx_r = ((PyObject*)__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1132
 * 
 * 
 * cdef bytes _cstr(s):             # <<<<<<<<<<<<<<
 *     """Encode python string to C string."""
 *     if s is None:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx._cstr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1141
 * 
 * 
 * cdef _node_name(clib.node* node):             # <<<<<<<<<<<<<<
 *     return name_from_internal(_str(node.name))
 * 
 */

static PyObject *__pyx_f_6cpymad_7libmadx__node_name(struct node *__pyx_v_node) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_node_name", 0);

  /* "cpymad/libmadx.pyx":1142
 * 
 * cdef _node_name(clib.node* node):
 *     return name_from_internal(_str(node.name))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_name_from_internal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_node->name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1141
 * 
 * 
 * cdef _node_name(clib.node* node):             # <<<<<<<<<<<<<<
 *     return name_from_internal(_str(node.name))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpymad.libmadx._node_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1145
 * 
 * 
 * cdef _get_node(clib.node* node, int ref_flag, int is_expanded, int line):             # <<<<<<<<<<<<<<
 *     """Return dictionary with node + element attributes."""
 *     if node.p_elem is NULL:
 */

static PyObject *__pyx_f_6cpymad_7libmadx__get_node(struct node *__pyx_v_node, int __pyx_v_ref_flag, int __pyx_v_is_expanded, int __pyx_v_line) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_get_node", 0);

  /* "cpymad/libmadx.pyx":1147
 * cdef _get_node(clib.node* node, int ref_flag, int is_expanded, int line):
 *     """Return dictionary with node + element attributes."""
 *     if node.p_elem is NULL:             # <<<<<<<<<<<<<<
 *         # Maybe this is a valid case, but better detect it with boom!
 *         raise RuntimeError("Empty node or subsequence! Please report this incident!")
 */
  __pyx_t_1 = ((__pyx_v_node->p_elem == NULL) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cpymad/libmadx.pyx":1149
 *     if node.p_elem is NULL:
 *         # Maybe this is a valid case, but better detect it with boom!
 *         raise RuntimeError("Empty node or subsequence! Please report this incident!")             # <<<<<<<<<<<<<<
 *     data = _get_element(node.p_elem)
 *     if not line:
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1149, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1149, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":1147
 * cdef _get_node(clib.node* node, int ref_flag, int is_expanded, int line):
 *     """Return dictionary with node + element attributes."""
 *     if node.p_elem is NULL:             # <<<<<<<<<<<<<<
 *         # Maybe this is a valid case, but better detect it with boom!
 *         raise RuntimeError("Empty node or subsequence! Please report this incident!")
 */
  }

  /* "cpymad/libmadx.pyx":1150
 *         # Maybe this is a valid case, but better detect it with boom!
 *         raise RuntimeError("Empty node or subsequence! Please report this incident!")
 *     data = _get_element(node.p_elem)             # <<<<<<<<<<<<<<
 *     if not line:
 *         # Update `at` command parameters in order to avoid surprises when
 */
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__get_element(__pyx_v_node->p_elem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_data = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1151
 *         raise RuntimeError("Empty node or subsequence! Please report this incident!")
 *     data = _get_element(node.p_elem)
 *     if not line:             # <<<<<<<<<<<<<<
 *         # Update `at` command parameters in order to avoid surprises when
 *         # specifying `at` value for elements defined outside the sequence:
 */
  __pyx_t_1 = ((!(__pyx_v_line != 0)) != 0);
  if (__pyx_t_1) {

    /* "cpymad/libmadx.pyx":1154
 *         # Update `at` command parameters in order to avoid surprises when
 *         # specifying `at` value for elements defined outside the sequence:
 *         data['data']['at'] = Parameter(             # <<<<<<<<<<<<<<
 *             'at', *_expr(node.at_expr, node.at_value),
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Parameter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "cpymad/libmadx.pyx":1155
 *         # specifying `at` value for elements defined outside the sequence:
 *         data['data']['at'] = Parameter(
 *             'at', *_expr(node.at_expr, node.at_value),             # <<<<<<<<<<<<<<
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 *         data['data']['from'] = Parameter(
 */
    __pyx_t_3 = __pyx_f_6cpymad_7libmadx__expr(__pyx_v_node->at_expr, __pyx_v_node->at_value, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "cpymad/libmadx.pyx":1154
 *         # Update `at` command parameters in order to avoid surprises when
 *         # specifying `at` value for elements defined outside the sequence:
 *         data['data']['at'] = Parameter(             # <<<<<<<<<<<<<<
 *             'at', *_expr(node.at_expr, node.at_value),
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 */
    __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_tuple__15, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":1156
 *         data['data']['at'] = Parameter(
 *             'at', *_expr(node.at_expr, node.at_value),
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)             # <<<<<<<<<<<<<<
 *         data['data']['from'] = Parameter(
 *             'from', _str(node.from_name), None,
 */
    __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_e_6cpymad_8clibmadx_PARAM_TYPE_DOUBLE); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 1156, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_inform, __pyx_int_1) < 0) __PYX_ERR(0, 1156, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":1154
 *         # Update `at` command parameters in order to avoid surprises when
 *         # specifying `at` value for elements defined outside the sequence:
 *         data['data']['at'] = Parameter(             # <<<<<<<<<<<<<<
 *             'at', *_expr(node.at_expr, node.at_value),
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_n_u_at, __pyx_t_5) < 0)) __PYX_ERR(0, 1154, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cpymad/libmadx.pyx":1157
 *             'at', *_expr(node.at_expr, node.at_value),
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 *         data['data']['from'] = Parameter(             # <<<<<<<<<<<<<<
 *             'from', _str(node.from_name), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=node.from_name != NULL)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Parameter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);

    /* "cpymad/libmadx.pyx":1158
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 *         data['data']['from'] = Parameter(
 *             'from', _str(node.from_name), None,             # <<<<<<<<<<<<<<
 *             dtype=clib.PARAM_TYPE_STRING, inform=node.from_name != NULL)
 *     data['node_name'] = _node_name(node)
 */
    __pyx_t_4 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_node->from_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "cpymad/libmadx.pyx":1157
 *             'at', *_expr(node.at_expr, node.at_value),
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 *         data['data']['from'] = Parameter(             # <<<<<<<<<<<<<<
 *             'from', _str(node.from_name), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=node.from_name != NULL)
 */
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_n_u_from);
    __Pyx_GIVEREF(__pyx_n_u_from);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_u_from);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_4 = 0;

    /* "cpymad/libmadx.pyx":1159
 *         data['data']['from'] = Parameter(
 *             'from', _str(node.from_name), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=node.from_name != NULL)             # <<<<<<<<<<<<<<
 *     data['node_name'] = _node_name(node)
 *     data['occ_cnt'] = node.occ_cnt
 */
    __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_6cpymad_8clibmadx_PARAM_TYPE_STRING); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 1159, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyBool_FromLong((__pyx_v_node->from_name != NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_inform, __pyx_t_2) < 0) __PYX_ERR(0, 1159, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cpymad/libmadx.pyx":1157
 *             'at', *_expr(node.at_expr, node.at_value),
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 *         data['data']['from'] = Parameter(             # <<<<<<<<<<<<<<
 *             'from', _str(node.from_name), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=node.from_name != NULL)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_n_u_from, __pyx_t_2) < 0)) __PYX_ERR(0, 1157, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cpymad/libmadx.pyx":1151
 *         raise RuntimeError("Empty node or subsequence! Please report this incident!")
 *     data = _get_element(node.p_elem)
 *     if not line:             # <<<<<<<<<<<<<<
 *         # Update `at` command parameters in order to avoid surprises when
 *         # specifying `at` value for elements defined outside the sequence:
 */
  }

  /* "cpymad/libmadx.pyx":1160
 *             'from', _str(node.from_name), None,
 *             dtype=clib.PARAM_TYPE_STRING, inform=node.from_name != NULL)
 *     data['node_name'] = _node_name(node)             # <<<<<<<<<<<<<<
 *     data['occ_cnt'] = node.occ_cnt
 *     data['enable'] = node.enable
 */
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__node_name(__pyx_v_node); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_node_name, __pyx_t_2) < 0)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1161
 *             dtype=clib.PARAM_TYPE_STRING, inform=node.from_name != NULL)
 *     data['node_name'] = _node_name(node)
 *     data['occ_cnt'] = node.occ_cnt             # <<<<<<<<<<<<<<
 *     data['enable'] = node.enable
 *     data['base_name'] = _str(node.base_name)
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_node->occ_cnt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_occ_cnt, __pyx_t_2) < 0)) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1162
 *     data['node_name'] = _node_name(node)
 *     data['occ_cnt'] = node.occ_cnt
 *     data['enable'] = node.enable             # <<<<<<<<<<<<<<
 *     data['base_name'] = _str(node.base_name)
 *     data['position'] = _get_node_entry_pos(node, ref_flag, is_expanded)
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_node->enable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_enable, __pyx_t_2) < 0)) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1163
 *     data['occ_cnt'] = node.occ_cnt
 *     data['enable'] = node.enable
 *     data['base_name'] = _str(node.base_name)             # <<<<<<<<<<<<<<
 *     data['position'] = _get_node_entry_pos(node, ref_flag, is_expanded)
 *     data['length'] = node.length
 */
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_node->base_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_base_name, __pyx_t_2) < 0)) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1164
 *     data['enable'] = node.enable
 *     data['base_name'] = _str(node.base_name)
 *     data['position'] = _get_node_entry_pos(node, ref_flag, is_expanded)             # <<<<<<<<<<<<<<
 *     data['length'] = node.length
 *     return data
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_f_6cpymad_7libmadx__get_node_entry_pos(__pyx_v_node, __pyx_v_ref_flag, __pyx_v_is_expanded)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_position, __pyx_t_2) < 0)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1165
 *     data['base_name'] = _str(node.base_name)
 *     data['position'] = _get_node_entry_pos(node, ref_flag, is_expanded)
 *     data['length'] = node.length             # <<<<<<<<<<<<<<
 *     return data
 * 
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_node->length); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_length, __pyx_t_2) < 0)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1166
 *     data['position'] = _get_node_entry_pos(node, ref_flag, is_expanded)
 *     data['length'] = node.length
 *     return data             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_data);
  __pyx_r = __pyx_v_data;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1145
 * 
 * 
 * cdef _get_node(clib.node* node, int ref_flag, int is_expanded, int line):             # <<<<<<<<<<<<<<
 *     """Return dictionary with node + element attributes."""
 *     if node.p_elem is NULL:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpymad.libmadx._get_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1169
 * 
 * 
 * cdef double _get_node_entry_pos(clib.node* node, int ref_flag, int is_expanded):             # <<<<<<<<<<<<<<
 *     """Normalize 'at' value to node entry."""
 *     if is_expanded:
 */

static double __pyx_f_6cpymad_7libmadx__get_node_entry_pos(struct node *__pyx_v_node, int __pyx_v_ref_flag, int __pyx_v_is_expanded) {
  double __pyx_v_position;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  double __pyx_t_2;
  __Pyx_RefNannySetupContext("_get_node_entry_pos", 0);

  /* "cpymad/libmadx.pyx":1171
 * cdef double _get_node_entry_pos(clib.node* node, int ref_flag, int is_expanded):
 *     """Normalize 'at' value to node entry."""
 *     if is_expanded:             # <<<<<<<<<<<<<<
 *         return node.position - node.length / 2
 *     cdef double position = node.at_value
 */
  __pyx_t_1 = (__pyx_v_is_expanded != 0);
  if (__pyx_t_1) {

    /* "cpymad/libmadx.pyx":1172
 *     """Normalize 'at' value to node entry."""
 *     if is_expanded:
 *         return node.position - node.length / 2             # <<<<<<<<<<<<<<
 *     cdef double position = node.at_value
 *     if ref_flag == clib.REF_CENTER:
 */
    __pyx_r = (__pyx_v_node->position - (__pyx_v_node->length / 2.0));
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1171
 * cdef double _get_node_entry_pos(clib.node* node, int ref_flag, int is_expanded):
 *     """Normalize 'at' value to node entry."""
 *     if is_expanded:             # <<<<<<<<<<<<<<
 *         return node.position - node.length / 2
 *     cdef double position = node.at_value
 */
  }

  /* "cpymad/libmadx.pyx":1173
 *     if is_expanded:
 *         return node.position - node.length / 2
 *     cdef double position = node.at_value             # <<<<<<<<<<<<<<
 *     if ref_flag == clib.REF_CENTER:
 *         return position - node.length / 2
 */
  __pyx_t_2 = __pyx_v_node->at_value;
  __pyx_v_position = __pyx_t_2;

  /* "cpymad/libmadx.pyx":1174
 *         return node.position - node.length / 2
 *     cdef double position = node.at_value
 *     if ref_flag == clib.REF_CENTER:             # <<<<<<<<<<<<<<
 *         return position - node.length / 2
 *     elif ref_flag == clib.REF_EXIT:
 */
  switch (__pyx_v_ref_flag) {
    case __pyx_e_6cpymad_8clibmadx_REF_CENTER:

    /* "cpymad/libmadx.pyx":1175
 *     cdef double position = node.at_value
 *     if ref_flag == clib.REF_CENTER:
 *         return position - node.length / 2             # <<<<<<<<<<<<<<
 *     elif ref_flag == clib.REF_EXIT:
 *         return position - node.length
 */
    __pyx_r = (__pyx_v_position - (__pyx_v_node->length / 2.0));
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1174
 *         return node.position - node.length / 2
 *     cdef double position = node.at_value
 *     if ref_flag == clib.REF_CENTER:             # <<<<<<<<<<<<<<
 *         return position - node.length / 2
 *     elif ref_flag == clib.REF_EXIT:
 */
    break;
    case __pyx_e_6cpymad_8clibmadx_REF_EXIT:

    /* "cpymad/libmadx.pyx":1177
 *         return position - node.length / 2
 *     elif ref_flag == clib.REF_EXIT:
 *         return position - node.length             # <<<<<<<<<<<<<<
 *     else:
 *         return position
 */
    __pyx_r = (__pyx_v_position - __pyx_v_node->length);
    goto __pyx_L0;

    /* "cpymad/libmadx.pyx":1176
 *     if ref_flag == clib.REF_CENTER:
 *         return position - node.length / 2
 *     elif ref_flag == clib.REF_EXIT:             # <<<<<<<<<<<<<<
 *         return position - node.length
 *     else:
 */
    break;
    default:

    /* "cpymad/libmadx.pyx":1179
 *         return position - node.length
 *     else:
 *         return position             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = __pyx_v_position;
    goto __pyx_L0;
    break;
  }

  /* "cpymad/libmadx.pyx":1169
 * 
 * 
 * cdef double _get_node_entry_pos(clib.node* node, int ref_flag, int is_expanded):             # <<<<<<<<<<<<<<
 *     """Normalize 'at' value to node entry."""
 *     if is_expanded:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1182
 * 
 * 
 * cdef _get_element(clib.element* elem):             # <<<<<<<<<<<<<<
 *     """Return dictionary with element attributes."""
 *     data = _parse_command(elem.def_)
 */

static PyObject *__pyx_f_6cpymad_7libmadx__get_element(struct element *__pyx_v_elem) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_get_element", 0);

  /* "cpymad/libmadx.pyx":1184
 * cdef _get_element(clib.element* elem):
 *     """Return dictionary with element attributes."""
 *     data = _parse_command(elem.def_)             # <<<<<<<<<<<<<<
 *     data['name'] = _str(elem.name)
 *     data['length'] = elem.length
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__parse_command(__pyx_v_elem->def); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":1185
 *     """Return dictionary with element attributes."""
 *     data = _parse_command(elem.def_)
 *     data['name'] = _str(elem.name)             # <<<<<<<<<<<<<<
 *     data['length'] = elem.length
 *     data['parent'] = _str(elem.parent.name)
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_elem->name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_name, __pyx_t_1) < 0)) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":1186
 *     data = _parse_command(elem.def_)
 *     data['name'] = _str(elem.name)
 *     data['length'] = elem.length             # <<<<<<<<<<<<<<
 *     data['parent'] = _str(elem.parent.name)
 *     data['base_type'] = _str(elem.base_type.name)
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_elem->length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_length, __pyx_t_1) < 0)) __PYX_ERR(0, 1186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":1187
 *     data['name'] = _str(elem.name)
 *     data['length'] = elem.length
 *     data['parent'] = _str(elem.parent.name)             # <<<<<<<<<<<<<<
 *     data['base_type'] = _str(elem.base_type.name)
 *     return data
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_elem->parent->name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_parent, __pyx_t_1) < 0)) __PYX_ERR(0, 1187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":1188
 *     data['length'] = elem.length
 *     data['parent'] = _str(elem.parent.name)
 *     data['base_type'] = _str(elem.base_type.name)             # <<<<<<<<<<<<<<
 *     return data
 * 
 */
  __pyx_t_1 = __pyx_f_6cpymad_7libmadx__str(__pyx_v_elem->base_type->name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_n_u_base_type, __pyx_t_1) < 0)) __PYX_ERR(0, 1188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":1189
 *     data['parent'] = _str(elem.parent.name)
 *     data['base_type'] = _str(elem.base_type.name)
 *     return data             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_data);
  __pyx_r = __pyx_v_data;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1182
 * 
 * 
 * cdef _get_element(clib.element* elem):             # <<<<<<<<<<<<<<
 *     """Return dictionary with element attributes."""
 *     data = _parse_command(elem.def_)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpymad.libmadx._get_element", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1192
 * 
 * 
 * cdef _get_table_row_name(clib.table* table, int index):             # <<<<<<<<<<<<<<
 *     if index < 0 or index >= table.curr:
 *         raise ValueError("Invalid row index: {}".format(index))
 */

static PyObject *__pyx_f_6cpymad_7libmadx__get_table_row_name(struct table *__pyx_v_table, int __pyx_v_index) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("_get_table_row_name", 0);

  /* "cpymad/libmadx.pyx":1193
 * 
 * cdef _get_table_row_name(clib.table* table, int index):
 *     if index < 0 or index >= table.curr:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid row index: {}".format(index))
 *     return normalize_range_name(name_from_internal(_str(
 */
  __pyx_t_2 = ((__pyx_v_index < 0) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_index >= __pyx_v_table->curr) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "cpymad/libmadx.pyx":1194
 * cdef _get_table_row_name(clib.table* table, int index):
 *     if index < 0 or index >= table.curr:
 *         raise ValueError("Invalid row index: {}".format(index))             # <<<<<<<<<<<<<<
 *     return normalize_range_name(name_from_internal(_str(
 *         table.node_nm.p[index]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Invalid_row_index, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1194, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1194, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1194, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1194, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1194, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":1193
 * 
 * cdef _get_table_row_name(clib.table* table, int index):
 *     if index < 0 or index >= table.curr:             # <<<<<<<<<<<<<<
 *         raise ValueError("Invalid row index: {}".format(index))
 *     return normalize_range_name(name_from_internal(_str(
 */
  }

  /* "cpymad/libmadx.pyx":1195
 *     if index < 0 or index >= table.curr:
 *         raise ValueError("Invalid row index: {}".format(index))
 *     return normalize_range_name(name_from_internal(_str(             # <<<<<<<<<<<<<<
 *         table.node_nm.p[index]
 *     )))
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_normalize_range_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_name_from_internal); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "cpymad/libmadx.pyx":1196
 *         raise ValueError("Invalid row index: {}".format(index))
 *     return normalize_range_name(name_from_internal(_str(
 *         table.node_nm.p[index]             # <<<<<<<<<<<<<<
 *     )))
 * 
 */
  __pyx_t_7 = __pyx_f_6cpymad_7libmadx__str((__pyx_v_table->node_nm->p[__pyx_v_index])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1192
 * 
 * 
 * cdef _get_table_row_name(clib.table* table, int index):             # <<<<<<<<<<<<<<
 *     if index < 0 or index >= table.curr:
 *         raise ValueError("Invalid row index: {}".format(index))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpymad.libmadx._get_table_row_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1200
 * 
 * 
 * cdef clib.variable* _get_var(name) except NULL:             # <<<<<<<<<<<<<<
 *     cdef bytes _name = _cstr(name.lower())
 *     cdef clib.variable* var = clib.find_variable(_name, clib.variable_list)
 */

static struct variable *__pyx_f_6cpymad_7libmadx__get_var(PyObject *__pyx_v_name) {
  PyObject *__pyx_v__name = 0;
  struct variable *__pyx_v_var;
  struct variable *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("_get_var", 0);

  /* "cpymad/libmadx.pyx":1201
 * 
 * cdef clib.variable* _get_var(name) except NULL:
 *     cdef bytes _name = _cstr(name.lower())             # <<<<<<<<<<<<<<
 *     cdef clib.variable* var = clib.find_variable(_name, clib.variable_list)
 *     if var is NULL:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __pyx_f_6cpymad_7libmadx__cstr(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v__name = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":1202
 * cdef clib.variable* _get_var(name) except NULL:
 *     cdef bytes _name = _cstr(name.lower())
 *     cdef clib.variable* var = clib.find_variable(_name, clib.variable_list)             # <<<<<<<<<<<<<<
 *     if var is NULL:
 *         raise KeyError("Variable not defined: {!r}".format(name))
 */
  if (unlikely(__pyx_v__name == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1202, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyBytes_AsWritableString(__pyx_v__name); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 1202, __pyx_L1_error)
  __pyx_v_var = find_variable(__pyx_t_4, variable_list);

  /* "cpymad/libmadx.pyx":1203
 *     cdef bytes _name = _cstr(name.lower())
 *     cdef clib.variable* var = clib.find_variable(_name, clib.variable_list)
 *     if var is NULL:             # <<<<<<<<<<<<<<
 *         raise KeyError("Variable not defined: {!r}".format(name))
 *     return var
 */
  __pyx_t_5 = ((__pyx_v_var == NULL) != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cpymad/libmadx.pyx":1204
 *     cdef clib.variable* var = clib.find_variable(_name, clib.variable_list)
 *     if var is NULL:
 *         raise KeyError("Variable not defined: {!r}".format(name))             # <<<<<<<<<<<<<<
 *     return var
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Variable_not_defined_r, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_name) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_name);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1204, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 1204, __pyx_L1_error)

    /* "cpymad/libmadx.pyx":1203
 *     cdef bytes _name = _cstr(name.lower())
 *     cdef clib.variable* var = clib.find_variable(_name, clib.variable_list)
 *     if var is NULL:             # <<<<<<<<<<<<<<
 *         raise KeyError("Variable not defined: {!r}".format(name))
 *     return var
 */
  }

  /* "cpymad/libmadx.pyx":1205
 *     if var is NULL:
 *         raise KeyError("Variable not defined: {!r}".format(name))
 *     return var             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_var;
  goto __pyx_L0;

  /* "cpymad/libmadx.pyx":1200
 * 
 * 
 * cdef clib.variable* _get_var(name) except NULL:             # <<<<<<<<<<<<<<
 *     cdef bytes _name = _cstr(name.lower())
 *     cdef clib.variable* var = clib.find_variable(_name, clib.variable_list)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpymad.libmadx._get_var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__name);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpymad/libmadx.pyx":1208
 * 
 * 
 * cdef void _strip_comments(char* text) nogil:             # <<<<<<<<<<<<<<
 *     cdef char* dest = text
 *     cdef char c, d
 */

static void __pyx_f_6cpymad_7libmadx__strip_comments(char *__pyx_v_text) {
  char *__pyx_v_dest;
  char __pyx_v_c;
  char __pyx_v_d;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "cpymad/libmadx.pyx":1209
 * 
 * cdef void _strip_comments(char* text) nogil:
 *     cdef char* dest = text             # <<<<<<<<<<<<<<
 *     cdef char c, d
 *     while True:
 */
  __pyx_v_dest = __pyx_v_text;

  /* "cpymad/libmadx.pyx":1211
 *     cdef char* dest = text
 *     cdef char c, d
 *     while True:             # <<<<<<<<<<<<<<
 *         c = text[0]
 *         if c == 0:
 */
  while (1) {

    /* "cpymad/libmadx.pyx":1212
 *     cdef char c, d
 *     while True:
 *         c = text[0]             # <<<<<<<<<<<<<<
 *         if c == 0:
 *             break
 */
    __pyx_v_c = (__pyx_v_text[0]);

    /* "cpymad/libmadx.pyx":1213
 *     while True:
 *         c = text[0]
 *         if c == 0:             # <<<<<<<<<<<<<<
 *             break
 *         d = text[1]
 */
    __pyx_t_1 = ((__pyx_v_c == 0) != 0);
    if (__pyx_t_1) {

      /* "cpymad/libmadx.pyx":1214
 *         c = text[0]
 *         if c == 0:
 *             break             # <<<<<<<<<<<<<<
 *         d = text[1]
 *         if c == b'!' or (c == b'/' and d == b'/'):
 */
      goto __pyx_L4_break;

      /* "cpymad/libmadx.pyx":1213
 *     while True:
 *         c = text[0]
 *         if c == 0:             # <<<<<<<<<<<<<<
 *             break
 *         d = text[1]
 */
    }

    /* "cpymad/libmadx.pyx":1215
 *         if c == 0:
 *             break
 *         d = text[1]             # <<<<<<<<<<<<<<
 *         if c == b'!' or (c == b'/' and d == b'/'):
 *             text = strchr(text+1, b'\n')
 */
    __pyx_v_d = (__pyx_v_text[1]);

    /* "cpymad/libmadx.pyx":1216
 *             break
 *         d = text[1]
 *         if c == b'!' or (c == b'/' and d == b'/'):             # <<<<<<<<<<<<<<
 *             text = strchr(text+1, b'\n')
 *             if text == NULL:
 */
    __pyx_t_2 = ((__pyx_v_c == '!') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_c == '/') != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_d == '/') != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_1) {

      /* "cpymad/libmadx.pyx":1217
 *         d = text[1]
 *         if c == b'!' or (c == b'/' and d == b'/'):
 *             text = strchr(text+1, b'\n')             # <<<<<<<<<<<<<<
 *             if text == NULL:
 *                 break
 */
      __pyx_v_text = strchr((__pyx_v_text + 1), '\n');

      /* "cpymad/libmadx.pyx":1218
 *         if c == b'!' or (c == b'/' and d == b'/'):
 *             text = strchr(text+1, b'\n')
 *             if text == NULL:             # <<<<<<<<<<<<<<
 *                 break
 *             continue
 */
      __pyx_t_1 = ((__pyx_v_text == NULL) != 0);
      if (__pyx_t_1) {

        /* "cpymad/libmadx.pyx":1219
 *             text = strchr(text+1, b'\n')
 *             if text == NULL:
 *                 break             # <<<<<<<<<<<<<<
 *             continue
 *         if c == b'/' and d == b'*':
 */
        goto __pyx_L4_break;

        /* "cpymad/libmadx.pyx":1218
 *         if c == b'!' or (c == b'/' and d == b'/'):
 *             text = strchr(text+1, b'\n')
 *             if text == NULL:             # <<<<<<<<<<<<<<
 *                 break
 *             continue
 */
      }

      /* "cpymad/libmadx.pyx":1220
 *             if text == NULL:
 *                 break
 *             continue             # <<<<<<<<<<<<<<
 *         if c == b'/' and d == b'*':
 *             text = strstr(text+2, b"*[inserted by cython to avoid comment closer]/")
 */
      goto __pyx_L3_continue;

      /* "cpymad/libmadx.pyx":1216
 *             break
 *         d = text[1]
 *         if c == b'!' or (c == b'/' and d == b'/'):             # <<<<<<<<<<<<<<
 *             text = strchr(text+1, b'\n')
 *             if text == NULL:
 */
    }

    /* "cpymad/libmadx.pyx":1221
 *                 break
 *             continue
 *         if c == b'/' and d == b'*':             # <<<<<<<<<<<<<<
 *             text = strstr(text+2, b"*[inserted by cython to avoid comment closer]/")
 *             if text == NULL:
 */
    __pyx_t_2 = ((__pyx_v_c == '/') != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_d == '*') != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L12_bool_binop_done:;
    if (__pyx_t_1) {

      /* "cpymad/libmadx.pyx":1222
 *             continue
 *         if c == b'/' and d == b'*':
 *             text = strstr(text+2, b"*[inserted by cython to avoid comment closer]/")             # <<<<<<<<<<<<<<
 *             if text == NULL:
 *                 break
 */
      __pyx_v_text = strstr((__pyx_v_text + 2), ((char *)"*/"));

      /* "cpymad/libmadx.pyx":1223
 *         if c == b'/' and d == b'*':
 *             text = strstr(text+2, b"*[inserted by cython to avoid comment closer]/")
 *             if text == NULL:             # <<<<<<<<<<<<<<
 *                 break
 *             text += 2
 */
      __pyx_t_1 = ((__pyx_v_text == NULL) != 0);
      if (__pyx_t_1) {

        /* "cpymad/libmadx.pyx":1224
 *             text = strstr(text+2, b"*[inserted by cython to avoid comment closer]/")
 *             if text == NULL:
 *                 break             # <<<<<<<<<<<<<<
 *             text += 2
 *             continue
 */
        goto __pyx_L4_break;

        /* "cpymad/libmadx.pyx":1223
 *         if c == b'/' and d == b'*':
 *             text = strstr(text+2, b"*[inserted by cython to avoid comment closer]/")
 *             if text == NULL:             # <<<<<<<<<<<<<<
 *                 break
 *             text += 2
 */
      }

      /* "cpymad/libmadx.pyx":1225
 *             if text == NULL:
 *                 break
 *             text += 2             # <<<<<<<<<<<<<<
 *             continue
 *         dest[0] = text[0]
 */
      __pyx_v_text = (__pyx_v_text + 2);

      /* "cpymad/libmadx.pyx":1226
 *                 break
 *             text += 2
 *             continue             # <<<<<<<<<<<<<<
 *         dest[0] = text[0]
 *         text += 1
 */
      goto __pyx_L3_continue;

      /* "cpymad/libmadx.pyx":1221
 *                 break
 *             continue
 *         if c == b'/' and d == b'*':             # <<<<<<<<<<<<<<
 *             text = strstr(text+2, b"*[inserted by cython to avoid comment closer]/")
 *             if text == NULL:
 */
    }

    /* "cpymad/libmadx.pyx":1227
 *             text += 2
 *             continue
 *         dest[0] = text[0]             # <<<<<<<<<<<<<<
 *         text += 1
 *         dest += 1
 */
    (__pyx_v_dest[0]) = (__pyx_v_text[0]);

    /* "cpymad/libmadx.pyx":1228
 *             continue
 *         dest[0] = text[0]
 *         text += 1             # <<<<<<<<<<<<<<
 *         dest += 1
 *     dest[0] = 0
 */
    __pyx_v_text = (__pyx_v_text + 1);

    /* "cpymad/libmadx.pyx":1229
 *         dest[0] = text[0]
 *         text += 1
 *         dest += 1             # <<<<<<<<<<<<<<
 *     dest[0] = 0
 */
    __pyx_v_dest = (__pyx_v_dest + 1);
    __pyx_L3_continue:;
  }
  __pyx_L4_break:;

  /* "cpymad/libmadx.pyx":1230
 *         text += 1
 *         dest += 1
 *     dest[0] = 0             # <<<<<<<<<<<<<<
 */
  (__pyx_v_dest[0]) = 0;

  /* "cpymad/libmadx.pyx":1208
 * 
 * 
 * cdef void _strip_comments(char* text) nogil:             # <<<<<<<<<<<<<<
 *     cdef char* dest = text
 *     cdef char c, d
 */

  /* function exit code */
}

static struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *__pyx_freelist_6cpymad_7libmadx___pyx_scope_struct__get_table_row[8];
static int __pyx_freecount_6cpymad_7libmadx___pyx_scope_struct__get_table_row = 0;

static PyObject *__pyx_tp_new_6cpymad_7libmadx___pyx_scope_struct__get_table_row(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6cpymad_7libmadx___pyx_scope_struct__get_table_row > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row)))) {
    o = (PyObject*)__pyx_freelist_6cpymad_7libmadx___pyx_scope_struct__get_table_row[--__pyx_freecount_6cpymad_7libmadx___pyx_scope_struct__get_table_row];
    memset(o, 0, sizeof(struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpymad_7libmadx___pyx_scope_struct__get_table_row(PyObject *o) {
  struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *p = (struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_row_index);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6cpymad_7libmadx___pyx_scope_struct__get_table_row < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row)))) {
    __pyx_freelist_6cpymad_7libmadx___pyx_scope_struct__get_table_row[__pyx_freecount_6cpymad_7libmadx___pyx_scope_struct__get_table_row++] = ((struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6cpymad_7libmadx___pyx_scope_struct__get_table_row(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *p = (struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *)o;
  if (p->__pyx_v_row_index) {
    e = (*v)(p->__pyx_v_row_index, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpymad_7libmadx___pyx_scope_struct__get_table_row(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *p = (struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row *)o;
  tmp = ((PyObject*)p->__pyx_v_row_index);
  p->__pyx_v_row_index = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6cpymad_7libmadx___pyx_scope_struct__get_table_row = {
  PyVarObject_HEAD_INIT(0, 0)
  "cpymad.libmadx.__pyx_scope_struct__get_table_row", /*tp_name*/
  sizeof(struct __pyx_obj_6cpymad_7libmadx___pyx_scope_struct__get_table_row), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpymad_7libmadx___pyx_scope_struct__get_table_row, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6cpymad_7libmadx___pyx_scope_struct__get_table_row, /*tp_traverse*/
  __pyx_tp_clear_6cpymad_7libmadx___pyx_scope_struct__get_table_row, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpymad_7libmadx___pyx_scope_struct__get_table_row, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_libmadx(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_libmadx},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "libmadx",
    __pyx_k_Low_level_cython_binding_to_MAD, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
  {&__pyx_kp_u_Column_index_out_of_range_0_colu, __pyx_k_Column_index_out_of_range_0_colu, sizeof(__pyx_k_Column_index_out_of_range_0_colu), 0, 1, 0, 0},
  {&__pyx_kp_u_Column_not_found_0_r, __pyx_k_Column_not_found_0_r, sizeof(__pyx_k_Column_not_found_0_r), 0, 1, 0, 0},
  {&__pyx_kp_u_Column_r_is_not_in_table_r, __pyx_k_Column_r_is_not_in_table_r, sizeof(__pyx_k_Column_r_is_not_in_table_r), 0, 1, 0, 0},
  {&__pyx_n_s_Constraint, __pyx_k_Constraint, sizeof(__pyx_k_Constraint), 0, 0, 1, 1},
  {&__pyx_kp_u_Element_name_not_found_0_r, __pyx_k_Element_name_not_found_0_r, sizeof(__pyx_k_Element_name_not_found_0_r), 0, 1, 0, 0},
  {&__pyx_kp_u_Empty_node_or_subsequence_Please, __pyx_k_Empty_node_or_subsequence_Please, sizeof(__pyx_k_Empty_node_or_subsequence_Please), 0, 1, 0, 0},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_kp_u_Index_out_of_range_0_element_cou, __pyx_k_Index_out_of_range_0_element_cou, sizeof(__pyx_k_Index_out_of_range_0_element_cou), 0, 1, 0, 0},
  {&__pyx_kp_u_Invalid_command_r, __pyx_k_Invalid_command_r, sizeof(__pyx_k_Invalid_command_r), 0, 1, 0, 0},
  {&__pyx_kp_u_Invalid_expression_r, __pyx_k_Invalid_expression_r, sizeof(__pyx_k_Invalid_expression_r), 0, 1, 0, 0},
  {&__pyx_kp_u_Invalid_row_index, __pyx_k_Invalid_row_index, sizeof(__pyx_k_Invalid_row_index), 0, 1, 0, 0},
  {&__pyx_kp_u_Invalid_sequence_r, __pyx_k_Invalid_sequence_r, sizeof(__pyx_k_Invalid_sequence_r), 0, 1, 0, 0},
  {&__pyx_kp_u_Invalid_table_r, __pyx_k_Invalid_table_r, sizeof(__pyx_k_Invalid_table_r), 0, 1, 0, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_kp_u_No_active_sequence, __pyx_k_No_active_sequence, sizeof(__pyx_k_No_active_sequence), 0, 1, 0, 0},
  {&__pyx_kp_u_No_beam_attached_to_r, __pyx_k_No_beam_attached_to_r, sizeof(__pyx_k_No_beam_attached_to_r), 0, 1, 0, 0},
  {&__pyx_kp_u_No_element_found_at_position_0, __pyx_k_No_element_found_at_position_0, sizeof(__pyx_k_No_element_found_at_position_0), 0, 1, 0, 0},
  {&__pyx_kp_u_No_summary_for_table_r, __pyx_k_No_summary_for_table_r, sizeof(__pyx_k_No_summary_for_table_r), 0, 1, 0, 0},
  {&__pyx_n_s_Parameter, __pyx_k_Parameter, sizeof(__pyx_k_Parameter), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_b_S, __pyx_k_S, sizeof(__pyx_k_S), 0, 0, 0, 1},
  {&__pyx_kp_u_TWISS_table_invalid_for_r, __pyx_k_TWISS_table_invalid_for_r, sizeof(__pyx_k_TWISS_table_invalid_for_r), 0, 1, 0, 0},
  {&__pyx_kp_u_Unknown_datatype_r_in_column_r, __pyx_k_Unknown_datatype_r_in_column_r, sizeof(__pyx_k_Unknown_datatype_r_in_column_r), 0, 1, 0, 0},
  {&__pyx_kp_u_Unknown_parameter_type, __pyx_k_Unknown_parameter_type, sizeof(__pyx_k_Unknown_parameter_type), 0, 1, 0, 0},
  {&__pyx_n_b_V, __pyx_k_V, sizeof(__pyx_k_V), 0, 0, 0, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_u_Variable_not_defined_r, __pyx_k_Variable_not_defined_r, sizeof(__pyx_k_Variable_not_defined_r), 0, 1, 0, 0},
  {&__pyx_kp_b__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 0, 0, 0},
  {&__pyx_kp_u__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 1, 0, 0},
  {&__pyx_kp_u__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 1, 0, 0},
  {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0},
  {&__pyx_n_s_addr, __pyx_k_addr, sizeof(__pyx_k_addr), 0, 0, 1, 1},
  {&__pyx_n_u_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 1, 0, 1},
  {&__pyx_n_s_all_2, __pyx_k_all_2, sizeof(__pyx_k_all_2), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_apply_table_selections, __pyx_k_apply_table_selections, sizeof(__pyx_k_apply_table_selections), 0, 0, 1, 1},
  {&__pyx_n_u_apply_table_selections, __pyx_k_apply_table_selections, sizeof(__pyx_k_apply_table_selections), 0, 1, 0, 1},
  {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
  {&__pyx_n_s_array_data, __pyx_k_array_data, sizeof(__pyx_k_array_data), 0, 0, 1, 1},
  {&__pyx_n_s_array_type, __pyx_k_array_type, sizeof(__pyx_k_array_type), 0, 0, 1, 1},
  {&__pyx_n_s_as_array, __pyx_k_as_array, sizeof(__pyx_k_as_array), 0, 0, 1, 1},
  {&__pyx_n_s_at, __pyx_k_at, sizeof(__pyx_k_at), 0, 0, 1, 1},
  {&__pyx_n_u_at, __pyx_k_at, sizeof(__pyx_k_at), 0, 1, 0, 1},
  {&__pyx_n_u_base_name, __pyx_k_base_name, sizeof(__pyx_k_base_name), 0, 1, 0, 1},
  {&__pyx_n_u_base_type, __pyx_k_base_type, sizeof(__pyx_k_base_type), 0, 1, 0, 1},
  {&__pyx_n_s_c_double, __pyx_k_c_double, sizeof(__pyx_k_c_double), 0, 0, 1, 1},
  {&__pyx_n_s_char_tmp, __pyx_k_char_tmp, sizeof(__pyx_k_char_tmp), 0, 0, 1, 1},
  {&__pyx_n_s_chdir, __pyx_k_chdir, sizeof(__pyx_k_chdir), 0, 0, 1, 1},
  {&__pyx_n_u_chdir, __pyx_k_chdir, sizeof(__pyx_k_chdir), 0, 1, 0, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_cmd, __pyx_k_cmd, sizeof(__pyx_k_cmd), 0, 0, 1, 1},
  {&__pyx_n_s_cmd_2, __pyx_k_cmd_2, sizeof(__pyx_k_cmd_2), 0, 0, 1, 1},
  {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1},
  {&__pyx_n_s_col_index, __pyx_k_col_index, sizeof(__pyx_k_col_index), 0, 0, 1, 1},
  {&__pyx_n_s_col_name, __pyx_k_col_name, sizeof(__pyx_k_col_name), 0, 0, 1, 1},
  {&__pyx_n_s_column_name, __pyx_k_column_name, sizeof(__pyx_k_column_name), 0, 0, 1, 1},
  {&__pyx_n_s_columns, __pyx_k_columns, sizeof(__pyx_k_columns), 0, 0, 1, 1},
  {&__pyx_n_s_command_name, __pyx_k_command_name, sizeof(__pyx_k_command_name), 0, 0, 1, 1},
  {&__pyx_n_s_command_name_2, __pyx_k_command_name_2, sizeof(__pyx_k_command_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_cpymad_libmadx, __pyx_k_cpymad_libmadx, sizeof(__pyx_k_cpymad_libmadx), 0, 0, 1, 1},
  {&__pyx_n_s_cpymad_types, __pyx_k_cpymad_types, sizeof(__pyx_k_cpymad_types), 0, 0, 1, 1},
  {&__pyx_n_s_cpymad_util, __pyx_k_cpymad_util, sizeof(__pyx_k_cpymad_util), 0, 0, 1, 1},
  {&__pyx_n_s_ctypes, __pyx_k_ctypes, sizeof(__pyx_k_ctypes), 0, 0, 1, 1},
  {&__pyx_n_s_ctypeslib, __pyx_k_ctypeslib, sizeof(__pyx_k_ctypeslib), 0, 0, 1, 1},
  {&__pyx_n_b_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 0, 1},
  {&__pyx_n_u_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 1, 0, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_elem, __pyx_k_elem, sizeof(__pyx_k_elem), 0, 0, 1, 1},
  {&__pyx_n_s_element_index, __pyx_k_element_index, sizeof(__pyx_k_element_index), 0, 0, 1, 1},
  {&__pyx_n_s_element_name, __pyx_k_element_name, sizeof(__pyx_k_element_name), 0, 0, 1, 1},
  {&__pyx_n_s_element_name_2, __pyx_k_element_name_2, sizeof(__pyx_k_element_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_elems, __pyx_k_elems, sizeof(__pyx_k_elems), 0, 0, 1, 1},
  {&__pyx_n_u_enable, __pyx_k_enable, sizeof(__pyx_k_enable), 0, 1, 0, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_endswith, __pyx_k_endswith, sizeof(__pyx_k_endswith), 0, 0, 1, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_n_s_eval, __pyx_k_eval, sizeof(__pyx_k_eval), 0, 0, 1, 1},
  {&__pyx_n_u_eval, __pyx_k_eval, sizeof(__pyx_k_eval), 0, 1, 0, 1},
  {&__pyx_n_s_expr, __pyx_k_expr, sizeof(__pyx_k_expr), 0, 0, 1, 1},
  {&__pyx_n_s_expr_types, __pyx_k_expr_types, sizeof(__pyx_k_expr_types), 0, 0, 1, 1},
  {&__pyx_n_s_expression, __pyx_k_expression, sizeof(__pyx_k_expression), 0, 0, 1, 1},
  {&__pyx_n_s_expression_vars, __pyx_k_expression_vars, sizeof(__pyx_k_expression_vars), 0, 0, 1, 1},
  {&__pyx_n_s_fetch_value, __pyx_k_fetch_value, sizeof(__pyx_k_fetch_value), 0, 0, 1, 1},
  {&__pyx_n_s_finish, __pyx_k_finish, sizeof(__pyx_k_finish), 0, 0, 1, 1},
  {&__pyx_n_u_finish, __pyx_k_finish, sizeof(__pyx_k_finish), 0, 1, 0, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_u_from, __pyx_k_from, sizeof(__pyx_k_from), 0, 1, 0, 1},
  {&__pyx_n_s_from_address, __pyx_k_from_address, sizeof(__pyx_k_from_address), 0, 0, 1, 1},
  {&__pyx_n_s_get_active_sequence_name, __pyx_k_get_active_sequence_name, sizeof(__pyx_k_get_active_sequence_name), 0, 0, 1, 1},
  {&__pyx_n_u_get_active_sequence_name, __pyx_k_get_active_sequence_name, sizeof(__pyx_k_get_active_sequence_name), 0, 1, 0, 1},
  {&__pyx_n_s_get_base_type_names, __pyx_k_get_base_type_names, sizeof(__pyx_k_get_base_type_names), 0, 0, 1, 1},
  {&__pyx_n_u_get_base_type_names, __pyx_k_get_base_type_names, sizeof(__pyx_k_get_base_type_names), 0, 1, 0, 1},
  {&__pyx_n_s_get_defined_command, __pyx_k_get_defined_command, sizeof(__pyx_k_get_defined_command), 0, 0, 1, 1},
  {&__pyx_n_u_get_defined_command, __pyx_k_get_defined_command, sizeof(__pyx_k_get_defined_command), 0, 1, 0, 1},
  {&__pyx_n_s_get_defined_command_names, __pyx_k_get_defined_command_names, sizeof(__pyx_k_get_defined_command_names), 0, 0, 1, 1},
  {&__pyx_n_u_get_defined_command_names, __pyx_k_get_defined_command_names, sizeof(__pyx_k_get_defined_command_names), 0, 1, 0, 1},
  {&__pyx_n_s_get_element, __pyx_k_get_element, sizeof(__pyx_k_get_element), 0, 0, 1, 1},
  {&__pyx_n_u_get_element, __pyx_k_get_element, sizeof(__pyx_k_get_element), 0, 1, 0, 1},
  {&__pyx_n_s_get_element_count, __pyx_k_get_element_count, sizeof(__pyx_k_get_element_count), 0, 0, 1, 1},
  {&__pyx_n_u_get_element_count, __pyx_k_get_element_count, sizeof(__pyx_k_get_element_count), 0, 1, 0, 1},
  {&__pyx_n_s_get_element_index, __pyx_k_get_element_index, sizeof(__pyx_k_get_element_index), 0, 0, 1, 1},
  {&__pyx_n_u_get_element_index, __pyx_k_get_element_index, sizeof(__pyx_k_get_element_index), 0, 1, 0, 1},
  {&__pyx_n_s_get_element_index_by_position, __pyx_k_get_element_index_by_position, sizeof(__pyx_k_get_element_index_by_position), 0, 0, 1, 1},
  {&__pyx_n_u_get_element_index_by_position, __pyx_k_get_element_index_by_position, sizeof(__pyx_k_get_element_index_by_position), 0, 1, 0, 1},
  {&__pyx_n_s_get_element_name, __pyx_k_get_element_name, sizeof(__pyx_k_get_element_name), 0, 0, 1, 1},
  {&__pyx_n_u_get_element_name, __pyx_k_get_element_name, sizeof(__pyx_k_get_element_name), 0, 1, 0, 1},
  {&__pyx_n_s_get_element_names, __pyx_k_get_element_names, sizeof(__pyx_k_get_element_names), 0, 0, 1, 1},
  {&__pyx_n_u_get_element_names, __pyx_k_get_element_names, sizeof(__pyx_k_get_element_names), 0, 1, 0, 1},
  {&__pyx_n_s_get_element_positions, __pyx_k_get_element_positions, sizeof(__pyx_k_get_element_positions), 0, 0, 1, 1},
  {&__pyx_n_u_get_element_positions, __pyx_k_get_element_positions, sizeof(__pyx_k_get_element_positions), 0, 1, 0, 1},
  {&__pyx_n_s_get_expanded_element, __pyx_k_get_expanded_element, sizeof(__pyx_k_get_expanded_element), 0, 0, 1, 1},
  {&__pyx_n_u_get_expanded_element, __pyx_k_get_expanded_element, sizeof(__pyx_k_get_expanded_element), 0, 1, 0, 1},
  {&__pyx_n_s_get_expanded_element_count, __pyx_k_get_expanded_element_count, sizeof(__pyx_k_get_expanded_element_count), 0, 0, 1, 1},
  {&__pyx_n_u_get_expanded_element_count, __pyx_k_get_expanded_element_count, sizeof(__pyx_k_get_expanded_element_count), 0, 1, 0, 1},
  {&__pyx_n_s_get_expanded_element_index, __pyx_k_get_expanded_element_index, sizeof(__pyx_k_get_expanded_element_index), 0, 0, 1, 1},
  {&__pyx_n_u_get_expanded_element_index, __pyx_k_get_expanded_element_index, sizeof(__pyx_k_get_expanded_element_index), 0, 1, 0, 1},
  {&__pyx_n_s_get_expanded_element_index_by_po, __pyx_k_get_expanded_element_index_by_po, sizeof(__pyx_k_get_expanded_element_index_by_po), 0, 0, 1, 1},
  {&__pyx_n_u_get_expanded_element_index_by_po, __pyx_k_get_expanded_element_index_by_po, sizeof(__pyx_k_get_expanded_element_index_by_po), 0, 1, 0, 1},
  {&__pyx_n_s_get_expanded_element_name, __pyx_k_get_expanded_element_name, sizeof(__pyx_k_get_expanded_element_name), 0, 0, 1, 1},
  {&__pyx_n_u_get_expanded_element_name, __pyx_k_get_expanded_element_name, sizeof(__pyx_k_get_expanded_element_name), 0, 1, 0, 1},
  {&__pyx_n_s_get_expanded_element_names, __pyx_k_get_expanded_element_names, sizeof(__pyx_k_get_expanded_element_names), 0, 0, 1, 1},
  {&__pyx_n_u_get_expanded_element_names, __pyx_k_get_expanded_element_names, sizeof(__pyx_k_get_expanded_element_names), 0, 1, 0, 1},
  {&__pyx_n_s_get_expanded_element_positions, __pyx_k_get_expanded_element_positions, sizeof(__pyx_k_get_expanded_element_positions), 0, 0, 1, 1},
  {&__pyx_n_u_get_expanded_element_positions, __pyx_k_get_expanded_element_positions, sizeof(__pyx_k_get_expanded_element_positions), 0, 1, 0, 1},
  {&__pyx_n_s_get_global_element, __pyx_k_get_global_element, sizeof(__pyx_k_get_global_element), 0, 0, 1, 1},
  {&__pyx_n_u_get_global_element, __pyx_k_get_global_element, sizeof(__pyx_k_get_global_element), 0, 1, 0, 1},
  {&__pyx_n_s_get_global_element_count, __pyx_k_get_global_element_count, sizeof(__pyx_k_get_global_element_count), 0, 0, 1, 1},
  {&__pyx_n_u_get_global_element_count, __pyx_k_get_global_element_count, sizeof(__pyx_k_get_global_element_count), 0, 1, 0, 1},
  {&__pyx_n_s_get_global_element_index, __pyx_k_get_global_element_index, sizeof(__pyx_k_get_global_element_index), 0, 0, 1, 1},
  {&__pyx_n_u_get_global_element_index, __pyx_k_get_global_element_index, sizeof(__pyx_k_get_global_element_index), 0, 1, 0, 1},
  {&__pyx_n_s_get_global_element_name, __pyx_k_get_global_element_name, sizeof(__pyx_k_get_global_element_name), 0, 0, 1, 1},
  {&__pyx_n_u_get_global_element_name, __pyx_k_get_global_element_name, sizeof(__pyx_k_get_global_element_name), 0, 1, 0, 1},
  {&__pyx_n_s_get_globals, __pyx_k_get_globals, sizeof(__pyx_k_get_globals), 0, 0, 1, 1},
  {&__pyx_n_u_get_globals, __pyx_k_get_globals, sizeof(__pyx_k_get_globals), 0, 1, 0, 1},
  {&__pyx_n_s_get_options, __pyx_k_get_options, sizeof(__pyx_k_get_options), 0, 0, 1, 1},
  {&__pyx_n_u_get_options, __pyx_k_get_options, sizeof(__pyx_k_get_options), 0, 1, 0, 1},
  {&__pyx_n_s_get_rightmost_word, __pyx_k_get_rightmost_word, sizeof(__pyx_k_get_rightmost_word), 0, 0, 1, 1},
  {&__pyx_n_s_get_sequence_beam, __pyx_k_get_sequence_beam, sizeof(__pyx_k_get_sequence_beam), 0, 0, 1, 1},
  {&__pyx_n_u_get_sequence_beam, __pyx_k_get_sequence_beam, sizeof(__pyx_k_get_sequence_beam), 0, 1, 0, 1},
  {&__pyx_n_s_get_sequence_count, __pyx_k_get_sequence_count, sizeof(__pyx_k_get_sequence_count), 0, 0, 1, 1},
  {&__pyx_n_u_get_sequence_count, __pyx_k_get_sequence_count, sizeof(__pyx_k_get_sequence_count), 0, 1, 0, 1},
  {&__pyx_n_s_get_sequence_names, __pyx_k_get_sequence_names, sizeof(__pyx_k_get_sequence_names), 0, 0, 1, 1},
  {&__pyx_n_u_get_sequence_names, __pyx_k_get_sequence_names, sizeof(__pyx_k_get_sequence_names), 0, 1, 0, 1},
  {&__pyx_n_s_get_sequence_twiss_table_name, __pyx_k_get_sequence_twiss_table_name, sizeof(__pyx_k_get_sequence_twiss_table_name), 0, 0, 1, 1},
  {&__pyx_n_u_get_sequence_twiss_table_name, __pyx_k_get_sequence_twiss_table_name, sizeof(__pyx_k_get_sequence_twiss_table_name), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_column, __pyx_k_get_table_column, sizeof(__pyx_k_get_table_column), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_column, __pyx_k_get_table_column, sizeof(__pyx_k_get_table_column), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_column_count, __pyx_k_get_table_column_count, sizeof(__pyx_k_get_table_column_count), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_column_count, __pyx_k_get_table_column_count, sizeof(__pyx_k_get_table_column_count), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_column_count_all, __pyx_k_get_table_column_count_all, sizeof(__pyx_k_get_table_column_count_all), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_column_count_all, __pyx_k_get_table_column_count_all, sizeof(__pyx_k_get_table_column_count_all), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_column_names, __pyx_k_get_table_column_names, sizeof(__pyx_k_get_table_column_names), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_column_names, __pyx_k_get_table_column_names, sizeof(__pyx_k_get_table_column_names), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_column_names_all, __pyx_k_get_table_column_names_all, sizeof(__pyx_k_get_table_column_names_all), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_column_names_all, __pyx_k_get_table_column_names_all, sizeof(__pyx_k_get_table_column_names_all), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_count, __pyx_k_get_table_count, sizeof(__pyx_k_get_table_count), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_count, __pyx_k_get_table_count, sizeof(__pyx_k_get_table_count), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_names, __pyx_k_get_table_names, sizeof(__pyx_k_get_table_names), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_names, __pyx_k_get_table_names, sizeof(__pyx_k_get_table_names), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_row, __pyx_k_get_table_row, sizeof(__pyx_k_get_table_row), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_row, __pyx_k_get_table_row, sizeof(__pyx_k_get_table_row), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_row_count, __pyx_k_get_table_row_count, sizeof(__pyx_k_get_table_row_count), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_row_count, __pyx_k_get_table_row_count, sizeof(__pyx_k_get_table_row_count), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_row_locals_fetch_value, __pyx_k_get_table_row_locals_fetch_value, sizeof(__pyx_k_get_table_row_locals_fetch_value), 0, 0, 1, 1},
  {&__pyx_n_s_get_table_row_names, __pyx_k_get_table_row_names, sizeof(__pyx_k_get_table_row_names), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_row_names, __pyx_k_get_table_row_names, sizeof(__pyx_k_get_table_row_names), 0, 1, 0, 1},
  {&__pyx_n_s_get_table_summary, __pyx_k_get_table_summary, sizeof(__pyx_k_get_table_summary), 0, 0, 1, 1},
  {&__pyx_n_u_get_table_summary, __pyx_k_get_table_summary, sizeof(__pyx_k_get_table_summary), 0, 1, 0, 1},
  {&__pyx_n_s_get_var, __pyx_k_get_var, sizeof(__pyx_k_get_var), 0, 0, 1, 1},
  {&__pyx_n_u_get_var, __pyx_k_get_var, sizeof(__pyx_k_get_var), 0, 1, 0, 1},
  {&__pyx_n_s_get_var_type, __pyx_k_get_var_type, sizeof(__pyx_k_get_var_type), 0, 0, 1, 1},
  {&__pyx_n_u_get_var_type, __pyx_k_get_var_type, sizeof(__pyx_k_get_var_type), 0, 1, 0, 1},
  {&__pyx_n_s_get_version_date, __pyx_k_get_version_date, sizeof(__pyx_k_get_version_date), 0, 0, 1, 1},
  {&__pyx_n_u_get_version_date, __pyx_k_get_version_date, sizeof(__pyx_k_get_version_date), 0, 1, 0, 1},
  {&__pyx_n_s_get_version_number, __pyx_k_get_version_number, sizeof(__pyx_k_get_version_number), 0, 0, 1, 1},
  {&__pyx_n_u_get_version_number, __pyx_k_get_version_number, sizeof(__pyx_k_get_version_number), 0, 1, 0, 1},
  {&__pyx_n_s_getcwd, __pyx_k_getcwd, sizeof(__pyx_k_getcwd), 0, 0, 1, 1},
  {&__pyx_n_u_getcwd, __pyx_k_getcwd, sizeof(__pyx_k_getcwd), 0, 1, 0, 1},
  {&__pyx_n_s_header, __pyx_k_header, sizeof(__pyx_k_header), 0, 0, 1, 1},
  {&__pyx_n_b_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 0, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_idx, __pyx_k_idx, sizeof(__pyx_k_idx), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
  {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  {&__pyx_n_s_inform, __pyx_k_inform, sizeof(__pyx_k_inform), 0, 0, 1, 1},
  {&__pyx_n_s_input, __pyx_k_input, sizeof(__pyx_k_input), 0, 0, 1, 1},
  {&__pyx_n_u_input, __pyx_k_input, sizeof(__pyx_k_input), 0, 1, 0, 1},
  {&__pyx_n_s_is_sequence_expanded, __pyx_k_is_sequence_expanded, sizeof(__pyx_k_is_sequence_expanded), 0, 0, 1, 1},
  {&__pyx_n_u_is_sequence_expanded, __pyx_k_is_sequence_expanded, sizeof(__pyx_k_is_sequence_expanded), 0, 1, 0, 1},
  {&__pyx_n_s_is_started, __pyx_k_is_started, sizeof(__pyx_k_is_started), 0, 0, 1, 1},
  {&__pyx_n_u_is_started, __pyx_k_is_started, sizeof(__pyx_k_is_started), 0, 1, 0, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_kp_u_le, __pyx_k_le, sizeof(__pyx_k_le), 0, 1, 0, 0},
  {&__pyx_n_u_length, __pyx_k_length, sizeof(__pyx_k_length), 0, 1, 0, 1},
  {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
  {&__pyx_n_s_madx_started, __pyx_k_madx_started, sizeof(__pyx_k_madx_started), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1},
  {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1},
  {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_u_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 1, 0, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_name_from_internal, __pyx_k_name_from_internal, sizeof(__pyx_k_name_from_internal), 0, 0, 1, 1},
  {&__pyx_n_s_name_to_internal, __pyx_k_name_to_internal, sizeof(__pyx_k_name_to_internal), 0, 0, 1, 1},
  {&__pyx_n_u_node_name, __pyx_k_node_name, sizeof(__pyx_k_node_name), 0, 1, 0, 1},
  {&__pyx_n_s_nodes, __pyx_k_nodes, sizeof(__pyx_k_nodes), 0, 0, 1, 1},
  {&__pyx_n_s_normalize_range_name, __pyx_k_normalize_range_name, sizeof(__pyx_k_normalize_range_name), 0, 0, 1, 1},
  {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  {&__pyx_n_s_num_globals, __pyx_k_num_globals, sizeof(__pyx_k_num_globals), 0, 0, 1, 1},
  {&__pyx_n_u_num_globals, __pyx_k_num_globals, sizeof(__pyx_k_num_globals), 0, 1, 0, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_u_occ_cnt, __pyx_k_occ_cnt, sizeof(__pyx_k_occ_cnt), 0, 1, 0, 1},
  {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  {&__pyx_n_u_parent, __pyx_k_parent, sizeof(__pyx_k_parent), 0, 1, 0, 1},
  {&__pyx_n_s_pch, __pyx_k_pch, sizeof(__pyx_k_pch), 0, 0, 1, 1},
  {&__pyx_n_s_position, __pyx_k_position, sizeof(__pyx_k_position), 0, 0, 1, 1},
  {&__pyx_n_u_position, __pyx_k_position, sizeof(__pyx_k_position), 0, 1, 0, 1},
  {&__pyx_n_s_position_2, __pyx_k_position_2, sizeof(__pyx_k_position_2), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_row_index, __pyx_k_row_index, sizeof(__pyx_k_row_index), 0, 0, 1, 1},
  {&__pyx_n_s_rsplit, __pyx_k_rsplit, sizeof(__pyx_k_rsplit), 0, 0, 1, 1},
  {&__pyx_n_s_rstrip, __pyx_k_rstrip, sizeof(__pyx_k_rstrip), 0, 0, 1, 1},
  {&__pyx_n_u_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 1, 0, 1},
  {&__pyx_n_u_selected, __pyx_k_selected, sizeof(__pyx_k_selected), 0, 1, 0, 1},
  {&__pyx_n_s_sentence, __pyx_k_sentence, sizeof(__pyx_k_sentence), 0, 0, 1, 1},
  {&__pyx_n_s_seq, __pyx_k_seq, sizeof(__pyx_k_seq), 0, 0, 1, 1},
  {&__pyx_n_s_seqs, __pyx_k_seqs, sizeof(__pyx_k_seqs), 0, 0, 1, 1},
  {&__pyx_n_s_sequence_exists, __pyx_k_sequence_exists, sizeof(__pyx_k_sequence_exists), 0, 0, 1, 1},
  {&__pyx_n_u_sequence_exists, __pyx_k_sequence_exists, sizeof(__pyx_k_sequence_exists), 0, 1, 0, 1},
  {&__pyx_n_s_sequence_name, __pyx_k_sequence_name, sizeof(__pyx_k_sequence_name), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_k_src_cpymad_libmadx_pyx, sizeof(__pyx_k_src_cpymad_libmadx_pyx), 0, 0, 1, 0},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_u_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 1, 0, 1},
  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
  {&__pyx_n_s_tab_name, __pyx_k_tab_name, sizeof(__pyx_k_tab_name), 0, 0, 1, 1},
  {&__pyx_n_s_table, __pyx_k_table, sizeof(__pyx_k_table), 0, 0, 1, 1},
  {&__pyx_n_s_table_exists, __pyx_k_table_exists, sizeof(__pyx_k_table_exists), 0, 0, 1, 1},
  {&__pyx_n_u_table_exists, __pyx_k_table_exists, sizeof(__pyx_k_table_exists), 0, 1, 0, 1},
  {&__pyx_n_s_table_name, __pyx_k_table_name, sizeof(__pyx_k_table_name), 0, 0, 1, 1},
  {&__pyx_n_s_table_name_2, __pyx_k_table_name_2, sizeof(__pyx_k_table_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_typeid, __pyx_k_typeid, sizeof(__pyx_k_typeid), 0, 0, 1, 1},
  {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0},
  {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_var, __pyx_k_var, sizeof(__pyx_k_var), 0, 0, 1, 1},
  {&__pyx_n_s_var_type, __pyx_k_var_type, sizeof(__pyx_k_var_type), 0, 0, 1, 1},
  {&__pyx_n_s_vars, __pyx_k_vars, sizeof(__pyx_k_vars), 0, 0, 1, 1},
  {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 267, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 283, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 326, __pyx_L1_error)
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 496, __pyx_L1_error)
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) __PYX_ERR(0, 567, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 1204, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "cpymad/libmadx.pyx":130
 * def _get_rightmost_word(sentence):
 *     """Get the work right of the rightmost space character."""
 *     return sentence.rsplit(' ', 1)[-1]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__2 = PyTuple_Pack(2, __pyx_kp_u_, __pyx_int_1); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "cpymad/libmadx.pyx":312
 *     """
 *     if clib.current_sequ is NULL:
 *         raise RuntimeError("No active sequence!")             # <<<<<<<<<<<<<<
 *     return _str(clib.current_sequ.name)
 * 
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_No_active_sequence); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "cpymad/libmadx.pyx":501
 *         row_index += table.curr
 * 
 *     def fetch_value(col_index):             # <<<<<<<<<<<<<<
 *         inform = table.columns.inform[col_index]
 *         if inform == clib.PARAM_TYPE_INTEGER:
 */
  __pyx_tuple__5 = PyTuple_Pack(2, __pyx_n_s_col_index, __pyx_n_s_inform); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);
  __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_fetch_value, 501, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 501, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":568
 *     cdef clib.table* t = _find_table(table_name)
 *     version_info = tuple(map(int, get_version_number().split('.')))
 *     if version_info > (5,3,7):       # will crash before             # <<<<<<<<<<<<<<
 *         clib.out_table(_cstr(table_name), t, NULL)
 * 
 */
  __pyx_tuple__8 = PyTuple_Pack(3, __pyx_int_5, __pyx_int_3, __pyx_int_7); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cpymad/libmadx.pyx":1027
 * 
 *     if par.type == clib.PARAM_TYPE_CONSTRAINT:
 *         val = min = max = (None, None)             # <<<<<<<<<<<<<<
 *         if par.c_type == clib.CONSTR_TYPE_NONE: # occurs in defined_commands
 *             pass
 */
  __pyx_tuple__10 = PyTuple_Pack(2, Py_None, Py_None); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 1027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "cpymad/libmadx.pyx":1107
 * cdef _split_header_line(header_line):
 *     """Parse a table header value."""
 *     _, key, kind, value = _str(header_line).split(None, 3)             # <<<<<<<<<<<<<<
 *     key = key.lower()
 *     if kind == "%le":
 */
  __pyx_tuple__11 = PyTuple_Pack(2, Py_None, __pyx_int_3); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "cpymad/libmadx.pyx":1112
 *         return key, float(value)    # convert to number
 *     elif kind.endswith('s'):
 *         return key, value[1:-1]     # strip quotes from string             # <<<<<<<<<<<<<<
 *     else:
 *         return key, value           #
 */
  __pyx_slice__12 = PySlice_New(__pyx_int_1, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__12)) __PYX_ERR(0, 1112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__12);
  __Pyx_GIVEREF(__pyx_slice__12);

  /* "cpymad/libmadx.pyx":1149
 *     if node.p_elem is NULL:
 *         # Maybe this is a valid case, but better detect it with boom!
 *         raise RuntimeError("Empty node or subsequence! Please report this incident!")             # <<<<<<<<<<<<<<
 *     data = _get_element(node.p_elem)
 *     if not line:
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_Empty_node_or_subsequence_Please); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 1149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "cpymad/libmadx.pyx":1154
 *         # Update `at` command parameters in order to avoid surprises when
 *         # specifying `at` value for elements defined outside the sequence:
 *         data['data']['at'] = Parameter(             # <<<<<<<<<<<<<<
 *             'at', *_expr(node.at_expr, node.at_value),
 *             dtype=clib.PARAM_TYPE_DOUBLE, inform=1)
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_n_u_at); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "cpymad/libmadx.pyx":128
 * 
 * 
 * def _get_rightmost_word(sentence):             # <<<<<<<<<<<<<<
 *     """Get the work right of the rightmost space character."""
 *     return sentence.rsplit(' ', 1)[-1]
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_n_s_sentence); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);
  __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_rightmost_word, 128, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 128, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":133
 * 
 * 
 * def get_version_number():             # <<<<<<<<<<<<<<
 *     """
 *     Get the version number of loaded MAD-X interpreter.
 */
  __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_version_number, 133, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 133, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":143
 * 
 * 
 * def get_version_date():             # <<<<<<<<<<<<<<
 *     """
 *     Get the release date of loaded MAD-X interpreter.
 */
  __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_version_date, 143, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 143, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":153
 * 
 * 
 * def is_started():             # <<<<<<<<<<<<<<
 *     """
 *     Check whether MAD-X has been initialized.
 */
  __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_is_started, 153, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 153, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":163
 * 
 * 
 * def start():             # <<<<<<<<<<<<<<
 *     """
 *     Initialize MAD-X.
 */
  __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_start, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 163, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":172
 * 
 * 
 * def finish():             # <<<<<<<<<<<<<<
 *     """
 *     Cleanup MAD-X.
 */
  __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_finish, 172, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 172, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":181
 * 
 * 
 * def input(cmd):             # <<<<<<<<<<<<<<
 *     """
 *     Pass one input command to MAD-X.
 */
  __pyx_tuple__23 = PyTuple_Pack(4, __pyx_n_s_cmd, __pyx_n_s_cmd_2, __pyx_n_s_pch, __pyx_n_s_error); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);
  __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_input, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 181, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":203
 * 
 * 
 * def get_var(name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the value of a global variable.
 */
  __pyx_tuple__25 = PyTuple_Pack(6, __pyx_n_s_name, __pyx_n_s_var, __pyx_n_s_index, __pyx_n_s_inform, __pyx_n_s_value, __pyx_n_s_typeid); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);
  __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_var, 203, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 203, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":225
 * 
 * 
 * def get_var_type(name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the type of the variable:
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_n_s_name); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_var_type, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 225, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":237
 * 
 * 
 * def get_options():             # <<<<<<<<<<<<<<
 *     """Get the current option values."""
 *     return _parse_command(clib.options)
 */
  __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_options, 237, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 237, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":242
 * 
 * 
 * def num_globals():             # <<<<<<<<<<<<<<
 *     """
 *     Return the number of global variables.
 */
  __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_num_globals, 242, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 242, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":249
 * 
 * 
 * def get_globals():             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of names of all global variables.
 */
  __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_globals, 249, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 249, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":256
 * 
 * 
 * def sequence_exists(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check if the sequence exists.
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_n_s_sequence_name); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);
  __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_sequence_exists, 256, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 256, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":271
 * 
 * 
 * def get_sequence_twiss_table_name(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the last calculated twiss table for the given sequence.
 */
  __pyx_tuple__34 = PyTuple_Pack(2, __pyx_n_s_sequence_name, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
  __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_sequence_twiss_table_name, 271, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 271, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":287
 * 
 * 
 * def get_sequence_beam(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the beam associated to the sequence.
 */
  __pyx_tuple__36 = PyTuple_Pack(2, __pyx_n_s_sequence_name, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
  __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_sequence_beam, 287, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 287, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":303
 * 
 * 
 * def get_active_sequence_name():             # <<<<<<<<<<<<<<
 *     """
 *     Get the name of the active sequence.
 */
  __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_active_sequence_name, 303, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 303, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":316
 * 
 * 
 * def get_sequence_names():             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all sequences currently in memory.
 */
  __pyx_tuple__39 = PyTuple_Pack(3, __pyx_n_s_seqs, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);
  __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_sequence_names, 316, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 316, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":329
 * 
 * 
 * def get_sequence_count():             # <<<<<<<<<<<<<<
 *     """
 *     Get the number of all sequences currently in memory.
 */
  __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_sequence_count, 329, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 329, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":339
 * 
 * 
 * def table_exists(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check if the table exists.
 */
  __pyx_tuple__42 = PyTuple_Pack(2, __pyx_n_s_table_name, __pyx_n_s_table_name_2); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);
  __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_table_exists, 339, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 339, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":351
 * 
 * 
 * def get_table_names():             # <<<<<<<<<<<<<<
 *     """
 *     Return list of all table names.
 */
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_n_s_i); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);
  __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_names, 351, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 351, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":362
 * 
 * 
 * def get_table_count():             # <<<<<<<<<<<<<<
 *     """
 *     Return number of existing tables.
 */
  __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_count, 362, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 362, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":372
 * 
 * 
 * def get_table_summary(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get table summary.
 */
  __pyx_tuple__47 = PyTuple_Pack(5, __pyx_n_s_table_name, __pyx_n_s_table_name_2, __pyx_n_s_header, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);
  __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_summary, 372, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 372, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":389
 * 
 * 
 * def get_table_column_names(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all column names in the table that were selected for output.
 */
  __pyx_tuple__49 = PyTuple_Pack(5, __pyx_n_s_table_name, __pyx_n_s_table, __pyx_n_s_indices, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);
  __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_column_names, 389, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 389, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":405
 * 
 * 
 * def get_table_column_names_all(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all column names in the table.
 */
  __pyx_tuple__51 = PyTuple_Pack(2, __pyx_n_s_table_name, __pyx_n_s_table); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);
  __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_column_names_all, 405, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 405, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":420
 * 
 * 
 * def get_table_column_count(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a number of columns selected for display in the table.
 */
  __pyx_tuple__53 = PyTuple_Pack(2, __pyx_n_s_table_name, __pyx_n_s_table); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);
  __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_column_count, 420, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 420, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":433
 * 
 * 
 * def get_table_column_count_all(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a number of columns in the table.
 */
  __pyx_tuple__55 = PyTuple_Pack(2, __pyx_n_s_table_name, __pyx_n_s_table); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);
  __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_column_count_all, 433, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 433, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":446
 * 
 * 
 * def get_table_column(table_name, column_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get data from the specified table.
 */
  __pyx_tuple__57 = PyTuple_Pack(12, __pyx_n_s_table_name, __pyx_n_s_column_name, __pyx_n_s_char_tmp, __pyx_n_s_tab_name, __pyx_n_s_col_name, __pyx_n_s_info, __pyx_n_s_dtype, __pyx_n_s_size, __pyx_n_s_addr, __pyx_n_s_array_type, __pyx_n_s_array_data, __pyx_n_s_i); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);
  __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(2, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_column, 446, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 446, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":489
 * 
 * 
 * def get_table_row(table_name, row_index, columns='selected'):             # <<<<<<<<<<<<<<
 *     """
 *     Return row as tuple of values.
 */
  __pyx_tuple__59 = PyTuple_Pack(11, __pyx_n_s_table_name, __pyx_n_s_row_index, __pyx_n_s_columns, __pyx_n_s_table, __pyx_n_s_fetch_value, __pyx_n_s_fetch_value, __pyx_n_s_indices, __pyx_n_s_col, __pyx_n_s_idx, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);
  __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_row, 489, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 489, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":539
 * 
 * 
 * def get_table_row_count(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return total number of rows in the table.
 */
  __pyx_tuple__61 = PyTuple_Pack(1, __pyx_n_s_table_name); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);
  __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_row_count, 539, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) __PYX_ERR(0, 539, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":546
 * 
 * 
 * def get_table_row_names(table_name, indices=None):             # <<<<<<<<<<<<<<
 *     """
 *     Return row names for every index (row number) in the list.
 */
  __pyx_tuple__63 = PyTuple_Pack(4, __pyx_n_s_table_name, __pyx_n_s_indices, __pyx_n_s_table, __pyx_n_s_i); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);
  __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_table_row_names, 546, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 546, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":558
 * 
 * 
 * def apply_table_selections(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Apply the SELECT/DESELECT commands for table columns/rows.
 */
  __pyx_tuple__65 = PyTuple_Pack(3, __pyx_n_s_table_name, __pyx_n_s_t, __pyx_n_s_version_info); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);
  __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_apply_table_selections, 558, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) __PYX_ERR(0, 558, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":572
 * 
 * 
 * def get_element(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the original sequence.
 */
  __pyx_tuple__67 = PyTuple_Pack(3, __pyx_n_s_sequence_name, __pyx_n_s_element_index, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);
  __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_element, 572, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) __PYX_ERR(0, 572, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":590
 * 
 * 
 * def get_element_positions(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with positions of all elements of a specific sequence.
 */
  __pyx_tuple__69 = PyTuple_Pack(5, __pyx_n_s_sequence_name, __pyx_n_s_seq, __pyx_n_s_i, __pyx_n_s_nodes, __pyx_n_s_i); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 590, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);
  __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_element_positions, 590, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 590, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":605
 *             for i in range(seq.nodes.curr)]
 * 
 * def get_element_names(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */
  __pyx_tuple__71 = PyTuple_Pack(4, __pyx_n_s_sequence_name, __pyx_n_s_seq, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);
  __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_element_names, 605, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 605, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":620
 * 
 * 
 * def get_element_name(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */
  __pyx_tuple__73 = PyTuple_Pack(3, __pyx_n_s_sequence_name, __pyx_n_s_element_index, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);
  __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_element_name, 620, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) __PYX_ERR(0, 620, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":638
 * 
 * 
 * def get_element_index(sequence_name, element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the original sequence.
 */
  __pyx_tuple__75 = PyTuple_Pack(5, __pyx_n_s_sequence_name, __pyx_n_s_element_name, __pyx_n_s_seq, __pyx_n_s_element_name_2, __pyx_n_s_index); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);
  __pyx_codeobj__76 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_element_index, 638, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__76)) __PYX_ERR(0, 638, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":656
 * 
 * 
 * def get_element_index_by_position(sequence_name, position):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element at specified position in the original sequence.
 */
  __pyx_tuple__77 = PyTuple_Pack(7, __pyx_n_s_sequence_name, __pyx_n_s_position, __pyx_n_s_seq, __pyx_n_s_position_2, __pyx_n_s_elem, __pyx_n_s_at, __pyx_n_s_i); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);
  __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_element_index_by_position, 656, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) __PYX_ERR(0, 656, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":681
 * 
 * 
 * def get_element_count(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return number of elements in the original sequence.
 */
  __pyx_tuple__79 = PyTuple_Pack(2, __pyx_n_s_sequence_name, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);
  __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_element_count, 681, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) __PYX_ERR(0, 681, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":694
 * 
 * 
 * def get_expanded_element(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the expanded sequence.
 */
  __pyx_tuple__81 = PyTuple_Pack(3, __pyx_n_s_sequence_name, __pyx_n_s_element_index, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
  __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_expanded_element, 694, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) __PYX_ERR(0, 694, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":716
 * 
 * 
 * def get_expanded_element_positions(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with positions of all elements of a specific sequence.
 */
  __pyx_tuple__83 = PyTuple_Pack(5, __pyx_n_s_sequence_name, __pyx_n_s_seq, __pyx_n_s_i, __pyx_n_s_nodes, __pyx_n_s_i); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);
  __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_expanded_element_positions, 716, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) __PYX_ERR(0, 716, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":732
 * 
 * 
 * def get_expanded_element_names(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */
  __pyx_tuple__85 = PyTuple_Pack(4, __pyx_n_s_sequence_name, __pyx_n_s_seq, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);
  __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__85, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_expanded_element_names, 732, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) __PYX_ERR(0, 732, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":747
 * 
 * 
 * def get_expanded_element_name(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */
  __pyx_tuple__87 = PyTuple_Pack(3, __pyx_n_s_sequence_name, __pyx_n_s_element_index, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);
  __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_expanded_element_name, 747, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) __PYX_ERR(0, 747, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":766
 * 
 * 
 * def get_expanded_element_index(sequence_name, element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the expanded sequence.
 */
  __pyx_tuple__89 = PyTuple_Pack(5, __pyx_n_s_sequence_name, __pyx_n_s_element_name, __pyx_n_s_seq, __pyx_n_s_element_name_2, __pyx_n_s_i); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);
  __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_expanded_element_index, 766, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) __PYX_ERR(0, 766, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":789
 * 
 * 
 * def get_expanded_element_index_by_position(sequence_name, position):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element at specified position in the expanded sequence.
 */
  __pyx_tuple__91 = PyTuple_Pack(7, __pyx_n_s_sequence_name, __pyx_n_s_position, __pyx_n_s_seq, __pyx_n_s_position_2, __pyx_n_s_elem, __pyx_n_s_at, __pyx_n_s_i); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);
  __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__91, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_expanded_element_index_by_po, 789, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) __PYX_ERR(0, 789, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":814
 * 
 * 
 * def get_expanded_element_count(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return number of elements in the expanded sequence.
 */
  __pyx_tuple__93 = PyTuple_Pack(2, __pyx_n_s_sequence_name, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);
  __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__93, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_expanded_element_count, 814, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) __PYX_ERR(0, 814, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":827
 * 
 * 
 * def get_global_element(element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the expanded sequence.
 */
  __pyx_tuple__95 = PyTuple_Pack(2, __pyx_n_s_element_index, __pyx_n_s_elems); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);
  __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__95, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_global_element, 827, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) __PYX_ERR(0, 827, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":843
 * 
 * 
 * def get_global_element_name(element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return name of element.
 */
  __pyx_tuple__97 = PyTuple_Pack(2, __pyx_n_s_element_index, __pyx_n_s_elems); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);
  __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__97, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_global_element_name, 843, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) __PYX_ERR(0, 843, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":859
 * 
 * 
 * def get_global_element_index(element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the global element list.
 */
  __pyx_tuple__99 = PyTuple_Pack(2, __pyx_n_s_element_name, __pyx_n_s_element_name_2); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);
  __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__99, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_global_element_index, 859, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) __PYX_ERR(0, 859, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":871
 * 
 * 
 * def get_global_element_count():             # <<<<<<<<<<<<<<
 *     """
 *     Return number of globally visible elements.
 */
  __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_global_element_count, 871, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(0, 871, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":878
 * 
 * 
 * def get_base_type_names():             # <<<<<<<<<<<<<<
 *     """
 *     Return list of element names for base types.
 */
  __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_base_type_names, 878, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) __PYX_ERR(0, 878, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":885
 * 
 * 
 * def get_defined_command(command_name):             # <<<<<<<<<<<<<<
 *     """Return MAD-X command as dict of values."""
 *     cdef bytes _command_name = _cstr(command_name)
 */
  __pyx_tuple__103 = PyTuple_Pack(3, __pyx_n_s_command_name, __pyx_n_s_command_name_2, __pyx_n_s_index); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);
  __pyx_codeobj__104 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__103, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_defined_command, 885, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__104)) __PYX_ERR(0, 885, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":894
 * 
 * 
 * def get_defined_command_names():             # <<<<<<<<<<<<<<
 *     """Return list of MAD-X command names."""
 *     return _name_list(clib.defined_commands.list)
 */
  __pyx_codeobj__105 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_get_defined_command_names, 894, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__105)) __PYX_ERR(0, 894, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":899
 * 
 * 
 * def is_sequence_expanded(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check whether a sequence has already been expanded.
 */
  __pyx_tuple__106 = PyTuple_Pack(2, __pyx_n_s_sequence_name, __pyx_n_s_seq); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);
  __pyx_codeobj__107 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__106, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_is_sequence_expanded, 899, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__107)) __PYX_ERR(0, 899, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":912
 * 
 * 
 * def eval(expression):             # <<<<<<<<<<<<<<
 *     """
 *     Evaluates an expression and returns the result as double.
 */
  __pyx_tuple__108 = PyTuple_Pack(3, __pyx_n_s_expression, __pyx_n_s_expr, __pyx_n_s_value); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);
  __pyx_codeobj__109 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__108, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_eval, 912, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__109)) __PYX_ERR(0, 912, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":933
 * 
 * 
 * def expression_vars(expression):             # <<<<<<<<<<<<<<
 *     """
 *     Returns all the variables in an expression.
 */
  __pyx_tuple__110 = PyTuple_Pack(6, __pyx_n_s_expression, __pyx_n_s_expr, __pyx_n_s_i, __pyx_n_s_vars, __pyx_n_s_i, __pyx_n_s_k); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 933, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);
  __pyx_codeobj__111 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__110, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cpymad_libmadx_pyx, __pyx_n_s_expression_vars, 933, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__111)) __PYX_ERR(0, 933, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_100000000 = PyInt_FromLong(100000000L); if (unlikely(!__pyx_int_100000000)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_6cpymad_7libmadx___pyx_scope_struct__get_table_row) < 0) __PYX_ERR(0, 489, __pyx_L1_error)
  __pyx_type_6cpymad_7libmadx___pyx_scope_struct__get_table_row.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6cpymad_7libmadx___pyx_scope_struct__get_table_row.tp_dictoffset && __pyx_type_6cpymad_7libmadx___pyx_scope_struct__get_table_row.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6cpymad_7libmadx___pyx_scope_struct__get_table_row.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6cpymad_7libmadx___pyx_scope_struct__get_table_row = &__pyx_type_6cpymad_7libmadx___pyx_scope_struct__get_table_row;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#if PY_MAJOR_VERSION < 3
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC void
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#else
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initlibmadx(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initlibmadx(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_libmadx(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_libmadx(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_libmadx(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'libmadx' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_libmadx(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("libmadx", __pyx_methods, __pyx_k_Low_level_cython_binding_to_MAD, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_cpymad__libmadx) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "cpymad.libmadx")) {
      if (unlikely(PyDict_SetItemString(modules, "cpymad.libmadx", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  (void)__Pyx_modinit_type_import_code();
  (void)__Pyx_modinit_variable_import_code();
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "cpymad/libmadx.pyx":17
 * """
 * 
 * from os import chdir, getcwd             # <<<<<<<<<<<<<<
 * 
 * import ctypes
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_chdir);
  __Pyx_GIVEREF(__pyx_n_s_chdir);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_chdir);
  __Pyx_INCREF(__pyx_n_s_getcwd);
  __Pyx_GIVEREF(__pyx_n_s_getcwd);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_getcwd);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_os, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_chdir); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_chdir, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_getcwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_getcwd, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":19
 * from os import chdir, getcwd
 * 
 * import ctypes             # <<<<<<<<<<<<<<
 * import numpy as np      # Import the Python-level symbols of numpy
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_ctypes, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ctypes, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":20
 * 
 * import ctypes
 * import numpy as np      # Import the Python-level symbols of numpy             # <<<<<<<<<<<<<<
 * 
 * # Import a large-enough integer type to hold pointer, see also:
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":31
 *     char* strchr(char* s, int c)
 * 
 * from cpymad.types import Constraint, Parameter             # <<<<<<<<<<<<<<
 * from cpymad.util import name_to_internal, name_from_internal, normalize_range_name
 * cimport cpymad.clibmadx as clib
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Constraint);
  __Pyx_GIVEREF(__pyx_n_s_Constraint);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Constraint);
  __Pyx_INCREF(__pyx_n_s_Parameter);
  __Pyx_GIVEREF(__pyx_n_s_Parameter);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_Parameter);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cpymad_types, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Constraint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Constraint, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Parameter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Parameter, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpymad/libmadx.pyx":32
 * 
 * from cpymad.types import Constraint, Parameter
 * from cpymad.util import name_to_internal, name_from_internal, normalize_range_name             # <<<<<<<<<<<<<<
 * cimport cpymad.clibmadx as clib
 * 
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_name_to_internal);
  __Pyx_GIVEREF(__pyx_n_s_name_to_internal);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_name_to_internal);
  __Pyx_INCREF(__pyx_n_s_name_from_internal);
  __Pyx_GIVEREF(__pyx_n_s_name_from_internal);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_name_from_internal);
  __Pyx_INCREF(__pyx_n_s_normalize_range_name);
  __Pyx_GIVEREF(__pyx_n_s_normalize_range_name);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_normalize_range_name);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cpymad_util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_name_to_internal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_name_to_internal, __pyx_t_1) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_name_from_internal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_name_from_internal, __pyx_t_1) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_normalize_range_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_normalize_range_name, __pyx_t_1) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":37
 * 
 * # Remember whether start() was called
 * _madx_started = False             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_madx_started, Py_False) < 0) __PYX_ERR(0, 37, __pyx_L1_error)

  /* "cpymad/libmadx.pyx":41
 * 
 * # Python-level binding to libmadx:
 * __all__ = [             # <<<<<<<<<<<<<<
 *     # MAD-X version
 *     'get_version_number',
 */
  __pyx_t_2 = PyList_New(55); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_u_get_version_number);
  __Pyx_GIVEREF(__pyx_n_u_get_version_number);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_u_get_version_number);
  __Pyx_INCREF(__pyx_n_u_get_version_date);
  __Pyx_GIVEREF(__pyx_n_u_get_version_date);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_get_version_date);
  __Pyx_INCREF(__pyx_n_u_is_started);
  __Pyx_GIVEREF(__pyx_n_u_is_started);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_u_is_started);
  __Pyx_INCREF(__pyx_n_u_start);
  __Pyx_GIVEREF(__pyx_n_u_start);
  PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_u_start);
  __Pyx_INCREF(__pyx_n_u_finish);
  __Pyx_GIVEREF(__pyx_n_u_finish);
  PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_u_finish);
  __Pyx_INCREF(__pyx_n_u_input);
  __Pyx_GIVEREF(__pyx_n_u_input);
  PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_u_input);
  __Pyx_INCREF(__pyx_n_u_eval);
  __Pyx_GIVEREF(__pyx_n_u_eval);
  PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_u_eval);
  __Pyx_INCREF(__pyx_n_u_get_var);
  __Pyx_GIVEREF(__pyx_n_u_get_var);
  PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_u_get_var);
  __Pyx_INCREF(__pyx_n_u_num_globals);
  __Pyx_GIVEREF(__pyx_n_u_num_globals);
  PyList_SET_ITEM(__pyx_t_2, 8, __pyx_n_u_num_globals);
  __Pyx_INCREF(__pyx_n_u_get_globals);
  __Pyx_GIVEREF(__pyx_n_u_get_globals);
  PyList_SET_ITEM(__pyx_t_2, 9, __pyx_n_u_get_globals);
  __Pyx_INCREF(__pyx_n_u_get_var_type);
  __Pyx_GIVEREF(__pyx_n_u_get_var_type);
  PyList_SET_ITEM(__pyx_t_2, 10, __pyx_n_u_get_var_type);
  __Pyx_INCREF(__pyx_n_u_get_options);
  __Pyx_GIVEREF(__pyx_n_u_get_options);
  PyList_SET_ITEM(__pyx_t_2, 11, __pyx_n_u_get_options);
  __Pyx_INCREF(__pyx_n_u_sequence_exists);
  __Pyx_GIVEREF(__pyx_n_u_sequence_exists);
  PyList_SET_ITEM(__pyx_t_2, 12, __pyx_n_u_sequence_exists);
  __Pyx_INCREF(__pyx_n_u_get_sequence_names);
  __Pyx_GIVEREF(__pyx_n_u_get_sequence_names);
  PyList_SET_ITEM(__pyx_t_2, 13, __pyx_n_u_get_sequence_names);
  __Pyx_INCREF(__pyx_n_u_get_sequence_count);
  __Pyx_GIVEREF(__pyx_n_u_get_sequence_count);
  PyList_SET_ITEM(__pyx_t_2, 14, __pyx_n_u_get_sequence_count);
  __Pyx_INCREF(__pyx_n_u_get_active_sequence_name);
  __Pyx_GIVEREF(__pyx_n_u_get_active_sequence_name);
  PyList_SET_ITEM(__pyx_t_2, 15, __pyx_n_u_get_active_sequence_name);
  __Pyx_INCREF(__pyx_n_u_get_sequence_twiss_table_name);
  __Pyx_GIVEREF(__pyx_n_u_get_sequence_twiss_table_name);
  PyList_SET_ITEM(__pyx_t_2, 16, __pyx_n_u_get_sequence_twiss_table_name);
  __Pyx_INCREF(__pyx_n_u_get_sequence_beam);
  __Pyx_GIVEREF(__pyx_n_u_get_sequence_beam);
  PyList_SET_ITEM(__pyx_t_2, 17, __pyx_n_u_get_sequence_beam);
  __Pyx_INCREF(__pyx_n_u_is_sequence_expanded);
  __Pyx_GIVEREF(__pyx_n_u_is_sequence_expanded);
  PyList_SET_ITEM(__pyx_t_2, 18, __pyx_n_u_is_sequence_expanded);
  __Pyx_INCREF(__pyx_n_u_table_exists);
  __Pyx_GIVEREF(__pyx_n_u_table_exists);
  PyList_SET_ITEM(__pyx_t_2, 19, __pyx_n_u_table_exists);
  __Pyx_INCREF(__pyx_n_u_get_table_names);
  __Pyx_GIVEREF(__pyx_n_u_get_table_names);
  PyList_SET_ITEM(__pyx_t_2, 20, __pyx_n_u_get_table_names);
  __Pyx_INCREF(__pyx_n_u_get_table_count);
  __Pyx_GIVEREF(__pyx_n_u_get_table_count);
  PyList_SET_ITEM(__pyx_t_2, 21, __pyx_n_u_get_table_count);
  __Pyx_INCREF(__pyx_n_u_get_table_summary);
  __Pyx_GIVEREF(__pyx_n_u_get_table_summary);
  PyList_SET_ITEM(__pyx_t_2, 22, __pyx_n_u_get_table_summary);
  __Pyx_INCREF(__pyx_n_u_get_table_column_names);
  __Pyx_GIVEREF(__pyx_n_u_get_table_column_names);
  PyList_SET_ITEM(__pyx_t_2, 23, __pyx_n_u_get_table_column_names);
  __Pyx_INCREF(__pyx_n_u_get_table_column_names_all);
  __Pyx_GIVEREF(__pyx_n_u_get_table_column_names_all);
  PyList_SET_ITEM(__pyx_t_2, 24, __pyx_n_u_get_table_column_names_all);
  __Pyx_INCREF(__pyx_n_u_get_table_column_count);
  __Pyx_GIVEREF(__pyx_n_u_get_table_column_count);
  PyList_SET_ITEM(__pyx_t_2, 25, __pyx_n_u_get_table_column_count);
  __Pyx_INCREF(__pyx_n_u_get_table_column_count_all);
  __Pyx_GIVEREF(__pyx_n_u_get_table_column_count_all);
  PyList_SET_ITEM(__pyx_t_2, 26, __pyx_n_u_get_table_column_count_all);
  __Pyx_INCREF(__pyx_n_u_get_table_column);
  __Pyx_GIVEREF(__pyx_n_u_get_table_column);
  PyList_SET_ITEM(__pyx_t_2, 27, __pyx_n_u_get_table_column);
  __Pyx_INCREF(__pyx_n_u_get_table_row);
  __Pyx_GIVEREF(__pyx_n_u_get_table_row);
  PyList_SET_ITEM(__pyx_t_2, 28, __pyx_n_u_get_table_row);
  __Pyx_INCREF(__pyx_n_u_get_table_row_count);
  __Pyx_GIVEREF(__pyx_n_u_get_table_row_count);
  PyList_SET_ITEM(__pyx_t_2, 29, __pyx_n_u_get_table_row_count);
  __Pyx_INCREF(__pyx_n_u_get_table_row_names);
  __Pyx_GIVEREF(__pyx_n_u_get_table_row_names);
  PyList_SET_ITEM(__pyx_t_2, 30, __pyx_n_u_get_table_row_names);
  __Pyx_INCREF(__pyx_n_u_apply_table_selections);
  __Pyx_GIVEREF(__pyx_n_u_apply_table_selections);
  PyList_SET_ITEM(__pyx_t_2, 31, __pyx_n_u_apply_table_selections);
  __Pyx_INCREF(__pyx_n_u_get_element);
  __Pyx_GIVEREF(__pyx_n_u_get_element);
  PyList_SET_ITEM(__pyx_t_2, 32, __pyx_n_u_get_element);
  __Pyx_INCREF(__pyx_n_u_get_element_name);
  __Pyx_GIVEREF(__pyx_n_u_get_element_name);
  PyList_SET_ITEM(__pyx_t_2, 33, __pyx_n_u_get_element_name);
  __Pyx_INCREF(__pyx_n_u_get_element_positions);
  __Pyx_GIVEREF(__pyx_n_u_get_element_positions);
  PyList_SET_ITEM(__pyx_t_2, 34, __pyx_n_u_get_element_positions);
  __Pyx_INCREF(__pyx_n_u_get_element_names);
  __Pyx_GIVEREF(__pyx_n_u_get_element_names);
  PyList_SET_ITEM(__pyx_t_2, 35, __pyx_n_u_get_element_names);
  __Pyx_INCREF(__pyx_n_u_get_element_index);
  __Pyx_GIVEREF(__pyx_n_u_get_element_index);
  PyList_SET_ITEM(__pyx_t_2, 36, __pyx_n_u_get_element_index);
  __Pyx_INCREF(__pyx_n_u_get_element_index_by_position);
  __Pyx_GIVEREF(__pyx_n_u_get_element_index_by_position);
  PyList_SET_ITEM(__pyx_t_2, 37, __pyx_n_u_get_element_index_by_position);
  __Pyx_INCREF(__pyx_n_u_get_element_count);
  __Pyx_GIVEREF(__pyx_n_u_get_element_count);
  PyList_SET_ITEM(__pyx_t_2, 38, __pyx_n_u_get_element_count);
  __Pyx_INCREF(__pyx_n_u_get_expanded_element);
  __Pyx_GIVEREF(__pyx_n_u_get_expanded_element);
  PyList_SET_ITEM(__pyx_t_2, 39, __pyx_n_u_get_expanded_element);
  __Pyx_INCREF(__pyx_n_u_get_expanded_element_name);
  __Pyx_GIVEREF(__pyx_n_u_get_expanded_element_name);
  PyList_SET_ITEM(__pyx_t_2, 40, __pyx_n_u_get_expanded_element_name);
  __Pyx_INCREF(__pyx_n_u_get_expanded_element_positions);
  __Pyx_GIVEREF(__pyx_n_u_get_expanded_element_positions);
  PyList_SET_ITEM(__pyx_t_2, 41, __pyx_n_u_get_expanded_element_positions);
  __Pyx_INCREF(__pyx_n_u_get_expanded_element_names);
  __Pyx_GIVEREF(__pyx_n_u_get_expanded_element_names);
  PyList_SET_ITEM(__pyx_t_2, 42, __pyx_n_u_get_expanded_element_names);
  __Pyx_INCREF(__pyx_n_u_get_expanded_element_index);
  __Pyx_GIVEREF(__pyx_n_u_get_expanded_element_index);
  PyList_SET_ITEM(__pyx_t_2, 43, __pyx_n_u_get_expanded_element_index);
  __Pyx_INCREF(__pyx_n_u_get_expanded_element_index_by_po);
  __Pyx_GIVEREF(__pyx_n_u_get_expanded_element_index_by_po);
  PyList_SET_ITEM(__pyx_t_2, 44, __pyx_n_u_get_expanded_element_index_by_po);
  __Pyx_INCREF(__pyx_n_u_get_expanded_element_count);
  __Pyx_GIVEREF(__pyx_n_u_get_expanded_element_count);
  PyList_SET_ITEM(__pyx_t_2, 45, __pyx_n_u_get_expanded_element_count);
  __Pyx_INCREF(__pyx_n_u_get_global_element);
  __Pyx_GIVEREF(__pyx_n_u_get_global_element);
  PyList_SET_ITEM(__pyx_t_2, 46, __pyx_n_u_get_global_element);
  __Pyx_INCREF(__pyx_n_u_get_global_element_name);
  __Pyx_GIVEREF(__pyx_n_u_get_global_element_name);
  PyList_SET_ITEM(__pyx_t_2, 47, __pyx_n_u_get_global_element_name);
  __Pyx_INCREF(__pyx_n_u_get_global_element_index);
  __Pyx_GIVEREF(__pyx_n_u_get_global_element_index);
  PyList_SET_ITEM(__pyx_t_2, 48, __pyx_n_u_get_global_element_index);
  __Pyx_INCREF(__pyx_n_u_get_global_element_count);
  __Pyx_GIVEREF(__pyx_n_u_get_global_element_count);
  PyList_SET_ITEM(__pyx_t_2, 49, __pyx_n_u_get_global_element_count);
  __Pyx_INCREF(__pyx_n_u_get_base_type_names);
  __Pyx_GIVEREF(__pyx_n_u_get_base_type_names);
  PyList_SET_ITEM(__pyx_t_2, 50, __pyx_n_u_get_base_type_names);
  __Pyx_INCREF(__pyx_n_u_get_defined_command);
  __Pyx_GIVEREF(__pyx_n_u_get_defined_command);
  PyList_SET_ITEM(__pyx_t_2, 51, __pyx_n_u_get_defined_command);
  __Pyx_INCREF(__pyx_n_u_get_defined_command_names);
  __Pyx_GIVEREF(__pyx_n_u_get_defined_command_names);
  PyList_SET_ITEM(__pyx_t_2, 52, __pyx_n_u_get_defined_command_names);
  __Pyx_INCREF(__pyx_n_u_chdir);
  __Pyx_GIVEREF(__pyx_n_u_chdir);
  PyList_SET_ITEM(__pyx_t_2, 53, __pyx_n_u_chdir);
  __Pyx_INCREF(__pyx_n_u_getcwd);
  __Pyx_GIVEREF(__pyx_n_u_getcwd);
  PyList_SET_ITEM(__pyx_t_2, 54, __pyx_n_u_getcwd);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all_2, __pyx_t_2) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":128
 * 
 * 
 * def _get_rightmost_word(sentence):             # <<<<<<<<<<<<<<
 *     """Get the work right of the rightmost space character."""
 *     return sentence.rsplit(' ', 1)[-1]
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_1_get_rightmost_word, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_rightmost_word, __pyx_t_2) < 0) __PYX_ERR(0, 128, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":133
 * 
 * 
 * def get_version_number():             # <<<<<<<<<<<<<<
 *     """
 *     Get the version number of loaded MAD-X interpreter.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_3get_version_number, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version_number, __pyx_t_2) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":143
 * 
 * 
 * def get_version_date():             # <<<<<<<<<<<<<<
 *     """
 *     Get the release date of loaded MAD-X interpreter.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_5get_version_date, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version_date, __pyx_t_2) < 0) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":153
 * 
 * 
 * def is_started():             # <<<<<<<<<<<<<<
 *     """
 *     Check whether MAD-X has been initialized.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_7is_started, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_started, __pyx_t_2) < 0) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":163
 * 
 * 
 * def start():             # <<<<<<<<<<<<<<
 *     """
 *     Initialize MAD-X.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_9start, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_start, __pyx_t_2) < 0) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":172
 * 
 * 
 * def finish():             # <<<<<<<<<<<<<<
 *     """
 *     Cleanup MAD-X.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_11finish, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_finish, __pyx_t_2) < 0) __PYX_ERR(0, 172, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":181
 * 
 * 
 * def input(cmd):             # <<<<<<<<<<<<<<
 *     """
 *     Pass one input command to MAD-X.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_13input, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_input, __pyx_t_2) < 0) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":203
 * 
 * 
 * def get_var(name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the value of a global variable.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_15get_var, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_var, __pyx_t_2) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":225
 * 
 * 
 * def get_var_type(name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the type of the variable:
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_17get_var_type, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_var_type, __pyx_t_2) < 0) __PYX_ERR(0, 225, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":237
 * 
 * 
 * def get_options():             # <<<<<<<<<<<<<<
 *     """Get the current option values."""
 *     return _parse_command(clib.options)
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_19get_options, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_options, __pyx_t_2) < 0) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":242
 * 
 * 
 * def num_globals():             # <<<<<<<<<<<<<<
 *     """
 *     Return the number of global variables.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_21num_globals, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_num_globals, __pyx_t_2) < 0) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":249
 * 
 * 
 * def get_globals():             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of names of all global variables.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_23get_globals, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_globals, __pyx_t_2) < 0) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":256
 * 
 * 
 * def sequence_exists(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check if the sequence exists.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_25sequence_exists, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sequence_exists, __pyx_t_2) < 0) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":271
 * 
 * 
 * def get_sequence_twiss_table_name(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the last calculated twiss table for the given sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_27get_sequence_twiss_table_name, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_sequence_twiss_table_name, __pyx_t_2) < 0) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":287
 * 
 * 
 * def get_sequence_beam(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get the beam associated to the sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_29get_sequence_beam, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_sequence_beam, __pyx_t_2) < 0) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":303
 * 
 * 
 * def get_active_sequence_name():             # <<<<<<<<<<<<<<
 *     """
 *     Get the name of the active sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_31get_active_sequence_name, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_active_sequence_name, __pyx_t_2) < 0) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":316
 * 
 * 
 * def get_sequence_names():             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all sequences currently in memory.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_33get_sequence_names, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_sequence_names, __pyx_t_2) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":329
 * 
 * 
 * def get_sequence_count():             # <<<<<<<<<<<<<<
 *     """
 *     Get the number of all sequences currently in memory.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_35get_sequence_count, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_sequence_count, __pyx_t_2) < 0) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":339
 * 
 * 
 * def table_exists(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check if the table exists.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_37table_exists, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_table_exists, __pyx_t_2) < 0) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":351
 * 
 * 
 * def get_table_names():             # <<<<<<<<<<<<<<
 *     """
 *     Return list of all table names.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_39get_table_names, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_names, __pyx_t_2) < 0) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":362
 * 
 * 
 * def get_table_count():             # <<<<<<<<<<<<<<
 *     """
 *     Return number of existing tables.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_41get_table_count, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_count, __pyx_t_2) < 0) __PYX_ERR(0, 362, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":372
 * 
 * 
 * def get_table_summary(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get table summary.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_43get_table_summary, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_summary, __pyx_t_2) < 0) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":389
 * 
 * 
 * def get_table_column_names(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all column names in the table that were selected for output.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_45get_table_column_names, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_column_names, __pyx_t_2) < 0) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":405
 * 
 * 
 * def get_table_column_names_all(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a list of all column names in the table.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_47get_table_column_names_all, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_column_names_all, __pyx_t_2) < 0) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":420
 * 
 * 
 * def get_table_column_count(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a number of columns selected for display in the table.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_49get_table_column_count, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_column_count, __pyx_t_2) < 0) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":433
 * 
 * 
 * def get_table_column_count_all(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get a number of columns in the table.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_51get_table_column_count_all, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_column_count_all, __pyx_t_2) < 0) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":446
 * 
 * 
 * def get_table_column(table_name, column_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get data from the specified table.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_53get_table_column, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_column, __pyx_t_2) < 0) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":489
 * 
 * 
 * def get_table_row(table_name, row_index, columns='selected'):             # <<<<<<<<<<<<<<
 *     """
 *     Return row as tuple of values.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_55get_table_row, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_row, __pyx_t_2) < 0) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":539
 * 
 * 
 * def get_table_row_count(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return total number of rows in the table.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_57get_table_row_count, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_row_count, __pyx_t_2) < 0) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":546
 * 
 * 
 * def get_table_row_names(table_name, indices=None):             # <<<<<<<<<<<<<<
 *     """
 *     Return row names for every index (row number) in the list.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_59get_table_row_names, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_table_row_names, __pyx_t_2) < 0) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":558
 * 
 * 
 * def apply_table_selections(table_name):             # <<<<<<<<<<<<<<
 *     """
 *     Apply the SELECT/DESELECT commands for table columns/rows.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_61apply_table_selections, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_apply_table_selections, __pyx_t_2) < 0) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":572
 * 
 * 
 * def get_element(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the original sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_63get_element, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_element, __pyx_t_2) < 0) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":590
 * 
 * 
 * def get_element_positions(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with positions of all elements of a specific sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_65get_element_positions, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 590, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_element_positions, __pyx_t_2) < 0) __PYX_ERR(0, 590, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":605
 *             for i in range(seq.nodes.curr)]
 * 
 * def get_element_names(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_67get_element_names, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_element_names, __pyx_t_2) < 0) __PYX_ERR(0, 605, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":620
 * 
 * 
 * def get_element_name(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_69get_element_name, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_element_name, __pyx_t_2) < 0) __PYX_ERR(0, 620, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":638
 * 
 * 
 * def get_element_index(sequence_name, element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the original sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_71get_element_index, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_element_index, __pyx_t_2) < 0) __PYX_ERR(0, 638, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":656
 * 
 * 
 * def get_element_index_by_position(sequence_name, position):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element at specified position in the original sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_73get_element_index_by_position, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_element_index_by_position, __pyx_t_2) < 0) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":681
 * 
 * 
 * def get_element_count(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return number of elements in the original sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_75get_element_count, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_element_count, __pyx_t_2) < 0) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":694
 * 
 * 
 * def get_expanded_element(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the expanded sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_77get_expanded_element, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_expanded_element, __pyx_t_2) < 0) __PYX_ERR(0, 694, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":716
 * 
 * 
 * def get_expanded_element_positions(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with positions of all elements of a specific sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_79get_expanded_element_positions, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_expanded_element_positions, __pyx_t_2) < 0) __PYX_ERR(0, 716, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":732
 * 
 * 
 * def get_expanded_element_names(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_81get_expanded_element_names, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_expanded_element_names, __pyx_t_2) < 0) __PYX_ERR(0, 732, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":747
 * 
 * 
 * def get_expanded_element_name(sequence_name, element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Get list with the names of all elements of a specific sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_83get_expanded_element_name, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_expanded_element_name, __pyx_t_2) < 0) __PYX_ERR(0, 747, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":766
 * 
 * 
 * def get_expanded_element_index(sequence_name, element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the expanded sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_85get_expanded_element_index, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_expanded_element_index, __pyx_t_2) < 0) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":789
 * 
 * 
 * def get_expanded_element_index_by_position(sequence_name, position):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element at specified position in the expanded sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_87get_expanded_element_index_by_position, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_expanded_element_index_by_po, __pyx_t_2) < 0) __PYX_ERR(0, 789, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":814
 * 
 * 
 * def get_expanded_element_count(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return number of elements in the expanded sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_89get_expanded_element_count, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_expanded_element_count, __pyx_t_2) < 0) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":827
 * 
 * 
 * def get_global_element(element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return requested element in the expanded sequence.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_91get_global_element, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_global_element, __pyx_t_2) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":843
 * 
 * 
 * def get_global_element_name(element_index):             # <<<<<<<<<<<<<<
 *     """
 *     Return name of element.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_93get_global_element_name, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_global_element_name, __pyx_t_2) < 0) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":859
 * 
 * 
 * def get_global_element_index(element_name):             # <<<<<<<<<<<<<<
 *     """
 *     Return index of element with specified name in the global element list.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_95get_global_element_index, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_global_element_index, __pyx_t_2) < 0) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":871
 * 
 * 
 * def get_global_element_count():             # <<<<<<<<<<<<<<
 *     """
 *     Return number of globally visible elements.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_97get_global_element_count, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_global_element_count, __pyx_t_2) < 0) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":878
 * 
 * 
 * def get_base_type_names():             # <<<<<<<<<<<<<<
 *     """
 *     Return list of element names for base types.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_99get_base_type_names, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_base_type_names, __pyx_t_2) < 0) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":885
 * 
 * 
 * def get_defined_command(command_name):             # <<<<<<<<<<<<<<
 *     """Return MAD-X command as dict of values."""
 *     cdef bytes _command_name = _cstr(command_name)
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_101get_defined_command, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_defined_command, __pyx_t_2) < 0) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":894
 * 
 * 
 * def get_defined_command_names():             # <<<<<<<<<<<<<<
 *     """Return list of MAD-X command names."""
 *     return _name_list(clib.defined_commands.list)
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_103get_defined_command_names, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 894, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_defined_command_names, __pyx_t_2) < 0) __PYX_ERR(0, 894, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":899
 * 
 * 
 * def is_sequence_expanded(sequence_name):             # <<<<<<<<<<<<<<
 *     """
 *     Check whether a sequence has already been expanded.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_105is_sequence_expanded, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_sequence_expanded, __pyx_t_2) < 0) __PYX_ERR(0, 899, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":912
 * 
 * 
 * def eval(expression):             # <<<<<<<<<<<<<<
 *     """
 *     Evaluates an expression and returns the result as double.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_107eval, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_eval, __pyx_t_2) < 0) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":933
 * 
 * 
 * def expression_vars(expression):             # <<<<<<<<<<<<<<
 *     """
 *     Returns all the variables in an expression.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6cpymad_7libmadx_109expression_vars, NULL, __pyx_n_s_cpymad_libmadx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 933, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_expression_vars, __pyx_t_2) < 0) __PYX_ERR(0, 933, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":987
 * 
 * 
 * _expr_types = [bool, int, float]             # <<<<<<<<<<<<<<
 * 
 * cdef _expr(clib.expression* expr,
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 987, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyInt_Type)));
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyFloat_Type)));
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_expr_types, __pyx_t_2) < 0) __PYX_ERR(0, 987, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpymad/libmadx.pyx":991
 * cdef _expr(clib.expression* expr,
 *            double value,
 *            int typeid=clib.PARAM_TYPE_DOUBLE):             # <<<<<<<<<<<<<<
 *     """Return a parameter value with an appropriate type."""
 *     _type = _expr_types[typeid]
 */
  __pyx_k__9 = __pyx_e_6cpymad_8clibmadx_PARAM_TYPE_DOUBLE;

  /* "cpymad/libmadx.pyx":1
 * # cython: embedsignature=True             # <<<<<<<<<<<<<<
 * # cython: language_level=3
 * """
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init cpymad.libmadx", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cpymad.libmadx");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return dict ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
        dictptr = (offset > 0) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (!dict || tp_dict_version != __PYX_GET_DICT_VERSION(dict))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* BytesEquals */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* PyIntFromDouble */
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE PyObject* __Pyx_PyInt_FromDouble(double value) {
    if (value >= (double)LONG_MIN && value <= (double)LONG_MAX) {
        return PyInt_FromLong((long)value);
    }
    return PyLong_FromDouble(value);
}
#endif

/* None */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* FetchCommonType */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunction */
#include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* UnicodeEquals */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        #if PY_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* PyObjectGetMethod */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod1 */
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* append */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* PyIntCompare */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = Py_SIZE(op1);
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        if (intval == 0) {
            if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
        } else if (intval < 0) {
            if (size >= 0)
                Py_RETURN_FALSE;
            intval = -intval;
            size = -size;
        } else {
            if (size <= 0)
                Py_RETURN_FALSE;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
        if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    return (
        PyObject_RichCompare(op1, op2, Py_EQ));
}

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(b)
            if (unlikely(b == -1 && ((unsigned long)a) == 0-(unsigned long)a))
                return PyInt_Type.tp_as_number->nb_floor_divide(op1, op2);
            else {
                long q, r;
                q = a / b;
                r = a - q*b;
                q -= ((r != 0) & ((r ^ b) < 0));
                x = q;
            }
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_floor_divide(op1, op2);
            }
        }
                __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(b)
                {
                    long q, r;
                    q = a / b;
                    r = a - q*b;
                    q -= ((r != 0) & ((r ^ b) < 0));
                    x = q;
                }
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                {
                    PY_LONG_LONG q, r;
                    q = lla / llb;
                    r = lla - q*llb;
                    q -= ((r != 0) & ((r ^ llb) < 0));
                    llx = q;
                }
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceFloorDivide : PyNumber_FloorDivide)(op1, op2);
}
#endif

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_RemainderObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_RemainderObjC_ZeroDivisionError(b)
            x = a % b;
            x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_remainder(op1, op2);
            }
        }
                __Pyx_PyInt_RemainderObjC_ZeroDivisionError(b)
                x = a % b;
                x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla % llb;
                llx += ((llx != 0) & ((llx ^ llb) < 0)) * llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceRemainder : PyNumber_Remainder)(op1, op2);
}
#endif

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* RaiseTooManyValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* SliceObject */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* decode_c_string */
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    Py_ssize_t length;
    if (unlikely((start < 0) | (stop < 0))) {
        size_t slen = strlen(cstring);
        if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
            PyErr_SetString(PyExc_OverflowError,
                            "c-string too long to convert to Python");
            return NULL;
        }
        length = (Py_ssize_t) slen;
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    length = stop - start;
    if (unlikely(length <= 0))
        return PyUnicode_FromUnicode(NULL, 0);
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

/* DictGetItem */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) {
    const Py_intptr_t neg_one = (Py_intptr_t) ((Py_intptr_t) 0 - (Py_intptr_t) 1), const_zero = (Py_intptr_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(Py_intptr_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(Py_intptr_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
