text:
# MIT License
# Copyright (c) 2019 Dheepak Krishnamurthy

module Python

include("utils.jl")

# Python.jl interface

const Py_ssize_t = Clong
const size_t = Cint

# PyObject

mutable struct PyObject
    ob_refcnt::Py_ssize_t
    ob_type::Ptr{Cvoid}
end

# PyVarObject

mutable struct PyVarObject
    @embed PyObject
    ob_size::Py_ssize_t
end

# PyMethodDef

"""Base.@ccallable PyCFunction(::Ptr{PyObject}, ::Ptr{PyObject})::Ptr{PyObject} end"""
const PyCFunction = Ptr{Cvoid}

mutable struct PyMethodDef
    ml_name::Ptr{Cchar}
    ml_meth::PyCFunction
    ml_flags::Cint
    ml_doc::Ptr{Cchar}
end

# PyMemberDef

mutable struct PyMemberDef
    name::Ptr{Cchar}
    type::Cint
    offset::Py_ssize_t
    flags::Cint
    doc::Ptr{Cchar}
end

# PyGetSetDef

"""Base.@ccallable getter(::Ptr{PyObject}, ::Ptr{PyObject})::Ptr{PyObject}"""
const getter = Ptr{Cvoid}

"""Base.@ccallable setter(::Ptr{PyObject}, ::Ptr{PyObject}, Ptr{Cvoid})::Cint"""
const setter = Ptr{Cvoid}

mutable struct PyGetSetDef
    name::Ptr{Cchar}
    get::getter
    set::setter
    doc::Ptr{Cchar}
    closure::Ptr{Cvoid}
end

# PyModuleDef

"""Base.@ccallable _m_init()::Ptr{PyObject}"""
const _m_init = Ptr{Cvoid}

mutable struct PyModuleDef_Base
    @embed PyObject
    m_init::_m_init
    m_index::Py_ssize_t
    m_copy::Ptr{PyObject}
end

mutable struct PyModuleDef_Slot
    slot::Cint
    value::Ptr{Cvoid}
end

"""Base.@ccallable inquiry(::Ptr{PyObject})::Cint"""
const inquiry = Ptr{Cvoid}

"""Base.@ccallable traverseproc(::Ptr{PyObject}, ::visitproc, ::Ptr{Cvoid})::Cint"""
const traverseproc = Ptr{Cvoid}

"""Base.@ccallable freefunc(Ptr{Cvoid})::Ptr{Cvoid}"""
const freefunc = Ptr{Cvoid}

mutable struct PyModuleDef
    @embed PyModuleDef_Base
    m_doc::Cstring
    m_size::Py_ssize_t
    m_methods::Ptr{PyMethodDef}
    m_slots::Ptr{PyModuleDef_Slot}
    m_traverse::traverseproc
    m_clear::inquiry
    m_free::freefunc
end

# PyStructSequence_Field

mutable struct PyStructSequence_Field
    name::Ptr{Cchar}
    doc::Ptr{Cchar}
end

# PyStructSequence_Desc

mutable struct PyStructSequence_Desc
    name::Ptr{Cchar}
    doc::Ptr{Cchar}
    fields::Ptr{PyStructSequence_Field}
    n_in_sequence::Cint
end

# PyType_Slot

mutable struct PyType_Slot
    slot::Cint
    pfunc::Ptr{Cvoid}
end

# PyType_Spec

mutable struct PyType_Spec
    name::Ptr{Cchar}
    basicsize::Cint
    itemsize::Cint
    flags::Cuint
    slots::Ptr{PyType_Slot}
end

# Py_REFCNT

Py_REFCNT(ob::PyObject) = ob.ob_refcnt
Py_TYPE(ob::PyObject) = ob.ob_type
Py_SIZE(ob::PyVarObject) = ob.ob_size

const PyThreadState = Cvoid
const PyInterpreterState = Cvoid
const _frame = Cvoid
const symtable = Cvoid
const _node = Cvoid
const PyWeakReference = Cvoid
const PyLongObject = Cvoid
const PyTypeObject = Cvoid

const node = _node
const PyCodeObject = Cvoid
const PyCompilerFlags = Cvoid
const mod_ty = Ptr{Cvoid}

