Cython: sparse_matrix_ext.pyx

Generated by Cython 0.29.28

Yellow lines hint at Python interaction.
Click on a line that starts with a "`+`" to see the C code that Cython generated for it.

Raw output: sparse_matrix_ext.c

    +001: #cython: wraparound=False, boundscheck=False, cdivision=True, profile=False, nonecheck=False, overflowcheck=False, cdivision_warnings=False, unraisable_tracebacks=False

      __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     002: import cython

     003: from libc.stdlib cimport malloc, free

     004: from cpython.pycapsule cimport *

     005: # import both numpy and the Cython declarations for numpy

    +006: import numpy as np

      __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     007: cimport numpy as np

     008: # declare the interface to the C code

     009: cdef extern from "sparse_dok.c":

     010: 	ctypedef struct UT_hash_handle:

     011: 		UT_hash_handle* tbl

     012: 		void* prev

     013: 		void* next

     014: 		UT_hash_handle* hh_prev

     015: 		UT_hash_handle* hh_next

     016: 		void* key

     017: 		unsigned keylen

     018: 		unsigned hashv

     019: 	ctypedef struct edge_key_t:

     020: 		int i

     021: 		int j

     022: 	ctypedef struct edge_t:

     023: 		edge_key_t key

     024: 		double entry

     025: 		UT_hash_handle hh

     026: 	ctypedef struct sparse_dok:

     027: 		edge_t* edgetable

     028: 		int num_entries

     029: 		int num_rows

     030: 	void delete_dok_matrix(sparse_dok* mat)

     031: 	void sort_by_key(sparse_dok* hashtable)

     032: 	void add_dok_entry(sparse_dok* edgetable, edge_key_t key, double value)

     033: 	sparse_dok* make_dok()

     034:

    +035: cdef delete_dok_cap(object cap):

    static PyObject *__pyx_f_5anuga_9utilities_17sparse_matrix_ext_delete_dok_cap(PyObject *__pyx_v_cap) {
      sparse_dok *__pyx_v_kill;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("delete_dok_cap", 0);
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_AddTraceback("anuga.utilities.sparse_matrix_ext.delete_dok_cap", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    +036: 	kill = <sparse_dok* > PyCapsule_GetPointer(cap, "sparse dok")

      __pyx_t_1 = PyCapsule_GetPointer(__pyx_v_cap, ((char const *)"sparse dok")); if (unlikely(__pyx_t_1 == ((void *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L1_error)
      __pyx_v_kill = ((sparse_dok *)__pyx_t_1);

    +037: 	if kill != NULL:

      __pyx_t_2 = ((__pyx_v_kill != NULL) != 0);
      if (__pyx_t_2) {
    /* … */
      }

    +038: 		delete_dok_matrix(kill)

        delete_dok_matrix(__pyx_v_kill);

     039:

    +040: cdef int _serialise(sparse_dok* dok, dict serial_dok):

    static int __pyx_f_5anuga_9utilities_17sparse_matrix_ext__serialise(sparse_dok *__pyx_v_dok, PyObject *__pyx_v_serial_dok) {
      int __pyx_v_num_entries;
      CYTHON_UNUSED int __pyx_v_k;
      int __pyx_v_i;
      int __pyx_v_j;
      double __pyx_v_val;
      edge_t *__pyx_v_edge;
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_serialise", 0);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_XDECREF(__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_9);
      __Pyx_XDECREF(__pyx_t_10);
      __Pyx_WriteUnraisable("anuga.utilities.sparse_matrix_ext._serialise", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     041:

    +042: 	sort_by_key(dok)

      sort_by_key(__pyx_v_dok);

     043: 	cdef int num_entries

     044: 	cdef int k,i,j

     045: 	cdef double val

     046: 	cdef edge_t* edge

     047:

    +048: 	num_entries = dok.num_entries

      __pyx_t_1 = __pyx_v_dok->num_entries;
      __pyx_v_num_entries = __pyx_t_1;

    +049: 	edge = dok.edgetable

      __pyx_t_2 = __pyx_v_dok->edgetable;
      __pyx_v_edge = __pyx_t_2;

     050:

    +051: 	for k in xrange(num_entries):

      __pyx_t_1 = __pyx_v_num_entries;
      __pyx_t_3 = __pyx_t_1;
      for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
        __pyx_v_k = __pyx_t_4;

     052:

    +053: 		i = edge.key.i

        __pyx_t_5 = __pyx_v_edge->key.i;
        __pyx_v_i = __pyx_t_5;

    +054: 		j = edge.key.j

        __pyx_t_5 = __pyx_v_edge->key.j;
        __pyx_v_j = __pyx_t_5;

    +055: 		val = edge.entry

        __pyx_t_6 = __pyx_v_edge->entry;
        __pyx_v_val = __pyx_t_6;

     056:

    +057: 		serial_dok[(i,j)] = val

        __pyx_t_7 = PyFloat_FromDouble(__pyx_v_val); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 57, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (unlikely(__pyx_v_serial_dok == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 57, __pyx_L1_error)
        }
        __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 57, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 57, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 57, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
        __pyx_t_8 = 0;
        __pyx_t_9 = 0;
        if (unlikely(PyDict_SetItem(__pyx_v_serial_dok, __pyx_t_10, __pyx_t_7) < 0)) __PYX_ERR(0, 57, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

     058:

    +059: 		edge = <edge_t* > edge.hh.next

        __pyx_v_edge = ((edge_t *)__pyx_v_edge->hh.next);
      }

     060:

    +061: 	return 0

      __pyx_r = 0;
      goto __pyx_L0;

     062:

    +063: cdef int _deserialise(sparse_dok* dok, dict serial_dok):

    static int __pyx_f_5anuga_9utilities_17sparse_matrix_ext__deserialise(sparse_dok *__pyx_v_dok, PyObject *__pyx_v_serial_dok) {
      int __pyx_v_num_entries;
      int __pyx_v_k;
      int __pyx_v_i;
      int __pyx_v_j;
      double __pyx_v_val;
      CYTHON_UNUSED PyObject *__pyx_v_items = 0;
      PyObject *__pyx_v_keys = 0;
      edge_key_t __pyx_v_key;
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_deserialise", 0);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_WriteUnraisable("anuga.utilities.sparse_matrix_ext._deserialise", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_items);
      __Pyx_XDECREF(__pyx_v_keys);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     064:

     065: 	cdef int num_entries, k, i, j

     066: 	cdef double val

     067: 	cdef list items

     068: 	cdef list keys

     069: 	cdef edge_key_t key

     070:

    +071: 	items = serial_dok.items()

      if (unlikely(__pyx_v_serial_dok == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
        __PYX_ERR(0, 71, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_serial_dok); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 71, __pyx_L1_error)
      __pyx_v_items = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

    +072: 	keys = serial_dok.keys()

      if (unlikely(__pyx_v_serial_dok == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "keys");
        __PYX_ERR(0, 72, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_PyDict_Keys(__pyx_v_serial_dok); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 72, __pyx_L1_error)
      __pyx_v_keys = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

    +073: 	num_entries = len(serial_dok)

      if (unlikely(__pyx_v_serial_dok == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        __PYX_ERR(0, 73, __pyx_L1_error)
      }
      __pyx_t_2 = PyDict_Size(__pyx_v_serial_dok); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 73, __pyx_L1_error)
      __pyx_v_num_entries = __pyx_t_2;

     074:

    +075: 	for k in xrange(num_entries):

      __pyx_t_3 = __pyx_v_num_entries;
      __pyx_t_4 = __pyx_t_3;
      for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
        __pyx_v_k = __pyx_t_5;

     076:

    +077: 		val = serial_dok[keys[k]]

        if (unlikely(__pyx_v_serial_dok == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 77, __pyx_L1_error)
        }
        if (unlikely(__pyx_v_keys == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 77, __pyx_L1_error)
        }
        __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_serial_dok, PyList_GET_ITEM(__pyx_v_keys, __pyx_v_k)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 77, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_val = __pyx_t_6;

     078:

    +079: 		i = keys[k][0]

        if (unlikely(__pyx_v_keys == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 79, __pyx_L1_error)
        }
        __pyx_t_1 = __Pyx_GetItemInt(PyList_GET_ITEM(__pyx_v_keys, __pyx_v_k), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_i = __pyx_t_7;

    +080: 		j = keys[k][1]

        if (unlikely(__pyx_v_keys == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 80, __pyx_L1_error)
        }
        __pyx_t_1 = __Pyx_GetItemInt(PyList_GET_ITEM(__pyx_v_keys, __pyx_v_k), 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 80, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_j = __pyx_t_7;

     081:

    +082: 		key.i = i

        __pyx_v_key.i = __pyx_v_i;

    +083: 		key.j = j

        __pyx_v_key.j = __pyx_v_j;

     084:

    +085: 		add_dok_entry(dok, key, val)

        add_dok_entry(__pyx_v_dok, __pyx_v_key, __pyx_v_val);
      }

     086:

    +087: 	return 0

      __pyx_r = 0;
      goto __pyx_L0;

     088:

    +089: def serialise_dok(object sparse_dok_cap):

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_9utilities_17sparse_matrix_ext_1serialise_dok(PyObject *__pyx_self, PyObject *__pyx_v_sparse_dok_cap); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_9utilities_17sparse_matrix_ext_1serialise_dok = {"serialise_dok", (PyCFunction)__pyx_pw_5anuga_9utilities_17sparse_matrix_ext_1serialise_dok, METH_O, 0};
    static PyObject *__pyx_pw_5anuga_9utilities_17sparse_matrix_ext_1serialise_dok(PyObject *__pyx_self, PyObject *__pyx_v_sparse_dok_cap) {
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("serialise_dok (wrapper)", 0);
      __pyx_r = __pyx_pf_5anuga_9utilities_17sparse_matrix_ext_serialise_dok(__pyx_self, ((PyObject *)__pyx_v_sparse_dok_cap));

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

    static PyObject *__pyx_pf_5anuga_9utilities_17sparse_matrix_ext_serialise_dok(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sparse_dok_cap) {
      int __pyx_v_err;
      sparse_dok *__pyx_v_dok;
      PyObject *__pyx_v_serial_sparse_dok = 0;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("serialise_dok", 0);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_AddTraceback("anuga.utilities.sparse_matrix_ext.serialise_dok", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_serial_sparse_dok);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__3 = PyTuple_Pack(4, __pyx_n_s_sparse_dok_cap, __pyx_n_s_err, __pyx_n_s_dok, __pyx_n_s_serial_sparse_dok); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__3);
      __Pyx_GIVEREF(__pyx_tuple__3);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_9utilities_17sparse_matrix_ext_1serialise_dok, NULL, __pyx_n_s_anuga_utilities_sparse_matrix_ex_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_serialise_dok, __pyx_t_1) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_anuga_utilities_sparse_matrix_ex, __pyx_n_s_serialise_dok, 89, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 89, __pyx_L1_error)

     090:

     091: 	cdef int err

     092: 	cdef sparse_dok* dok

     093: 	cdef dict serial_sparse_dok

     094:

    +095: 	dok = <sparse_dok* > PyCapsule_GetPointer(sparse_dok_cap, "sparse dok")

      __pyx_t_1 = PyCapsule_GetPointer(__pyx_v_sparse_dok_cap, ((char const *)"sparse dok")); if (unlikely(__pyx_t_1 == ((void *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 95, __pyx_L1_error)
      __pyx_v_dok = ((sparse_dok *)__pyx_t_1);

    +096: 	serial_sparse_dok = {}

      __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_serial_sparse_dok = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;

     097:

    +098: 	err = _serialise(dok, serial_sparse_dok)

      __pyx_v_err = __pyx_f_5anuga_9utilities_17sparse_matrix_ext__serialise(__pyx_v_dok, __pyx_v_serial_sparse_dok);

     099:

    +100: 	assert err == 0, "sparse_matrix.serialise_dok: error in serialising sparse_dok"

      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(!((__pyx_v_err == 0) != 0))) {
          PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_sparse_matrix_serialise_dok_erro);
          __PYX_ERR(0, 100, __pyx_L1_error)
        }
      }
      #endif

     101:

    +102: 	return serial_sparse_dok

      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_serial_sparse_dok);
      __pyx_r = __pyx_v_serial_sparse_dok;
      goto __pyx_L0;

     103:

    +104: def deserialise_dok(dict serial_sparse_dok):

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_9utilities_17sparse_matrix_ext_3deserialise_dok(PyObject *__pyx_self, PyObject *__pyx_v_serial_sparse_dok); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_9utilities_17sparse_matrix_ext_3deserialise_dok = {"deserialise_dok", (PyCFunction)__pyx_pw_5anuga_9utilities_17sparse_matrix_ext_3deserialise_dok, METH_O, 0};
    static PyObject *__pyx_pw_5anuga_9utilities_17sparse_matrix_ext_3deserialise_dok(PyObject *__pyx_self, PyObject *__pyx_v_serial_sparse_dok) {
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("deserialise_dok (wrapper)", 0);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_serial_sparse_dok), (&PyDict_Type), 1, "serial_sparse_dok", 1))) __PYX_ERR(0, 104, __pyx_L1_error)
      __pyx_r = __pyx_pf_5anuga_9utilities_17sparse_matrix_ext_2deserialise_dok(__pyx_self, ((PyObject*)__pyx_v_serial_sparse_dok));
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_5anuga_9utilities_17sparse_matrix_ext_2deserialise_dok(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_serial_sparse_dok) {
      CYTHON_UNUSED int __pyx_v_err;
      sparse_dok *__pyx_v_dok;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("deserialise_dok", 0);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("anuga.utilities.sparse_matrix_ext.deserialise_dok", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__5 = PyTuple_Pack(4, __pyx_n_s_serial_sparse_dok, __pyx_n_s_err, __pyx_n_s_sparse_dok_cap, __pyx_n_s_dok); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__5);
      __Pyx_GIVEREF(__pyx_tuple__5);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_9utilities_17sparse_matrix_ext_3deserialise_dok, NULL, __pyx_n_s_anuga_utilities_sparse_matrix_ex_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_deserialise_dok, __pyx_t_1) < 0) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     105:

     106: 	cdef int err

     107: 	cdef object sparse_dok_cap

     108: 	cdef sparse_dok* dok

     109:

    +110: 	dok = make_dok()

      __pyx_v_dok = make_dok();

     111:

    +112: 	err = _deserialise(dok, serial_sparse_dok)

      __pyx_v_err = __pyx_f_5anuga_9utilities_17sparse_matrix_ext__deserialise(__pyx_v_dok, __pyx_v_serial_sparse_dok);

     113:

    +114: 	return PyCapsule_New(<void* > dok, "sparse dok", <PyCapsule_Destructor> delete_dok_cap)

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = PyCapsule_New(((void *)__pyx_v_dok), ((char const *)"sparse dok"), ((PyCapsule_Destructor)__pyx_f_5anuga_9utilities_17sparse_matrix_ext_delete_dok_cap)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;