PyAST_Check(obj::Ptr{PyObject})                                               = @ccall PyAST_Check(obj::Ptr{PyObject})::Cint)
PyAST_Compile(mod, filename, flags, arena)                                    = PyAST_CompileEx(mod, filename, flags, -1, arena)
PyAST_CompileEx(mod, filename, flags, optimize, arena)::Ptr{PyCodeObject}     = @ccall PyAST_CompileEx(mod::Ptr{Cvoid}, filename::Ptr{Cchar}, flags::Ptr{PyCompilerFlags}, optimize::Cint, arena::Ptr{PyArena}))::Ptr{PyCodeObject}
PyAST_CompileObject(mod, filename, flags, optimize, arena)::Ptr{PyCodeObject} = @ccall PyAST_CompileEx(mod::Ptr{Cvoid}, filename::Ptr{PyObject}, flags::Ptr{PyCompilerFlags}, optimize::Cint, arena::Ptr{PyArena}))::Ptr{PyCodeObject}
PyAST_FromNode(n, flags, filename, arena)                                     = @ccall PyAST_FromNode(n::Ptr{node}, flags::Ptr{PyCompilerFlags}, filename::Ptr{Cchar}, arena::Ptr{PyArena})))::mod_ty
PyAST_FromNodeObject(n, flags, filename, arena)                               = @ccall PyAST_FromNodeObject(n::Ptr{node}, flags::Ptr{PyCompilerFlags}, filename::Ptr{PyObject}, arena::Ptr{PyArena})))::mod_ty
PyAST_Validate(t)                                                             = @ccall PyAST_Validate(t::mod_ty)::Cint
PyAST_mod2obj(t)                                                              = @ccall PyAST_mod2obj(t::mod_ty)::Ptr{PyObject}
PyAST_obj2mod(ast, arena, mode)                                               = @ccall PyAST_obj2mod(ast::Ptr{PyObject}, arena::Ptr{PyArena}, mode::Cint)::mod_ty
PyArena_AddPyObject(arena, object)                                            = @ccall PyArena_AddPyObject(arena::Ptr{PyArena}, object::Ptr{PyObject})::Cint
PyArena_Free(arena)                                                           = @ccall PyArena_Free(arena::Ptr{PyArena})::Cvoid
PyArena_Malloc(arena, size)                                                   = @ccall PyArena_Malloc(arena::Ptr{PyArena}, size::size_t)
PyArena_New()                                                                 = @ccall PyArena_New()::Ptr{PyArena}
PyArg_Parse()                                         = error("Not implemented.")
PyArg_ParseTuple()                                    = error("Not implemented.")
PyArg_ParseTupleAndKeywords()                         = error("Not implemented.")
PyArg_UnpackTuple()                                   = error("Not implemented.")
PyArg_VaParse()                                       = error("Not implemented.")
PyArg_VaParseTupleAndKeywords()                       = error("Not implemented.")
PyArg_ValidateKeywordArguments()                      = error("Not implemented.")
PyAsyncGen_ClearFreeLists()                           = error("Not implemented.")
PyAsyncGen_Fini()                                     = error("Not implemented.")
PyAsyncGen_New()                                      = error("Not implemented.")
PyBool_FromLong()                                     = error("Not implemented.")
PyBuffer_FillContiguousStrides()                      = error("Not implemented.")
PyBuffer_FillInfo()                                   = error("Not implemented.")
PyBuffer_FromContiguous()                             = error("Not implemented.")
PyBuffer_GetPointer()                                 = error("Not implemented.")
PyBuffer_IsContiguous()                               = error("Not implemented.")
PyBuffer_Release()                                    = error("Not implemented.")
PyBuffer_ToContiguous()                               = error("Not implemented.")
PyByteArray_AsString()                                = error("Not implemented.")
PyByteArray_Concat()                                  = error("Not implemented.")
PyByteArray_Fini()                                    = error("Not implemented.")
PyByteArray_FromObject()                              = error("Not implemented.")
PyByteArray_FromStringAndSize()                       = error("Not implemented.")
PyByteArray_Init()                                    = error("Not implemented.")
PyByteArray_Resize()                                  = error("Not implemented.")
PyByteArray_Size()                                    = error("Not implemented.")
PyBytes_AsString()                                    = error("Not implemented.")
PyBytes_AsStringAndSize()                             = error("Not implemented.")
PyBytes_Concat()                                      = error("Not implemented.")
PyBytes_ConcatAndDel()                                = error("Not implemented.")
PyBytes_DecodeEscape()                                = error("Not implemented.")
PyBytes_Fini()                                        = error("Not implemented.")
PyBytes_FromFormat()                                  = error("Not implemented.")
PyBytes_FromFormatV()                                 = error("Not implemented.")
PyBytes_FromObject()                                  = error("Not implemented.")
PyBytes_FromString()                                  = error("Not implemented.")
PyBytes_FromStringAndSize()                           = error("Not implemented.")
PyBytes_Repr()                                        = error("Not implemented.")
PyBytes_Size()                                        = error("Not implemented.")
PyCFunction_Call()                                    = error("Not implemented.")
PyCFunction_ClearFreeList()                           = error("Not implemented.")
PyCFunction_Fini()                                    = error("Not implemented.")
PyCFunction_GetFlags()                                = error("Not implemented.")
PyCFunction_GetFunction()                             = error("Not implemented.")
PyCFunction_GetSelf()                                 = error("Not implemented.")
PyCFunction_New()                                     = error("Not implemented.")
PyCFunction_NewEx()                                   = error("Not implemented.")
PyCallIter_New()                                      = error("Not implemented.")
PyCallable_Check()                                    = error("Not implemented.")
PyCapsule_GetContext()                                = error("Not implemented.")
PyCapsule_GetDestructor()                             = error("Not implemented.")
PyCapsule_GetName()                                   = error("Not implemented.")
PyCapsule_GetPointer()                                = error("Not implemented.")
PyCapsule_Import()                                    = error("Not implemented.")
PyCapsule_IsValid()                                   = error("Not implemented.")
PyCapsule_New()                                       = error("Not implemented.")
PyCapsule_SetContext()                                = error("Not implemented.")
PyCapsule_SetDestructor()                             = error("Not implemented.")
PyCapsule_SetName()                                   = error("Not implemented.")
PyCapsule_SetPointer()                                = error("Not implemented.")
PyCell_Get()                                          = error("Not implemented.")
PyCell_New()                                          = error("Not implemented.")
PyCell_Set()                                          = error("Not implemented.")
PyClassMethod_New()                                   = error("Not implemented.")
PyCode_Addr2Line()                                    = error("Not implemented.")
PyCode_New()                                          = error("Not implemented.")
PyCode_NewEmpty()                                     = error("Not implemented.")
PyCode_Optimize()                                     = error("Not implemented.")
PyCodec_BackslashReplaceErrors()                      = error("Not implemented.")
PyCodec_Decode()                                      = error("Not implemented.")
PyCodec_Decoder()                                     = error("Not implemented.")
PyCodec_Encode()                                      = error("Not implemented.")
PyCodec_Encoder()                                     = error("Not implemented.")
PyCodec_IgnoreErrors()                                = error("Not implemented.")
PyCodec_IncrementalDecoder()                          = error("Not implemented.")
PyCodec_IncrementalEncoder()                          = error("Not implemented.")
PyCodec_KnownEncoding()                               = error("Not implemented.")
PyCodec_LookupError()                                 = error("Not implemented.")
PyCodec_NameReplaceErrors()                           = error("Not implemented.")
PyCodec_Register()                                    = error("Not implemented.")
PyCodec_RegisterError()                               = error("Not implemented.")
PyCodec_ReplaceErrors()                               = error("Not implemented.")
PyCodec_StreamReader()                                = error("Not implemented.")
PyCodec_StreamWriter()                                = error("Not implemented.")
PyCodec_StrictErrors()                                = error("Not implemented.")
PyCodec_XMLCharRefReplaceErrors()                     = error("Not implemented.")
PyCompileString()                                     = error("Not implemented.")
PyCompile_OpcodeStackEffect()                         = error("Not implemented.")
PyComplex_AsCComplex()                                = error("Not implemented.")
PyComplex_FromCComplex()                              = error("Not implemented.")
PyComplex_FromDoubles()                               = error("Not implemented.")
PyComplex_ImagAsDouble()                              = error("Not implemented.")
PyComplex_RealAsDouble()                              = error("Not implemented.")
PyContextVar_Get()                                    = error("Not implemented.")
PyContextVar_New()                                    = error("Not implemented.")
PyContextVar_Reset()                                  = error("Not implemented.")
PyContextVar_Set()                                    = error("Not implemented.")
PyContext_ClearFreeList()                             = error("Not implemented.")
PyContext_Copy()                                      = error("Not implemented.")
PyContext_CopyCurrent()                               = error("Not implemented.")
PyContext_Enter()                                     = error("Not implemented.")
PyContext_Exit()                                      = error("Not implemented.")
PyContext_New()                                       = error("Not implemented.")
PyCoro_New()                                          = error("Not implemented.")
PyDescr_NewClassMethod()                              = error("Not implemented.")
PyDescr_NewGetSet()                                   = error("Not implemented.")
PyDescr_NewMember()                                   = error("Not implemented.")
PyDescr_NewMethod()                                   = error("Not implemented.")
PyDescr_NewWrapper()                                  = error("Not implemented.")
PyDictProxy_New()                                     = error("Not implemented.")
PyDict_Clear()                                        = error("Not implemented.")
PyDict_ClearFreeList()                                = error("Not implemented.")
PyDict_Contains()                                     = error("Not implemented.")
PyDict_Copy()                                         = error("Not implemented.")
PyDict_DelItem()                                      = error("Not implemented.")
PyDict_DelItemString()                                = error("Not implemented.")
PyDict_Fini()                                         = error("Not implemented.")
PyDict_GetItem()                                      = error("Not implemented.")
PyDict_GetItemString()                                = error("Not implemented.")
PyDict_GetItemWithError()                             = error("Not implemented.")
PyDict_Items()                                        = error("Not implemented.")
PyDict_Keys()                                         = error("Not implemented.")
PyDict_Merge()                                        = error("Not implemented.")
PyDict_MergeFromSeq2()                                = error("Not implemented.")
PyDict_New()                                          = error("Not implemented.")
PyDict_Next()                                         = error("Not implemented.")
PyDict_SetDefault()                                   = error("Not implemented.")
PyDict_SetItem()                                      = error("Not implemented.")
PyDict_SetItemString()                                = error("Not implemented.")
PyDict_Size()                                         = error("Not implemented.")
PyDict_Update()                                       = error("Not implemented.")
PyDict_Values()                                       = error("Not implemented.")
PyErr_BadArgument()                                   = error("Not implemented.")
PyErr_BadInternalCall()                               = error("Not implemented.")
PyErr_CheckSignals()                                  = error("Not implemented.")
PyErr_Clear()                                         = error("Not implemented.")
PyErr_Display()                                       = error("Not implemented.")
PyErr_ExceptionMatches()                              = error("Not implemented.")
PyErr_Fetch()                                         = error("Not implemented.")
PyErr_Format()                                        = error("Not implemented.")
PyErr_FormatV()                                       = error("Not implemented.")
PyErr_GetExcInfo()                                    = error("Not implemented.")
PyErr_GivenExceptionMatches()                         = error("Not implemented.")
PyErr_NewException()                                  = error("Not implemented.")
PyErr_NewExceptionWithDoc()                           = error("Not implemented.")
PyErr_NoMemory()                                      = error("Not implemented.")
PyErr_NormalizeException()                            = error("Not implemented.")
PyErr_Occurred()                                      = error("Not implemented.")
PyErr_Print()                                         = error("Not implemented.")
PyErr_PrintEx()                                       = error("Not implemented.")
PyErr_ProgramText()                                   = error("Not implemented.")
PyErr_ProgramTextObject()                             = error("Not implemented.")
PyErr_ResourceWarning()                               = error("Not implemented.")
PyErr_Restore()                                       = error("Not implemented.")
PyErr_SetExcInfo()                                    = error("Not implemented.")
PyErr_SetFromErrno()                                  = error("Not implemented.")
PyErr_SetFromErrnoWithFilename()                      = error("Not implemented.")
PyErr_SetFromErrnoWithFilenameObject()                = error("Not implemented.")
PyErr_SetFromErrnoWithFilenameObjects()               = error("Not implemented.")
PyErr_SetImportError()                                = error("Not implemented.")
PyErr_SetImportErrorSubclass()                        = error("Not implemented.")
PyErr_SetInterrupt()                                  = error("Not implemented.")
PyErr_SetNone()                                       = error("Not implemented.")
PyErr_SetObject()                                     = error("Not implemented.")
PyErr_SetString()                                     = error("Not implemented.")
PyErr_SyntaxLocation()                                = error("Not implemented.")
PyErr_SyntaxLocationEx()                              = error("Not implemented.")
PyErr_SyntaxLocationObject()                          = error("Not implemented.")
PyErr_Warn()                                          = error("Not implemented.")
PyErr_WarnEx()                                        = error("Not implemented.")
PyErr_WarnExplicit()                                  = error("Not implemented.")
PyErr_WarnExplicitFormat()                            = error("Not implemented.")
PyErr_WarnExplicitObject()                            = error("Not implemented.")
PyErr_WarnFormat()                                    = error("Not implemented.")
PyErr_WriteUnraisable()                               = error("Not implemented.")
PyEval_AcquireLock()                                  = error("Not implemented.")
PyEval_AcquireThread()                                = error("Not implemented.")
PyEval_CallFunction()                                 = error("Not implemented.")
PyEval_CallMethod()                                   = error("Not implemented.")
PyEval_CallObjectWithKeywords()                       = error("Not implemented.")
PyEval_EvalCode()                                     = error("Not implemented.")
PyEval_EvalCodeEx()                                   = error("Not implemented.")
PyEval_EvalFrame()                                    = error("Not implemented.")
PyEval_EvalFrameEx()                                  = error("Not implemented.")
PyEval_GetBuiltins()                                  = error("Not implemented.")
PyEval_GetFrame()                                     = error("Not implemented.")
PyEval_GetFuncDesc()                                  = error("Not implemented.")
PyEval_GetFuncName()                                  = error("Not implemented.")
PyEval_GetGlobals()                                   = error("Not implemented.")
PyEval_GetLocals()                                    = error("Not implemented.")
PyEval_InitThreads()                                  = error("Not implemented.")
PyEval_MergeCompilerFlags()                           = error("Not implemented.")
PyEval_ReInitThreads()                                = error("Not implemented.")
PyEval_ReleaseLock()                                  = error("Not implemented.")
PyEval_ReleaseThread()                                = error("Not implemented.")
PyEval_RestoreThread()                                = error("Not implemented.")
PyEval_SaveThread()                                   = error("Not implemented.")
PyEval_SetProfile()                                   = error("Not implemented.")
PyEval_SetTrace()                                     = error("Not implemented.")
PyEval_ThreadsInitialized()                           = error("Not implemented.")
PyException_GetCause()                                = error("Not implemented.")
PyException_GetContext()                              = error("Not implemented.")
PyException_GetTraceback()                            = error("Not implemented.")
PyException_SetCause()                                = error("Not implemented.")
PyException_SetContext()                              = error("Not implemented.")
PyException_SetTraceback()                            = error("Not implemented.")
PyFPE_dummy()                                         = error("Not implemented.")
PyFile_FromFd()                                       = error("Not implemented.")
PyFile_GetLine()                                      = error("Not implemented.")
PyFile_NewStdPrinter()                                = error("Not implemented.")
PyFile_WriteObject()                                  = error("Not implemented.")
PyFile_WriteString()                                  = error("Not implemented.")
PyFloat_AsDouble()                                    = error("Not implemented.")
PyFloat_ClearFreeList()                               = error("Not implemented.")
PyFloat_Fini()                                        = error("Not implemented.")
PyFloat_FromDouble()                                  = error("Not implemented.")
PyFloat_FromString()                                  = error("Not implemented.")
PyFloat_GetInfo()                                     = error("Not implemented.")
PyFloat_GetMax()                                      = error("Not implemented.")
PyFloat_GetMin()                                      = error("Not implemented.")
PyFrame_BlockPop()                                    = error("Not implemented.")
PyFrame_BlockSetup()                                  = error("Not implemented.")
PyFrame_ClearFreeList()                               = error("Not implemented.")
PyFrame_FastToLocals()                                = error("Not implemented.")
PyFrame_FastToLocalsWithError()                       = error("Not implemented.")
PyFrame_Fini()                                        = error("Not implemented.")
PyFrame_GetLineNumber()                               = error("Not implemented.")
PyFrame_LocalsToFast()                                = error("Not implemented.")
PyFrame_New()                                         = error("Not implemented.")
PyFrozenSet_New()                                     = error("Not implemented.")
PyFunction_GetAnnotations()                           = error("Not implemented.")
PyFunction_GetClosure()                               = error("Not implemented.")
PyFunction_GetCode()                                  = error("Not implemented.")
PyFunction_GetDefaults()                              = error("Not implemented.")
PyFunction_GetGlobals()                               = error("Not implemented.")
PyFunction_GetKwDefaults()                            = error("Not implemented.")
PyFunction_GetModule()                                = error("Not implemented.")
PyFunction_New()                                      = error("Not implemented.")
PyFunction_NewWithQualName()                          = error("Not implemented.")
PyFunction_SetAnnotations()                           = error("Not implemented.")
PyFunction_SetClosure()                               = error("Not implemented.")
PyFunction_SetDefaults()                              = error("Not implemented.")
PyFunction_SetKwDefaults()                            = error("Not implemented.")
PyFuture_FromAST()                                    = error("Not implemented.")
PyFuture_FromASTObject()                              = error("Not implemented.")
PyGC_Collect()                                        = error("Not implemented.")
PyGILState_Check()                                    = error("Not implemented.")
PyGILState_Ensure()                                   = error("Not implemented.")
PyGILState_GetThisThreadState()                       = error("Not implemented.")
PyGILState_Release()                                  = error("Not implemented.")
PyGen_NeedsFinalizing()                               = error("Not implemented.")
PyGen_New()                                           = error("Not implemented.")
PyGen_NewWithQualName()                               = error("Not implemented.")
PyGrammar_AddAccelerators()                           = error("Not implemented.")
PyGrammar_FindDFA()                                   = error("Not implemented.")
PyGrammar_LabelRepr()                                 = error("Not implemented.")
PyGrammar_RemoveAccelerators()                        = error("Not implemented.")
PyHash_GetFuncDef()                                   = error("Not implemented.")
PyImport_AddModule()                                  = error("Not implemented.")
PyImport_AddModuleObject()                            = error("Not implemented.")
PyImport_AppendInittab()                              = error("Not implemented.")
PyImport_Cleanup()                                    = error("Not implemented.")
PyImport_ExecCodeModule()                             = error("Not implemented.")
PyImport_ExecCodeModuleEx()                           = error("Not implemented.")
PyImport_ExecCodeModuleObject()                       = error("Not implemented.")
PyImport_ExecCodeModuleWithPathnames()                = error("Not implemented.")
PyImport_ExtendInittab()                              = error("Not implemented.")
PyImport_GetImporter()                                = error("Not implemented.")
PyImport_GetMagicNumber()                             = error("Not implemented.")
PyImport_GetMagicTag()                                = error("Not implemented.")
PyImport_GetModule()                                  = error("Not implemented.")
PyImport_GetModuleDict()                              = error("Not implemented.")
PyImport_Import()                                     = error("Not implemented.")
PyImport_ImportFrozenModule()                         = error("Not implemented.")
PyImport_ImportFrozenModuleObject()                   = error("Not implemented.")
PyImport_ImportModule()                               = error("Not implemented.")
PyImport_ImportModuleLevel()                          = error("Not implemented.")
PyImport_ImportModuleLevelObject()                    = error("Not implemented.")
PyImport_ImportModuleNoBlock()                        = error("Not implemented.")
PyImport_ReloadModule()                               = error("Not implemented.")
PyInit__abc()                                         = error("Not implemented.")
PyInit__ast()                                         = error("Not implemented.")
PyInit__codecs()                                      = error("Not implemented.")
PyInit__collections()                                 = error("Not implemented.")
PyInit__functools()                                   = error("Not implemented.")
PyInit__imp()                                         = error("Not implemented.")
PyInit__io()                                          = error("Not implemented.")
PyInit__locale()                                      = error("Not implemented.")
PyInit__operator()                                    = error("Not implemented.")
PyInit__signal()                                      = error("Not implemented.")
PyInit__sre()                                         = error("Not implemented.")
PyInit__stat()                                        = error("Not implemented.")
PyInit__string()                                      = error("Not implemented.")
PyInit__symtable()                                    = error("Not implemented.")
PyInit__thread()                                      = error("Not implemented.")
PyInit__tracemalloc()                                 = error("Not implemented.")
PyInit__weakref()                                     = error("Not implemented.")
PyInit_atexit()                                       = error("Not implemented.")
PyInit_errno()                                        = error("Not implemented.")
PyInit_faulthandler()                                 = error("Not implemented.")
PyInit_gc()                                           = error("Not implemented.")
PyInit_itertools()                                    = error("Not implemented.")
PyInit_posix()                                        = error("Not implemented.")
PyInit_pwd()                                          = error("Not implemented.")
PyInit_time()                                         = error("Not implemented.")
PyInit_xxsubtype()                                    = error("Not implemented.")
PyInit_zipimport()                                    = error("Not implemented.")
PyInstanceMethod_Function()                           = error("Not implemented.")
PyInstanceMethod_New()                                = error("Not implemented.")
PyInterpreterState_Clear()                            = error("Not implemented.")
PyInterpreterState_Delete()                           = error("Not implemented.")
PyInterpreterState_GetID()                            = error("Not implemented.")
PyInterpreterState_Head()                             = error("Not implemented.")
PyInterpreterState_Main()                             = error("Not implemented.")
PyInterpreterState_New()                              = error("Not implemented.")
PyInterpreterState_Next()                             = error("Not implemented.")
PyInterpreterState_ThreadHead()                       = error("Not implemented.")
PyIter_Next()                                         = error("Not implemented.")
PyList_Append()                                       = error("Not implemented.")
PyList_AsTuple()                                      = error("Not implemented.")
PyList_ClearFreeList()                                = error("Not implemented.")
PyList_Fini()                                         = error("Not implemented.")
PyList_GetItem()                                      = error("Not implemented.")
PyList_GetSlice()                                     = error("Not implemented.")
PyList_Insert()                                       = error("Not implemented.")
PyList_New()                                          = error("Not implemented.")
PyList_Reverse()                                      = error("Not implemented.")
PyList_SetItem()                                      = error("Not implemented.")
PyList_SetSlice()                                     = error("Not implemented.")
PyList_Size()                                         = error("Not implemented.")
PyList_Sort()                                         = error("Not implemented.")
PyLong_AsDouble()                                     = error("Not implemented.")
PyLong_AsLong()                                       = error("Not implemented.")
PyLong_AsLongAndOverflow()                            = error("Not implemented.")
PyLong_AsLongLong()                                   = error("Not implemented.")
PyLong_AsLongLongAndOverflow()                        = error("Not implemented.")
PyLong_AsSize_t()                                     = error("Not implemented.")
PyLong_AsSsize_t()                                    = error("Not implemented.")
PyLong_AsUnsignedLong()                               = error("Not implemented.")
PyLong_AsUnsignedLongLong()                           = error("Not implemented.")
PyLong_AsUnsignedLongLongMask()                       = error("Not implemented.")
PyLong_AsUnsignedLongMask()                           = error("Not implemented.")
PyLong_AsVoidPtr()                                    = error("Not implemented.")
PyLong_Fini()                                         = error("Not implemented.")
PyLong_FromDouble()                                   = error("Not implemented.")
PyLong_FromLong()                                     = error("Not implemented.")
PyLong_FromLongLong()                                 = error("Not implemented.")
PyLong_FromSize_t()                                   = error("Not implemented.")
PyLong_FromSsize_t()                                  = error("Not implemented.")
PyLong_FromString()                                   = error("Not implemented.")
PyLong_FromUnicode()                                  = error("Not implemented.")
PyLong_FromUnicodeObject()                            = error("Not implemented.")
PyLong_FromUnsignedLong()                             = error("Not implemented.")
PyLong_FromUnsignedLongLong()                         = error("Not implemented.")
PyLong_FromVoidPtr()                                  = error("Not implemented.")
PyLong_GetInfo()                                      = error("Not implemented.")
PyMapping_Check()                                     = error("Not implemented.")
PyMapping_GetItemString()                             = error("Not implemented.")
PyMapping_HasKey()                                    = error("Not implemented.")
PyMapping_HasKeyString()                              = error("Not implemented.")
PyMapping_Items()                                     = error("Not implemented.")
PyMapping_Keys()                                      = error("Not implemented.")
PyMapping_Length()                                    = error("Not implemented.")
PyMapping_SetItemString()                             = error("Not implemented.")
PyMapping_Size()                                      = error("Not implemented.")
PyMapping_Values()                                    = error("Not implemented.")
PyMarshal_Init()                                      = error("Not implemented.")
PyMarshal_ReadLastObjectFromFile()                    = error("Not implemented.")
PyMarshal_ReadLongFromFile()                          = error("Not implemented.")
PyMarshal_ReadObjectFromFile()                        = error("Not implemented.")
PyMarshal_ReadObjectFromString()                      = error("Not implemented.")
PyMarshal_ReadShortFromFile()                         = error("Not implemented.")
PyMarshal_WriteLongToFile()                           = error("Not implemented.")
PyMarshal_WriteObjectToFile()                         = error("Not implemented.")
PyMarshal_WriteObjectToString()                       = error("Not implemented.")
PyMem_Calloc()                                        = error("Not implemented.")
PyMem_Free()                                          = error("Not implemented.")
PyMem_GetAllocator()                                  = error("Not implemented.")
PyMem_Malloc()                                        = error("Not implemented.")
PyMem_RawCalloc()                                     = error("Not implemented.")
PyMem_RawFree()                                       = error("Not implemented.")
PyMem_RawMalloc()                                     = error("Not implemented.")
PyMem_RawRealloc()                                    = error("Not implemented.")
PyMem_Realloc()                                       = error("Not implemented.")
PyMem_SetAllocator()                                  = error("Not implemented.")
PyMem_SetupDebugHooks()                               = error("Not implemented.")
PyMember_GetOne()                                     = error("Not implemented.")
PyMember_SetOne()                                     = error("Not implemented.")
PyMemoryView_FromBuffer()                             = error("Not implemented.")
PyMemoryView_FromMemory()                             = error("Not implemented.")
PyMemoryView_FromObject()                             = error("Not implemented.")
PyMemoryView_GetContiguous()                          = error("Not implemented.")
PyMethod_ClearFreeList()                              = error("Not implemented.")
PyMethod_Fini()                                       = error("Not implemented.")
PyMethod_Function()                                   = error("Not implemented.")
PyMethod_New()                                        = error("Not implemented.")
PyMethod_Self()                                       = error("Not implemented.")
PyModuleDef_Init()                                    = error("Not implemented.")
PyModule_AddFunctions()                               = error("Not implemented.")
PyModule_AddIntConstant()                             = error("Not implemented.")
PyModule_AddObject()                                  = error("Not implemented.")
PyModule_AddStringConstant()                          = error("Not implemented.")
PyModule_Create2()                                    = error("Not implemented.")
PyModule_ExecDef()                                    = error("Not implemented.")
PyModule_FromDefAndSpec2()                            = error("Not implemented.")
PyModule_GetDef()                                     = error("Not implemented.")
PyModule_GetDict()                                    = error("Not implemented.")
PyModule_GetFilename()                                = error("Not implemented.")
PyModule_GetFilenameObject()                          = error("Not implemented.")
PyModule_GetName()                                    = error("Not implemented.")
PyModule_GetNameObject()                              = error("Not implemented.")
PyModule_GetState()                                   = error("Not implemented.")
PyModule_GetWarningsModule()                          = error("Not implemented.")
PyModule_New()                                        = error("Not implemented.")
PyModule_NewObject()                                  = error("Not implemented.")
PyModule_SetDocString()                               = error("Not implemented.")
PyNode_AddChild()                                     = error("Not implemented.")
PyNode_Compile()                                      = error("Not implemented.")
PyNode_Free()                                         = error("Not implemented.")
PyNode_ListTree()                                     = error("Not implemented.")
PyNode_New()                                          = error("Not implemented.")
PyNumber_Absolute()                                   = error("Not implemented.")
PyNumber_Add()                                        = error("Not implemented.")
PyNumber_And()                                        = error("Not implemented.")
PyNumber_AsOff_t()                                    = error("Not implemented.")
PyNumber_AsSsize_t()                                  = error("Not implemented.")
PyNumber_Check()                                      = error("Not implemented.")
PyNumber_Divmod()                                     = error("Not implemented.")
PyNumber_Float()                                      = error("Not implemented.")
PyNumber_FloorDivide()                                = error("Not implemented.")
PyNumber_InMatrixMultiply()                           = error("Not implemented.")
PyNumber_InPlaceAdd()                                 = error("Not implemented.")
PyNumber_InPlaceAnd()                                 = error("Not implemented.")
PyNumber_InPlaceFloorDivide()                         = error("Not implemented.")
PyNumber_InPlaceLshift()                              = error("Not implemented.")
PyNumber_InPlaceMatrixMultiply()                      = error("Not implemented.")
PyNumber_InPlaceMultiply()                            = error("Not implemented.")
PyNumber_InPlaceOr()                                  = error("Not implemented.")
PyNumber_InPlacePower()                               = error("Not implemented.")
PyNumber_InPlaceRemainder()                           = error("Not implemented.")
PyNumber_InPlaceRshift()                              = error("Not implemented.")
PyNumber_InPlaceSubtract()                            = error("Not implemented.")
PyNumber_InPlaceTrueDivide()                          = error("Not implemented.")
PyNumber_InPlaceXor()                                 = error("Not implemented.")
PyNumber_Index()                                      = error("Not implemented.")
PyNumber_Invert()                                     = error("Not implemented.")
PyNumber_Long()                                       = error("Not implemented.")
PyNumber_Lshift()                                     = error("Not implemented.")
PyNumber_MatrixMultiply()                             = error("Not implemented.")
PyNumber_Multiply()                                   = error("Not implemented.")
PyNumber_Negative()                                   = error("Not implemented.")
PyNumber_Or()                                         = error("Not implemented.")
PyNumber_Positive()                                   = error("Not implemented.")
PyNumber_Power()                                      = error("Not implemented.")
PyNumber_Remainder()                                  = error("Not implemented.")
PyNumber_Rshift()                                     = error("Not implemented.")
PyNumber_Subtract()                                   = error("Not implemented.")
PyNumber_ToBase()                                     = error("Not implemented.")
PyNumber_TrueDivide()                                 = error("Not implemented.")
PyNumber_Xor()                                        = error("Not implemented.")
PyODict_DelItem()                                     = error("Not implemented.")
PyODict_New()                                         = error("Not implemented.")
PyODict_SetItem()                                     = error("Not implemented.")
PyOS_AfterFork()                                      = error("Not implemented.")
PyOS_AfterFork_Child()                                = error("Not implemented.")
PyOS_AfterFork_Parent()                               = error("Not implemented.")
PyOS_BeforeFork()                                     = error("Not implemented.")
PyOS_FSPath()                                         = error("Not implemented.")
PyOS_FiniInterrupts()                                 = error("Not implemented.")
PyOS_InitInterrupts()                                 = error("Not implemented.")
PyOS_InterruptOccurred()                              = error("Not implemented.")
PyOS_Readline()                                       = error("Not implemented.")
PyOS_StdioReadline()                                  = error("Not implemented.")
PyOS_double_to_string()                               = error("Not implemented.")
PyOS_getsig()                                         = error("Not implemented.")
PyOS_mystricmp()                                      = error("Not implemented.")
PyOS_mystrnicmp()                                     = error("Not implemented.")
PyOS_setsig()                                         = error("Not implemented.")
PyOS_snprintf()                                       = error("Not implemented.")
PyOS_string_to_double()                               = error("Not implemented.")
PyOS_strtol()                                         = error("Not implemented.")
PyOS_strtoul()                                        = error("Not implemented.")
PyOS_vsnprintf()                                      = error("Not implemented.")
PyObject_ASCII()                                      = error("Not implemented.")
PyObject_AsCharBuffer()                               = error("Not implemented.")
PyObject_AsFileDescriptor()                           = error("Not implemented.")
PyObject_AsReadBuffer()                               = error("Not implemented.")
PyObject_AsWriteBuffer()                              = error("Not implemented.")
PyObject_Bytes()                                      = error("Not implemented.")
PyObject_Call()                                       = error("Not implemented.")
PyObject_CallFinalizer()                              = error("Not implemented.")
PyObject_CallFinalizerFromDealloc()                   = error("Not implemented.")
PyObject_CallFunction()                               = error("Not implemented.")
PyObject_CallFunctionObjArgs()                        = error("Not implemented.")
PyObject_CallMethod()                                 = error("Not implemented.")
PyObject_CallMethodObjArgs()                          = error("Not implemented.")
PyObject_CallObject()                                 = error("Not implemented.")
PyObject_Calloc()                                     = error("Not implemented.")
PyObject_CheckReadBuffer()                            = error("Not implemented.")
PyObject_ClearWeakRefs()                              = error("Not implemented.")
PyObject_CopyData()                                   = error("Not implemented.")
PyObject_DelItem()                                    = error("Not implemented.")
PyObject_DelItemString()                              = error("Not implemented.")
PyObject_Dir()                                        = error("Not implemented.")
PyObject_Format()                                     = error("Not implemented.")
PyObject_Free()                                       = error("Not implemented.")
PyObject_GC_Del()                                     = error("Not implemented.")
PyObject_GC_Track()                                   = error("Not implemented.")
PyObject_GC_UnTrack()                                 = error("Not implemented.")
PyObject_GenericGetAttr()                             = error("Not implemented.")
PyObject_GenericGetDict()                             = error("Not implemented.")
PyObject_GenericSetAttr()                             = error("Not implemented.")
PyObject_GenericSetDict()                             = error("Not implemented.")
PyObject_GetArenaAllocator()                          = error("Not implemented.")
PyObject_GetAttr()                                    = error("Not implemented.")
PyObject_GetAttrString()                              = error("Not implemented.")
PyObject_GetBuffer()                                  = error("Not implemented.")
PyObject_GetItem()                                    = error("Not implemented.")
PyObject_GetIter()                                    = error("Not implemented.")
PyObject_HasAttr()                                    = error("Not implemented.")
PyObject_HasAttrString()                              = error("Not implemented.")
PyObject_Hash()                                       = error("Not implemented.")
PyObject_HashNotImplemented()                         = error("Not implemented.")
PyObject_Init()                                       = error("Not implemented.")
PyObject_InitVar()                                    = error("Not implemented.")
PyObject_IsInstance()                                 = error("Not implemented.")
PyObject_IsSubclass()                                 = error("Not implemented.")
PyObject_IsTrue()                                     = error("Not implemented.")
PyObject_Length()                                     = error("Not implemented.")
PyObject_LengthHint()                                 = error("Not implemented.")
PyObject_Malloc()                                     = error("Not implemented.")
PyObject_Not()                                        = error("Not implemented.")
PyObject_Print()                                      = error("Not implemented.")
PyObject_Realloc()                                    = error("Not implemented.")
PyObject_Repr()                                       = error("Not implemented.")
PyObject_RichCompare()                                = error("Not implemented.")
PyObject_RichCompareBool()                            = error("Not implemented.")
PyObject_SelfIter()                                   = error("Not implemented.")
PyObject_SetArenaAllocator()                          = error("Not implemented.")
PyObject_SetAttr()                                    = error("Not implemented.")
PyObject_SetAttrString()                              = error("Not implemented.")
PyObject_SetItem()                                    = error("Not implemented.")
PyObject_Size()                                       = error("Not implemented.")
PyObject_Str()                                        = error("Not implemented.")
PyObject_Type()                                       = error("Not implemented.")
PyParser_ASTFromFile()                                = error("Not implemented.")
PyParser_ASTFromFileObject()                          = error("Not implemented.")
PyParser_ASTFromString()                              = error("Not implemented.")
PyParser_ASTFromStringObject()                        = error("Not implemented.")
PyParser_AddToken()                                   = error("Not implemented.")
PyParser_ClearError()                                 = error("Not implemented.")
PyParser_Delete()                                     = error("Not implemented.")
PyParser_New()                                        = error("Not implemented.")
PyParser_ParseFile()                                  = error("Not implemented.")
PyParser_ParseFileFlags()                             = error("Not implemented.")
PyParser_ParseFileFlagsEx()                           = error("Not implemented.")
PyParser_ParseFileObject()                            = error("Not implemented.")
PyParser_ParseString()                                = error("Not implemented.")
PyParser_ParseStringFlags()                           = error("Not implemented.")
PyParser_ParseStringFlagsFilename()                   = error("Not implemented.")
PyParser_ParseStringFlagsFilenameEx()                 = error("Not implemented.")
PyParser_ParseStringObject()                          = error("Not implemented.")
PyParser_SetError()                                   = error("Not implemented.")
PyParser_SimpleParseFile()                            = error("Not implemented.")
PyParser_SimpleParseFileFlags()                       = error("Not implemented.")
PyParser_SimpleParseString()                          = error("Not implemented.")
PyParser_SimpleParseStringFilename()                  = error("Not implemented.")
PyParser_SimpleParseStringFlags()                     = error("Not implemented.")
PyParser_SimpleParseStringFlagsFilename()             = error("Not implemented.")
PyRun_AnyFile()                                       = error("Not implemented.")
PyRun_AnyFileEx()                                     = error("Not implemented.")
PyRun_AnyFileExFlags()                                = error("Not implemented.")
PyRun_AnyFileFlags()                                  = error("Not implemented.")
PyRun_File()                                          = error("Not implemented.")
PyRun_FileEx()                                        = error("Not implemented.")
PyRun_FileExFlags()                                   = error("Not implemented.")
PyRun_FileFlags()                                     = error("Not implemented.")
PyRun_InteractiveLoop()                               = error("Not implemented.")
PyRun_InteractiveLoopFlags()                          = error("Not implemented.")
PyRun_InteractiveOne()                                = error("Not implemented.")
PyRun_InteractiveOneFlags()                           = error("Not implemented.")
PyRun_InteractiveOneObject()                          = error("Not implemented.")
PyRun_SimpleFile()                                    = error("Not implemented.")
PyRun_SimpleFileEx()                                  = error("Not implemented.")
PyRun_SimpleFileExFlags()                             = error("Not implemented.")
PyRun_SimpleString()                                  = error("Not implemented.")
PyRun_SimpleStringFlags()                             = error("Not implemented.")
PyRun_String()                                        = error("Not implemented.")
PyRun_StringFlags()                                   = error("Not implemented.")
PyST_GetScope()                                       = error("Not implemented.")
PySeqIter_New()                                       = error("Not implemented.")
PySequence_Check()                                    = error("Not implemented.")
PySequence_Concat()                                   = error("Not implemented.")
PySequence_Contains()                                 = error("Not implemented.")
PySequence_Count()                                    = error("Not implemented.")
PySequence_DelItem()                                  = error("Not implemented.")
PySequence_DelSlice()                                 = error("Not implemented.")
PySequence_Fast()                                     = error("Not implemented.")
PySequence_GetItem()                                  = error("Not implemented.")
PySequence_GetSlice()                                 = error("Not implemented.")
PySequence_In()                                       = error("Not implemented.")
PySequence_InPlaceConcat()                            = error("Not implemented.")
PySequence_InPlaceRepeat()                            = error("Not implemented.")
PySequence_Index()                                    = error("Not implemented.")
PySequence_Length()                                   = error("Not implemented.")
PySequence_List()                                     = error("Not implemented.")
PySequence_Repeat()                                   = error("Not implemented.")
PySequence_SetItem()                                  = error("Not implemented.")
PySequence_SetSlice()                                 = error("Not implemented.")
PySequence_Size()                                     = error("Not implemented.")
PySequence_Tuple()                                    = error("Not implemented.")
PySet_Add()                                           = error("Not implemented.")
PySet_Clear()                                         = error("Not implemented.")
PySet_ClearFreeList()                                 = error("Not implemented.")
PySet_Contains()                                      = error("Not implemented.")
PySet_Discard()                                       = error("Not implemented.")
PySet_Fini()                                          = error("Not implemented.")
PySet_New()                                           = error("Not implemented.")
PySet_Pop()                                           = error("Not implemented.")
PySet_Size()                                          = error("Not implemented.")
PySignal_SetWakeupFd()                                = error("Not implemented.")
PySlice_AdjustIndices()                               = error("Not implemented.")
PySlice_Fini()                                        = error("Not implemented.")
PySlice_GetIndices()                                  = error("Not implemented.")
PySlice_GetIndicesEx()                                = error("Not implemented.")
PySlice_New()                                         = error("Not implemented.")
PySlice_Unpack()                                      = error("Not implemented.")
PyState_AddModule()                                   = error("Not implemented.")
PyState_FindModule()                                  = error("Not implemented.")
PyState_RemoveModule()                                = error("Not implemented.")
PyStaticMethod_New()                                  = error("Not implemented.")
PyStructSequence_GetItem()                            = error("Not implemented.")
PyStructSequence_InitType()                           = error("Not implemented.")
PyStructSequence_InitType2()                          = error("Not implemented.")
PyStructSequence_New()                                = error("Not implemented.")
PyStructSequence_NewType()                            = error("Not implemented.")
PyStructSequence_SetItem()                            = error("Not implemented.")
PySymtable_Build()                                    = error("Not implemented.")
PySymtable_BuildObject()                              = error("Not implemented.")
PySymtable_Free()                                     = error("Not implemented.")
PySymtable_Lookup()                                   = error("Not implemented.")
PySys_AddWarnOption()                                 = error("Not implemented.")
PySys_AddWarnOptionUnicode()                          = error("Not implemented.")
PySys_AddXOption()                                    = error("Not implemented.")
PySys_FormatStderr()                                  = error("Not implemented.")
PySys_FormatStdout()                                  = error("Not implemented.")
PySys_GetObject()                                     = error("Not implemented.")
PySys_GetXOptions()                                   = error("Not implemented.")
PySys_HasWarnOptions()                                = error("Not implemented.")
PySys_ResetWarnOptions()                              = error("Not implemented.")
PySys_SetArgv()                                       = error("Not implemented.")
PySys_SetArgvEx()                                     = error("Not implemented.")
PySys_SetObject()                                     = error("Not implemented.")
PySys_SetPath()                                       = error("Not implemented.")
PySys_WriteStderr()                                   = error("Not implemented.")
PySys_WriteStdout()                                   = error("Not implemented.")
PyThreadState_Clear()                                 = error("Not implemented.")
PyThreadState_Delete()                                = error("Not implemented.")
PyThreadState_DeleteCurrent()                         = error("Not implemented.")
PyThreadState_Get()                                   = error("Not implemented.")
PyThreadState_GetDict()                               = error("Not implemented.")
PyThreadState_New()                                   = error("Not implemented.")
PyThreadState_Next()                                  = error("Not implemented.")
PyThreadState_SetAsyncExc()                           = error("Not implemented.")
PyThreadState_Swap()                                  = error("Not implemented.")
PyThread_GetInfo()                                    = error("Not implemented.")
PyThread_ReInitTLS()                                  = error("Not implemented.")
PyThread_acquire_lock()                               = error("Not implemented.")
PyThread_acquire_lock_timed()                         = error("Not implemented.")
PyThread_allocate_lock()                              = error("Not implemented.")
PyThread_create_key()                                 = error("Not implemented.")
PyThread_delete_key()                                 = error("Not implemented.")
PyThread_delete_key_value()                           = error("Not implemented.")
PyThread_exit_thread()                                = error("Not implemented.")
PyThread_free_lock()                                  = error("Not implemented.")
PyThread_get_key_value()                              = error("Not implemented.")
PyThread_get_stacksize()                              = error("Not implemented.")
PyThread_get_thread_ident()                           = error("Not implemented.")
PyThread_init_thread()                                = error("Not implemented.")
PyThread_release_lock()                               = error("Not implemented.")
PyThread_set_key_value()                              = error("Not implemented.")
PyThread_set_stacksize()                              = error("Not implemented.")
PyThread_start_new_thread()                           = error("Not implemented.")
PyThread_tss_alloc()                                  = error("Not implemented.")
PyThread_tss_create()                                 = error("Not implemented.")
PyThread_tss_delete()                                 = error("Not implemented.")
PyThread_tss_free()                                   = error("Not implemented.")
PyThread_tss_get()                                    = error("Not implemented.")
PyThread_tss_is_created()                             = error("Not implemented.")
PyThread_tss_set()                                    = error("Not implemented.")
PyToken_OneChar()                                     = error("Not implemented.")
PyToken_ThreeChars()                                  = error("Not implemented.")
PyToken_TwoChars()                                    = error("Not implemented.")
PyTokenizer_FindEncoding()                            = error("Not implemented.")
PyTokenizer_FindEncodingFilename()                    = error("Not implemented.")
PyTokenizer_Free()                                    = error("Not implemented.")
PyTokenizer_FromFile()                                = error("Not implemented.")
PyTokenizer_FromString()                              = error("Not implemented.")
PyTokenizer_FromUTF8()                                = error("Not implemented.")
PyTokenizer_Get()                                     = error("Not implemented.")
PyTraceBack_Here()                                    = error("Not implemented.")
PyTraceBack_Print()                                   = error("Not implemented.")
PyTraceMalloc_Track()                                 = error("Not implemented.")
PyTraceMalloc_Untrack()                               = error("Not implemented.")
PyTuple_ClearFreeList()                               = error("Not implemented.")
PyTuple_Fini()                                        = error("Not implemented.")
PyTuple_GetItem()                                     = error("Not implemented.")
PyTuple_GetSlice()                                    = error("Not implemented.")
PyTuple_New()                                         = error("Not implemented.")
PyTuple_Pack()                                        = error("Not implemented.")
PyTuple_SetItem()                                     = error("Not implemented.")
PyTuple_Size()                                        = error("Not implemented.")
PyType_ClearCache()                                   = error("Not implemented.")
PyType_FromSpec(pts::Ptr{PyType_Spec})::Ptr{PyObject} = ccall(:PyType_FromSpec, Ptr{PyObject}, (Ptr{PyType_Spec},), pts)
PyType_FromSpecWithBases()                            = error("Not implemented.")
PyType_GenericAlloc()                                 = error("Not implemented.")
PyType_GenericNew()                                   = error("Not implemented.")
PyType_GetFlags()                                     = error("Not implemented.")
PyType_GetSlot()                                      = error("Not implemented.")
PyType_IsSubtype()                                    = error("Not implemented.")
PyType_Modified()                                     = error("Not implemented.")
PyType_Ready()                                        = error("Not implemented.")
PyUnicodeDecodeError_Create()                         = error("Not implemented.")
PyUnicodeDecodeError_GetEncoding()                    = error("Not implemented.")
PyUnicodeDecodeError_GetEnd()                         = error("Not implemented.")
PyUnicodeDecodeError_GetObject()                      = error("Not implemented.")
PyUnicodeDecodeError_GetReason()                      = error("Not implemented.")
PyUnicodeDecodeError_GetStart()                       = error("Not implemented.")
PyUnicodeDecodeError_SetEnd()                         = error("Not implemented.")
PyUnicodeDecodeError_SetReason()                      = error("Not implemented.")
PyUnicodeDecodeError_SetStart()                       = error("Not implemented.")
PyUnicodeEncodeError_Create()                         = error("Not implemented.")
PyUnicodeEncodeError_GetEncoding()                    = error("Not implemented.")
PyUnicodeEncodeError_GetEnd()                         = error("Not implemented.")
PyUnicodeEncodeError_GetObject()                      = error("Not implemented.")
PyUnicodeEncodeError_GetReason()                      = error("Not implemented.")
PyUnicodeEncodeError_GetStart()                       = error("Not implemented.")
PyUnicodeEncodeError_SetEnd()                         = error("Not implemented.")
PyUnicodeEncodeError_SetReason()                      = error("Not implemented.")
PyUnicodeEncodeError_SetStart()                       = error("Not implemented.")
PyUnicodeTranslateError_Create()                      = error("Not implemented.")
PyUnicodeTranslateError_GetEnd()                      = error("Not implemented.")
PyUnicodeTranslateError_GetObject()                   = error("Not implemented.")
PyUnicodeTranslateError_GetReason()                   = error("Not implemented.")
PyUnicodeTranslateError_GetStart()                    = error("Not implemented.")
PyUnicodeTranslateError_SetEnd()                      = error("Not implemented.")
PyUnicodeTranslateError_SetReason()                   = error("Not implemented.")
PyUnicodeTranslateError_SetStart()                    = error("Not implemented.")
PyUnicode_Append()                                    = error("Not implemented.")
PyUnicode_AppendAndDel()                              = error("Not implemented.")
PyUnicode_AsASCIIString()                             = error("Not implemented.")
PyUnicode_AsCharmapString()                           = error("Not implemented.")
PyUnicode_AsDecodedObject()                           = error("Not implemented.")
PyUnicode_AsDecodedUnicode()                          = error("Not implemented.")
PyUnicode_AsEncodedObject()                           = error("Not implemented.")
PyUnicode_AsEncodedString()                           = error("Not implemented.")
PyUnicode_AsEncodedUnicode()                          = error("Not implemented.")
PyUnicode_AsLatin1String()                            = error("Not implemented.")
PyUnicode_AsRawUnicodeEscapeString()                  = error("Not implemented.")
PyUnicode_AsUCS4()                                    = error("Not implemented.")
PyUnicode_AsUCS4Copy()                                = error("Not implemented.")
PyUnicode_AsUTF16String()                             = error("Not implemented.")
PyUnicode_AsUTF32String()                             = error("Not implemented.")
PyUnicode_AsUTF8()                                    = error("Not implemented.")
PyUnicode_AsUTF8AndSize()                             = error("Not implemented.")
PyUnicode_AsUTF8String()                              = error("Not implemented.")
PyUnicode_AsUnicode()                                 = error("Not implemented.")
PyUnicode_AsUnicodeAndSize()                          = error("Not implemented.")
PyUnicode_AsUnicodeCopy()                             = error("Not implemented.")
PyUnicode_AsUnicodeEscapeString()                     = error("Not implemented.")
PyUnicode_AsWideChar()                                = error("Not implemented.")
PyUnicode_AsWideCharString()                          = error("Not implemented.")
PyUnicode_BuildEncodingMap()                          = error("Not implemented.")
PyUnicode_ClearFreeList()                             = error("Not implemented.")
PyUnicode_Compare()                                   = error("Not implemented.")
PyUnicode_CompareWithASCIIString()                    = error("Not implemented.")
PyUnicode_Concat()                                    = error("Not implemented.")
PyUnicode_Contains()                                  = error("Not implemented.")
PyUnicode_CopyCharacters()                            = error("Not implemented.")
PyUnicode_Count()                                     = error("Not implemented.")
PyUnicode_Decode()                                    = error("Not implemented.")
PyUnicode_DecodeASCII()                               = error("Not implemented.")
PyUnicode_DecodeCharmap()                             = error("Not implemented.")
PyUnicode_DecodeFSDefault()                           = error("Not implemented.")
PyUnicode_DecodeFSDefaultAndSize()                    = error("Not implemented.")
PyUnicode_DecodeLatin1()                              = error("Not implemented.")
PyUnicode_DecodeLocale()                              = error("Not implemented.")
PyUnicode_DecodeLocaleAndSize()                       = error("Not implemented.")
PyUnicode_DecodeRawUnicodeEscape()                    = error("Not implemented.")
PyUnicode_DecodeUTF16()                               = error("Not implemented.")
PyUnicode_DecodeUTF16Stateful()                       = error("Not implemented.")
PyUnicode_DecodeUTF32()                               = error("Not implemented.")
PyUnicode_DecodeUTF32Stateful()                       = error("Not implemented.")
PyUnicode_DecodeUTF7()                                = error("Not implemented.")
PyUnicode_DecodeUTF7Stateful()                        = error("Not implemented.")
PyUnicode_DecodeUTF8()                                = error("Not implemented.")
PyUnicode_DecodeUTF8Stateful()                        = error("Not implemented.")
PyUnicode_DecodeUnicodeEscape()                       = error("Not implemented.")
PyUnicode_Encode()                                    = error("Not implemented.")
PyUnicode_EncodeASCII()                               = error("Not implemented.")
PyUnicode_EncodeCharmap()                             = error("Not implemented.")
PyUnicode_EncodeDecimal()                             = error("Not implemented.")
PyUnicode_EncodeFSDefault()                           = error("Not implemented.")
PyUnicode_EncodeLatin1()                              = error("Not implemented.")
PyUnicode_EncodeLocale()                              = error("Not implemented.")
PyUnicode_EncodeRawUnicodeEscape()                    = error("Not implemented.")
PyUnicode_EncodeUTF16()                               = error("Not implemented.")
PyUnicode_EncodeUTF32()                               = error("Not implemented.")
PyUnicode_EncodeUTF7()                                = error("Not implemented.")
PyUnicode_EncodeUTF8()                                = error("Not implemented.")
PyUnicode_EncodeUnicodeEscape()                       = error("Not implemented.")
PyUnicode_FSConverter()                               = error("Not implemented.")
PyUnicode_FSDecoder()                                 = error("Not implemented.")
PyUnicode_Fill()                                      = error("Not implemented.")
PyUnicode_Find()                                      = error("Not implemented.")
PyUnicode_FindChar()                                  = error("Not implemented.")
PyUnicode_Format()                                    = error("Not implemented.")
PyUnicode_FromEncodedObject()                         = error("Not implemented.")
PyUnicode_FromFormat()                                = error("Not implemented.")
PyUnicode_FromFormatV()                               = error("Not implemented.")
PyUnicode_FromKindAndData()                           = error("Not implemented.")
PyUnicode_FromObject()                                = error("Not implemented.")
PyUnicode_FromOrdinal()                               = error("Not implemented.")
PyUnicode_FromString()                                = error("Not implemented.")
PyUnicode_FromStringAndSize()                         = error("Not implemented.")
PyUnicode_FromUnicode()                               = error("Not implemented.")
PyUnicode_FromWideChar()                              = error("Not implemented.")
PyUnicode_GetDefaultEncoding()                        = error("Not implemented.")
PyUnicode_GetLength()                                 = error("Not implemented.")
PyUnicode_GetMax()                                    = error("Not implemented.")
PyUnicode_GetSize()                                   = error("Not implemented.")
PyUnicode_InternFromString()                          = error("Not implemented.")
PyUnicode_InternImmortal()                            = error("Not implemented.")
PyUnicode_InternInPlace()                             = error("Not implemented.")
PyUnicode_IsIdentifier()                              = error("Not implemented.")
PyUnicode_Join()                                      = error("Not implemented.")
PyUnicode_New()                                       = error("Not implemented.")
PyUnicode_Partition()                                 = error("Not implemented.")
PyUnicode_RPartition()                                = error("Not implemented.")
PyUnicode_RSplit()                                    = error("Not implemented.")
PyUnicode_ReadChar()                                  = error("Not implemented.")
PyUnicode_Replace()                                   = error("Not implemented.")
PyUnicode_Resize()                                    = error("Not implemented.")
PyUnicode_RichCompare()                               = error("Not implemented.")
PyUnicode_Split()                                     = error("Not implemented.")
PyUnicode_Splitlines()                                = error("Not implemented.")
PyUnicode_Substring()                                 = error("Not implemented.")
PyUnicode_Tailmatch()                                 = error("Not implemented.")
PyUnicode_TransformDecimalToASCII()                   = error("Not implemented.")
PyUnicode_Translate()                                 = error("Not implemented.")
PyUnicode_TranslateCharmap()                          = error("Not implemented.")
PyUnicode_WriteChar()                                 = error("Not implemented.")
PyWeakref_GetObject()                                 = error("Not implemented.")
PyWeakref_NewProxy()                                  = error("Not implemented.")
PyWeakref_NewRef()                                    = error("Not implemented.")
PyWrapper_New()                                       = error("Not implemented.")
Py_AddPendingCall()                                   = error("Not implemented.")
Py_AtExit()                                           = error("Not implemented.")
Py_BuildValue()                                       = error("Not implemented.")
Py_CompileString()                                    = error("Not implemented.")
Py_CompileStringExFlags()                             = error("Not implemented.")
Py_CompileStringFlags()                               = error("Not implemented.")
Py_CompileStringObject()                              = error("Not implemented.")
Py_DecRef()                                           = error("Not implemented.")
Py_DecodeLocale()                                     = error("Not implemented.")
Py_EncodeLocale()                                     = error("Not implemented.")
Py_EndInterpreter()                                   = error("Not implemented.")
Py_Exit()                                             = error("Not implemented.")
Py_FatalError()                                       = error("Not implemented.")
Py_FdIsInteractive()                                  = error("Not implemented.")
Py_Finalize()                                         = error("Not implemented.")
Py_FinalizeEx()                                       = error("Not implemented.")
Py_FrozenMain()                                       = error("Not implemented.")
Py_GetArgcArgv()                                      = error("Not implemented.")
Py_GetBuildInfo()                                     = error("Not implemented.")
Py_GetCompiler()                                      = error("Not implemented.")
Py_GetCopyright()                                     = error("Not implemented.")
Py_GetExecPrefix()                                    = error("Not implemented.")
Py_GetPath()                                          = error("Not implemented.")
Py_GetPlatform()                                      = error("Not implemented.")
Py_GetPrefix()                                        = error("Not implemented.")
Py_GetProgramFullPath()                               = error("Not implemented.")
Py_GetProgramName()                                   = error("Not implemented.")
Py_GetPythonHome()                                    = error("Not implemented.")
Py_GetRecursionLimit()                                = error("Not implemented.")
Py_GetVersion()                                       = error("Not implemented.")
Py_IncRef()                                           = error("Not implemented.")
Py_Initialize()                                       = error("Not implemented.")
Py_InitializeEx()                                     = error("Not implemented.")
Py_IsInitialized()                                    = error("Not implemented.")
Py_Main()                                             = error("Not implemented.")
Py_MakePendingCalls()                                 = error("Not implemented.")
Py_NewInterpreter()                                   = error("Not implemented.")
Py_ReprEnter()                                        = error("Not implemented.")
Py_ReprLeave()                                        = error("Not implemented.")
Py_SetPath()                                          = error("Not implemented.")
Py_SetProgramName()                                   = error("Not implemented.")
Py_SetPythonHome()                                    = error("Not implemented.")
Py_SetRecursionLimit()                                = error("Not implemented.")
Py_SetStandardStreamEncoding()                        = error("Not implemented.")
Py_SymtableString()                                   = error("Not implemented.")
Py_SymtableStringObject()                             = error("Not implemented.")
Py_UNICODE_strcat()                                   = error("Not implemented.")
Py_UNICODE_strchr()                                   = error("Not implemented.")
Py_UNICODE_strcmp()                                   = error("Not implemented.")
Py_UNICODE_strcpy()                                   = error("Not implemented.")
Py_UNICODE_strlen()                                   = error("Not implemented.")
Py_UNICODE_strncmp()                                  = error("Not implemented.")
Py_UNICODE_strncpy()                                  = error("Not implemented.")
Py_UNICODE_strrchr()                                  = error("Not implemented.")
Py_UniversalNewlineFgets()                            = error("Not implemented.")
Py_VaBuildValue()                                     = error("Not implemented.")
Py_meta_grammar()                                     = error("Not implemented.")
Py_pgen()                                             = error("Not implemented.")

end # module


text:
export MWSingleLayerTDIO
export MWDoubleLayerTDIO

type MWSingleLayerTDIO{T} <: RetardedPotential{T}
    "speed of light in medium"
    speed_of_light::T
    "weight of the weakly singular term"
    ws_weight::T
    "weight of the hypersingular term"
    hs_weight::T
    "number of temporal differentiations in the weakly singular term"
    ws_diffs::Int
    "number of temporal differentiations in the hyper singular term"
    hs_diffs::Int
end

type MWDoubleLayerTDIO{T} <: RetardedPotential{T}
    speed_of_light::T
    weight::T
    num_diffs::Int
end

MWSingleLayerTDIO(c) = MWSingleLayerTDIO(c,-1/c,-c,2,0)
MWDoubleLayerTDIO(c) = MWDoubleLayerTDIO(c, one(c), 0)

function quaddata(op::MWSingleLayerTDIO, testrefs, trialrefs, timerefs,
        testels, trialels, timeels)

    dmax = numfunctions(timerefs)-1
    bn = binomial.((0:dmax),(0:dmax)')
    quadpoints(testrefs, testels, (3,)), bn

end

quadrule(op::MWSingleLayerTDIO, testrefs, trialrefs, timerefs,
        p, testel, q, trialel, r, timeel, qd) = WiltonInts84Strat(qd[1][1,p],qd[2])

function quaddata(op::MWDoubleLayerTDIO, testrefs, trialrefs, timerefs,
        testels, trialels, timeels)

    dmax = numfunctions(timerefs)-1
    bn = binomial.((0:dmax),(0:dmax)')
    quadpoints(testrefs, testels, (3,))
end

quadrule(op::MWDoubleLayerTDIO, testrefs, trialrefs, timerefs,
        p, testel, q, trialel, r, timeel, qd) = WiltonInts84Strat(qd[1][1,p],qd[2])

@inline function tmRoR(d, t, iG, bns)
    r = zero(t)
    for q in 0:d
        sgn = isodd(q) ? -1 : 1
        bn = bns[d+1,q+1]
        #r += binomial(d,q) * sgn * t^(d-q) * iG[q+2]
        r += bn * sgn * t^(d-q) * iG[q+2]
    end
    r
end

# build
# ``\int (D-R)^d/R (y-b) dy`` from
# ``(ξ-b) \int R^k dy`` and
# ``\int R^k (y-ξ) dy``
@inline function tmRoRf(d, t, iG, iGξy, bξ, bns)
    r = zero(bξ)
    for q in 0:d
        sgn = isodd(q) ? -1 : 1
        i = q+2
        iGf = iGξy[i] + bξ * iG[i]
        bn = bns[d+1,q+1]
        #r += binomial(d,q) * sgn * t^(d-q) * iGf
        r += bn * sgn * t^(d-q) * iGf
    end
    r
end

"""
    Q = qd(T,dh,::Val{N})

Q[k] is the factor in front resulting from differentiating t^(k-1) dh times.
"""
@generated function qh(::Type{T},dh,n::Type{Val{N}}) where {N,T}
    xp = quote end
    for k in 1:N
        qk = Symbol(:q,k)
        d = k-1
        xp1 = quote
            $(qk) = one($T)
            for v in 0 : dh-1
                $(qk) *= ($d-v)
            end
        end
        append!(xp.args, xp1.args)
    end
    xp1 = :(())
    for k in 1:N
        qk = Symbol(:q,k)
        push!(xp1.args, :($qk))
    end
    push!(xp.args, xp1)
    return xp
end

function innerintegrals!(zl, op::MWSingleLayerTDIO,
        p, tmax, # test_point, test_time
        U, V, W, # local_test_space, local_trial_space, local_temporal_space
        τ, σ, ι, # test_element, trial_element, spherial_shell
        qr, w)   # inner_quadrature_rule, outer_quadrature_weight

	T = typeof(w)

    sol = op.speed_of_light
    Rmax = sol * tmax

    dx = w
    x = cartesian(p)
    n = cross(σ[1]-σ[3],σ[2]-σ[3])
    n /= norm(n)
    ξ = x - ((x-σ[1]) ⋅ n) * n

    r = ι[1]
    R = ι[2]

    @assert r < R
    @assert degree(W) <= 3

    ∫G, ∫Gξy, = WiltonInts84.wiltonints(σ[1],σ[2],σ[3],x,r,R,Val{2})

    αg = 1 / volume(τ) / 2
	αf = 1 / volume(σ) / 2
	αG = 1 / 4π
	α = αg * αf * αG * op.ws_weight * dx
	β = 4 * αg * αf * αG * op.hs_weight * dx

	ds = op.ws_diffs
	dh = op.hs_diffs

    qhs = qh(T,dh,Val{4})
    qss = qh(T,ds,Val{4})

    bn = qr.binomials

    for i in 1 : numfunctions(U)
        a = τ[i]
        g = (x-a)
        for j in 1 : numfunctions(V)
            b = σ[j]; bξ = ξ-b
            for k in 1 : numfunctions(W)
				d = k-1 # ranges from 0 to numfunctions(W)-1
				sgn = isodd(d) ? -1 : 1
				# hyper singular contribution
				if d >= dh
                    @assert dh == 0
                    q = qhs[k]
                    Ih = tmRoR(d-dh, Rmax, ∫G, bn) # \int (cTmax-R)^(d-dh)/R dy
                    zl[i,j,k] += β * q * Ih / sol^(d-dh)
				end
				# weakly singular contribution
				if d >= ds
                    q = qss[k]
                    Is = tmRoRf(d-ds, Rmax, ∫G, ∫Gξy, bξ, bn) # \int (cTmax-R)^(d-ds)/R (y-b) dy
                    zl[i,j,k] += α * q * (g ⋅ Is) / sol^(d-ds)
				end
            end
        end
    end

end

function innerintegrals!(z, op::MWDoubleLayerTDIO,
    p, tmax,
    U, V, W,
    τ, σ, ι,
    qr, w)

	T = typeof(w)

    sol = op.speed_of_light
    Rmax = sol * tmax

    dx = w
    x = cartesian(p)
    #n = normal(σ)
    n = cross(σ[1]-σ[3],σ[2]-σ[3])
    n /= norm(n)
    ξ = x - ((x-σ[1]) ⋅ n) * n

    r = ι[1]
    R = ι[2]

    @assert r < R
    @assert degree(W) <= 3

    #N = max(degree(W), 0)
    ∫G, ∫Gξy, ∫∇G = WiltonInts84.wiltonints(σ[1],σ[2],σ[3],x,r,R,Val{2})

    αg = 1 / volume(τ) / 2
	αf = 1 / volume(σ) / 2
	αG = 1 / 4 / π
	α = αg * αf * αG * op.weight * dx

	ds = op.num_diffs

    @inline function tmRoR(d, t, iGG)
        r = zero(t)
        for q in 0:d
            sgn = isodd(q) ? -1 : 1
            r += binomial(d,q) * sgn * t^(d-q) * iGG[q+1]
        end
        r
    end

    for i in 1 : numfunctions(U)
        a = τ[i]
        g = (x-a)
        for j in 1 : numfunctions(V)
            b = σ[j]
            f = (x-b)
            fxg = f × g
            for k in 1 : numfunctions(W)
				d = k-1
				sgn = isodd(d) ? -1 : 1
				if d >= ds
					q = one(T)
					for p in 0 : ds-1
						q *= (d-p)
					end
                    @assert q == 1
                    z[i,j,k] += -α * q * ( fxg ⋅ tmRoR(d-ds, Rmax, ∫∇G) ) / sol^(d-ds)
				end
            end
        end
    end

end

ext: jl


text:
"""
model i_L and β_Ni as as step function increased by factor fac_int at t in [t1,t2).
Superimpose a seasonal pattern on the litter input.
"""
function plant_face_fluct(;name, t1=0.0, t2=100.0, fac_inc=1.2,
#    autumn_start=10/12, autumn_end = 11/12,
    autumn_start=8.5/12, autumn_end = 11.5/12,
    share_autumn=0.5, k_Lagr=12/2, k_PlantN0v = 100, k_PlantP0v = 100)
    @parameters t
    D = Differential(t)
    @parameters i_L0  i_IN0  β_Ni0 i_IP0 β_Pi0 t1=t1 t2=t2 fac_inc=fac_inc
    @parameters u_PlantPmax0  k_PlantP0=k_PlantP0v s_EP0
    @parameters u_PlantNmax0  k_PlantN0=k_PlantN0v
    @parameters k_Lagr = k_Lagr share_autumn = share_autumn
    # in the fluctuation analysis the integrated
    # model gives slightly higher litter input
    # ad-hoc correct for providiing slighly lower
    # amount in autumn

    # Distribution of litterfall within year (between 0 and 1)
    d_lit_agr = LocationScale(autumn_start, autumn_end - autumn_start, fit_mode_flat(LogitNormal, 0.3; peakedness = 3))
    @variables (begin
        i_L(t), β_Ni(t), i_IN(t),
        i_L_anomaly(t), i_L_annual(t), β_Ni_annual(t),
        Lagr(t), i_Lagr(t), dec_Lagr(t), d_Lagr(t),
        u_PlantNmax(t), k_PlantN(t), inc_period(t),
        β_Pi_annual(t), β_Pi(t), i_IP(t),
        u_PlantPmax(t), k_PlantP(t),
        s_EP(t)
    end)
    smooth_dt = 1/12/2
    eqs = [
        D(Lagr) ~ d_Lagr, d_Lagr ~ i_Lagr - dec_Lagr,
        dec_Lagr ~ k_Lagr*Lagr,
        i_Lagr ~ share_autumn * i_L_annual * i_L_anomaly,
        i_L ~ (1-share_autumn) * i_L_annual + dec_Lagr,
        # i_L_annual ~ IfElse.ifelse((t1 <= t) & (t < t2), fac_inc*i_L0, i_L0),
        # β_Ni_annual ~ IfElse.ifelse((t1 <= t) & (t < t2), fac_inc*β_Ni0, β_Ni0),
        inc_period ~ smoothstep_sesam(t, t1, smooth_dt) *
            (1-smoothstep_sesam(t, t2, smooth_dt)),
        i_L_annual ~ i_L0 * (1 + (fac_inc-1)*inc_period),
        β_Ni_annual ~ β_Ni0 * (1 + (fac_inc-1)*inc_period),
        i_L_anomaly ~ get_iL_anomaly(t, d_lit_agr),
        β_Ni ~ β_Ni_annual, # does not change with season
        i_IN ~ i_IN0,
        u_PlantNmax ~ u_PlantNmax0,
        k_PlantN ~ k_PlantN0,
        #
        β_Pi_annual ~ β_Pi0 * (1 + (fac_inc-1)*inc_period),
        β_Pi ~ β_Pi_annual,
        i_IP ~ i_IP0,
        u_PlantPmax ~ u_PlantPmax0,
        k_PlantP ~ k_PlantP0,
        s_EP ~ s_EP0,
    ]
    defaults=Pair{Num, Any}[
        # rate not constrained
        k_PlantN0 => k_PlantN0v,
        # take as much N and P as provide with litter
        u_PlantNmax0 => i_L0/β_Ni0,
        u_PlantPmax0 => i_L0/β_Pi0,
    ]
    continuous_events = vcat(
        [
        t ~ t1,
        t ~ t2,
        ])
    ODESystem(eqs,t; name, defaults, continuous_events)
end

# now defined in MTKHelpers - not found in generated function
smoothstep_sesam(args...) = smoothstep(args...)
@register_symbolic smoothstep_sesam(t, t_step::Number, dt::Number)

get_iL_anomaly(t, dist) = pdf(dist, t - floor(t))
@register_symbolic get_iL_anomaly(t, dist::Distribution)

function f_interpolate9(t, sol, numref)
	sol(t,idxs=numref.x)
end
@register_symbolic f_interpolate9(t, sol::ODESolution, numref::Base.RefValue{Num})

function plant_face_fluct_fake(;name, sys, sol, t1, t2)
    @parameters t
    D = Differential(t)
    ps = @parameters t1=t1 t2=t2 # for continuous events
    sts = @variables (begin
        i_L(t), β_Ni(t), i_IN(t),
        u_PlantNmax(t), k_PlantN(t),
        i_L_annual(t)
    end)
    eqs = [
        i_L ~  f_interpolate9(t, sol, Ref(sys.i_L)),
        β_Ni ~ f_interpolate9(t, sol, Ref(sys.β_Ni)),
        i_IN ~  f_interpolate9(t, sol, Ref(sys.i_IN)),
        u_PlantNmax ~ f_interpolate9(t, sol, Ref(sys.u_PlantNmax)),
        k_PlantN ~ f_interpolate9(t, sol, Ref(sys.k_PlantN)),
        i_L_annual ~  f_interpolate9(t, sol, Ref(sys.i_L_annual)),
    ]
    # continuous_events = vcat(
    #     [t-yr ~ autumn_start*1.05 for yr in -500:200],
    #     [t-yr ~ autumn_end*0.995 for yr in -500:200],
    #     [
    #     t ~ t1,
    #     t ~ t2,
    #     ])
    #@unpack autumn_start, autumn_end = sys # in case those become parameters
    continuous_events = first(sys.continuous_events.value).eqs
    ODESystem(eqs,t, sts, ps; name, continuous_events)
end


text:
"""
    PermutedDimsTabular{Perm}(data)

Like `Tabular`, but presents a view of tabular data where the order of indices is
permuted. `Perm` must be a tuple instance of the same length as the number of
dimensions of the `Tabular` input, e.g. `PermutDimsTabular{(2,1)}(table)` takes
the "transpose" of a table.

See also `permutedims`, `transpose`.
"""
struct PermutedDimsTabular{Perm, N, D} <: AbstractTabular{N}
    data::D
end

@inline function PermutedDimsTabular{Perm}(data::D) where {Perm, D}
    return PermutedDimsTabular{Perm::Tuple{Vararg{Int}}, length(Perm), D}(data)
end

@inline PermutedDimsTabular{Perm,N}(data::D) where {Perm,N,D} = PermutedDimsTabular{Perm,N,D}(data)

const TransposedTable{D} = PermutedDimsTabular{(2,1), 2, D}

get(t::PermutedDimsTabular) = t.data

"""
    permutedims(tabular::Tabular, Val{Perm})

Presents a view of a tabular object where the order of indices is permuted as a
`PermutedDimsTabular`. `Perm` must be a tuple instance of the same length as the number of
dimensions of the `Tabular` input, e.g. `permutedims(table, Val{(2,1)})` takes the
"transpose" of a table.

See also `transpose`, `PermutedDimsTabular`.
"""
permutedims(t::Tabular, ::Type{Val{Perm}}) where {Perm} = PermutedDimsTabular{Perm, ndims(t), typeof(get(t))}(get(t))
#permutedims(t::Tabular{0}, ::Type{Val{()}}) = t
permutedims(t::Tabular{1}, ::Type{Val{(1,)}}) = t

"""
    transpose(t::Table)

Presents a view of a table object where the column and row indices are reversed.

See also `permutedims`, `PermutedDimsTabular`
"""
transpose(t::Table) = permutedims(t, Val{(2,1)})
transpose(t::TransposedTable) = Table(get(t))

@generated function _permute(::Type{Val{Perm}}, inds) where {Perm}
    l = length(Perm)
    if l != length(inds.parameters)
        error("Cannot permute $(length(inds)) values by a length $l permutation")
    end
    exprs = [:(inds[$i]) for i ∈ Perm]
    return quote
        @_inline_meta
        tuple($(exprs...))
    end
end

indices(t::PermutedDimsTabular{Perm}) where {Perm} = _permute(Val{Perm}, _indices(Dims(length(Perm)), t.data))

@propagate_inbounds function getindex(t::PermutedDimsTabular{(1,), 1}, i)
    dims = Dims(index_shape(t, i))
    data = _getindex(Dims(1), get(t), i)
    if dims == 0
        return data
    else
        return Tabular{get(dims)}(data)
    end
end

@propagate_inbounds function getindex(t::PermutedDimsTabular{(1, 2), 2}, i1, i2)
    dims = Dims(index_shape(t, i1, i2))
    data = _getindex(Dims(2), get(t), i1, i2)
    if dims == 0
        return data
    else
        return Tabular{get(dims)}(data)
    end
end

@propagate_inbounds function getindex(t::TransposedTable, i1, i2)
    dims = Dims(index_shape(t, i1, i2))
    data = _getindex(Dims(2), get(t), i2, i1)
    if dims == 0
        return data
    elseif dims == 1
        return Series(data)
    else
        return TransposedTable(data)
    end
end

@inline function index_shape(x::TransposedTable, i1, i2)
    shape = _index_shape(Dims(2), typeof(get(x)), typeof(i2), typeof(i1))
    if shape[1] === nothing || shape[2] === nothing
        # TODO: An explicit path using data from elements?
        throw(IndexError("Tried to index a transposed $(typeof(x)) with $(typeof(i1)), $(typeof(i2))"))
    else
        return (shape[2], shape[1]) # fast path for fully-typed, inferred case
    end
end

# @propagate_inbounds function setindex!(t::PermutedDimsTabular{Perm, N}, value, inds::Vararg{Any, N}) where {Perm, N}
#     t.t[_permute(Val{Perm}, inds)...] = value
# end


text:
mutable struct SinkhornParameters
    L::Int
    ε::Real

    averaged_updates::Bool
    debias::Bool

    update_potentials::Bool
end

SinkhornParameters(L) = SinkhornParameters(L, 5e-3, false, true, false)
SinkhornParameters(L, ε) = SinkhornParameters(L, ε, false, true, false)

function _safe_log!(log_x, x)
    for i in eachindex(x)
        x[i] <= 0 ? log_x[i] = -1e4 : log_x[i] = log(x[i])
    end
end

function _safe_log(x::AbstractArray)
    log_x = zero(x)
    for i in eachindex(x)
        x[i] <= 0 ? log_x[i] = -1e4 : log_x[i] = log(x[i])
    end
    log_x
end

function _safe_log(x::Real)
    if x <= 0
        return -1e4
    else
        return log(x)
    end
end

max_stars_repo_name: JuliaRCM/WassersteinDictionaries

max_issues_repo_name: JuliaRCM/WassersteinDictionaries

max_forks_repo_name: JuliaRCM/WassersteinDictionaries


text:
julia> uppercase("alphaBETA")
"ALPHABETA"

julia> lowercase("alphaBETA")
"alphabeta"

max_stars_repo_name: ethansaxenian/RosettaDecode

max_issues_repo_name: ethansaxenian/RosettaDecode

max_forks_repo_name: ethansaxenian/RosettaDecode


text:
module TestUtil
using Test
using LinearAlgebra
using CompressedSensing: cumbabel, coherence, babel, sparse_data,
                precondition!, normalize!, preconditioner, dropindex!

@testset "dictionary analysis" begin
    n, m, k = 64, 128, 16
    A, x, b = sparse_data(n = n, m = m, k = k, rescaled = true)
    μ = coherence(A)
    @test μ isa Real
    @test 0 < μ
    @test babel(A, 1) ≈ μ
    μ₁ = cumbabel(A, k)
    @test μ₁ ≈ babel.((A,), 1:k)
    tol = 1e-12 # tolerance for violation of inequality
    for (i, μ_i) in enumerate(μ₁)
        @test μ_i ≤ i*μ + tol
    end
end

@testset "preconditioning" begin
    n, m, k = 64, 128, 6
    A, x, b = sparse_data(n = n, m = m, k = k, rescaled = false)
    @. A = abs(A) # preconditioning important for coherence dictionaries
    normalize!(A)
    @. x = abs(x)
    b = A*x

    # svd-based preconditioner, generally yields good babel function improvements
    PA = copy(A)
    PA = normalize!(preconditioner(A)(PA)) # renormalize after preconditioning
    μ = cumbabel(A, k)
    Pμ = cumbabel(PA, k)
    for i in 1:k  # test that preconditioner decreases babel function
        @test Pμ[i] < μ[i]
    end
    # mean preconditioner, babel improvement of MA good but not as large as PA
    ε = 1e-6
    MA = copy(A)
    normalize!(preconditioner(ε)(MA))
    Mμ = cumbabel(MA, k)
    for i in 1:k  # test that preconditioner decreases babel function
        @test Mμ[i] < μ[i]
    end
end
using SparseArrays
@testset "SparseArrays extensions" begin
    n = 16
    x = spzeros(n)
    k = 3
    @. x[1:k] = 1:k
    @test nnz(x) == k
    dropindex!(x, 1)
    @test x.nzind == [2, 3]
    @test x.nzval == [2, 3]
    @test nnz(x) == k-1
    # TODO: argmin, findmin
end

end

# display(μ)
# display(Mμ)
# display(Pμ)

# PPA = copy(PA)
# repeated application does change babel function, but not meaningfully
# for _ in 1:6
#     PPA = normalize!(preconditioner(PPA)(copy(PPA)))
#     PPμ = cumbabel(PPA, k)
#     display(PPμ)
# end


text:
function zero_matrix!(mat :: Array{Int32, 2})
  N :: Int = size(mat, 1) # row
  M :: Int = size(mat, 2) # col

  # Mark if the first row should be cleaned
  clear_first_row :: Bool = false
  for col = 1:M
    if mat[1, col] == 0 clear_first_row = true; end
  end

  # Mark each row and col to be cleaned
  for row = 2:N
    for col = 1:M
      if mat[row, col] == 0
        mat[row, 1] = 0
        mat[1, col] = 0
        break
      end
    end
  end

  # Clean columns
  for col = 1:M
    if mat[1, col] == 0
      for r = 1:N
        mat[r, col] = 0
      end
    end
  end

  # Clean the first row
  if clear_first_row
    for c = 1:M mat[1, c] = 0; end
  end

  # Clean rows
  for row =2:N
    if mat[row, 1] == 0
      for c = 1:M
        mat[row, c] = 0
      end
    end
  end

end

# Time  : O(mn)
# Space : O(1)

using Base: Test

mat = Array{Int32, 2}([[1 2 3 0];[4 5 6 11];[7 8 9 12]])
zero_matrix!(mat)
@test mat == Array{Int32, 2}([[0 0 0 0];[4 5 6 0];[7 8 9 0]])

max_stars_repo_name: Kiandr/crackingcodinginterview

max_issues_repo_name: Kiandr/crackingcodinginterview

max_forks_repo_name: Kiandr/crackingcodinginterview


text:
using DrWatson
@quickactivate "NonlinearDynamicsTextbook"
include(srcdir("colorscheme.jl"))
import GLMakie, GraphMakie
using GraphMakie.NetworkLayout, LightGraphs

n0 = 25
seed = 42
n2 = 100 # for getting distribution

er = n -> erdos_renyi(n, 0.25; seed)
ba = n -> barabasi_albert(2n, 3, 1; complete=true, seed)
ws = n -> watts_strogatz(n, 4, 0.1; seed)

fig = GLMakie.Figure(resolution = (800, 400))

graphs = (er, ba, ws)
names = ("Erdős–Rényi ", "Barabási–Albert", "Watts-Strogatz")
for (i, n) in enumerate(names)
    ax = GLMakie.Axis(fig[1,i], title = n)
    g = graphs[i](n0)
    layout = i == 3 ? Shell() : Spring()
    GraphMakie.graphplot!(ax, g, layout=layout, edge_color = COLORS[1], node_color = BLACK)
    GLMakie.hidedecorations!(ax)
    GLMakie.hidespines!(ax)

    degax = GLMakie.Axis(fig[2,i], ylabel = i == 1 ? L"P(k)" : "")
    degax.ylabelsize = 32
    g2 = graphs[i](n2)
    dh = degree_histogram(g2)
    k = Int.(keys(dh))
    p = Int.(values(dh))
    GLMakie.barplot!(degax, k, p, color = BLACK)
end

GLMakie.rowsize!(fig.layout, 2, GLMakie.Relative(1/3))
# display(fig)
GLMakie.save(plotsdir("10", "network_showcase.png"), fig; px_per_unit = 4)

max_stars_repo_name: JuliaDynamics/NonlinearDynamicsTextbook

max_issues_repo_name: JuliaDynamics/NonlinearDynamicsTextbook

max_forks_repo_name: JuliaDynamics/NonlinearDynamicsTextbook


text:
using Documenter, ArchGDAL

# make sure you have run the tests before such that the test files are present
makedocs(
    modules = [ArchGDAL],
    format = Documenter.HTML(),
    sitename = "ArchGDAL.jl",
    workdir = joinpath(@__DIR__, "..", "test"),
    strict = true,
    pages = [
        "index.md",
        "GDAL Datasets" => "datasets.md",
        "Feature Data" => "features.md",
        "Raster Data" => "rasters.md",
        "Geometric Operations" => "geometries.md",
        "Spatial Projections" => "projections.md",
        # "Working with Spatialite" => "spatialite.md",
        "Interactive versus Scoped Objects" => "memory.md",
        "Design Considerations" => "considerations.md",
        "API Reference" => "reference.md",
        # "Naming Conventions" => "conventions.md", # table between GDAL, GDAL.jl, and ArchGDAL.jl
    ]
)

deploydocs(
    deps = nothing,
    make = nothing,
    target = "build",
    repo = "github.com/yeesian/ArchGDAL.jl.git",
)