Generated by Cython 0.29.12
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: kernel_evaluations.c
+001: #!/usr/bin/env python
__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:
003: '''
004: Licensed to the Apache Software Foundation (ASF) under one or more
005: contributor license agreements. See the NOTICE file distributed with this
006: work for additional information regarding copyright ownership. The ASF
007: licenses this file to you under the Apache License, Version 2.0 (the
008: "License"); you may not use this file except in compliance with the
009: License. You may obtain a copy of the License at
010:
011: http://www.apache.org/licenses/LICENSE-2.0
012:
013: Unless required by applicable law or agreed to in writing, software
014: distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
015: WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
016: License for the specific language governing permissions and limitations
017: under the License.
018:
019: The code in this file was developed at Harvard University (2018) and
020: modified at ChemOS Inc. (2019) as stated in the NOTICE file.
021: '''
022:
+023: __author__ = 'Florian Hase'
if (PyDict_SetItem(__pyx_d, __pyx_n_s_author, __pyx_kp_s_Florian_Hase) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
024:
025: #=========================================================================
026:
027: import cython
028: cimport cython
029:
030: from cython.parallel import prange
031:
+032: import numpy as np
__pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
033: cimport numpy as np
034:
035: from libc.math cimport exp, abs, round
036:
037: #=========================================================================
038:
+039: cdef class KernelEvaluator:
struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator { PyObject_HEAD struct __pyx_vtabstruct_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *__pyx_vtab; int num_samples; int num_obs; int num_kernels; double lower_prob_bound; double inv_vol; PyArrayObject *np_locs; PyArrayObject *np_sqrt_precs; PyArrayObject *np_objs; PyArrayObject *np_probs; }; /* … */ struct __pyx_vtabstruct_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator { __Pyx_memviewslice (*_probs)(struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *, __Pyx_memviewslice); PyObject *(*get_kernel)(struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *, PyArrayObject *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *__pyx_vtabptr_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator;
040:
041: cdef int num_samples, num_obs, num_kernels
042: cdef double lower_prob_bound, inv_vol
043:
044: cdef np.ndarray np_locs, np_sqrt_precs
045: cdef np.ndarray np_objs
046: cdef np.ndarray np_probs
047:
+048: def __init__(self, locs, sqrt_precs, lower_prob_bound, objs, inv_vol):
/* Python wrapper */ static int __pyx_pw_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_locs = 0; PyObject *__pyx_v_sqrt_precs = 0; PyObject *__pyx_v_lower_prob_bound = 0; PyObject *__pyx_v_objs = 0; PyObject *__pyx_v_inv_vol = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_locs,&__pyx_n_s_sqrt_precs,&__pyx_n_s_lower_prob_bound,&__pyx_n_s_objs,&__pyx_n_s_inv_vol,0}; PyObject* values[5] = {0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_locs)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sqrt_precs)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(0, 48, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lower_prob_bound)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(0, 48, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_objs)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(0, 48, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inv_vol)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(0, 48, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 48, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } __pyx_v_locs = values[0]; __pyx_v_sqrt_precs = values[1]; __pyx_v_lower_prob_bound = values[2]; __pyx_v_objs = values[3]; __pyx_v_inv_vol = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 48, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("phoenics.BayesianNetwork.kernel_evaluations.KernelEvaluator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator___init__(((struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *)__pyx_v_self), __pyx_v_locs, __pyx_v_sqrt_precs, __pyx_v_lower_prob_bound, __pyx_v_objs, __pyx_v_inv_vol); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator___init__(struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *__pyx_v_self, PyObject *__pyx_v_locs, PyObject *__pyx_v_sqrt_precs, PyObject *__pyx_v_lower_prob_bound, PyObject *__pyx_v_objs, PyObject *__pyx_v_inv_vol) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("phoenics.BayesianNetwork.kernel_evaluations.KernelEvaluator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
049:
+050: self.np_locs = locs
if (!(likely(((__pyx_v_locs) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_locs, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 50, __pyx_L1_error) __pyx_t_1 = __pyx_v_locs; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->np_locs); __Pyx_DECREF(((PyObject *)__pyx_v_self->np_locs)); __pyx_v_self->np_locs = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0;
+051: self.np_sqrt_precs = sqrt_precs
if (!(likely(((__pyx_v_sqrt_precs) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_sqrt_precs, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 51, __pyx_L1_error) __pyx_t_1 = __pyx_v_sqrt_precs; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->np_sqrt_precs); __Pyx_DECREF(((PyObject *)__pyx_v_self->np_sqrt_precs)); __pyx_v_self->np_sqrt_precs = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0;
+052: self.np_objs = objs
if (!(likely(((__pyx_v_objs) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_objs, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 52, __pyx_L1_error) __pyx_t_1 = __pyx_v_objs; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->np_objs); __Pyx_DECREF(((PyObject *)__pyx_v_self->np_objs)); __pyx_v_self->np_objs = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0;
053:
+054: self.num_samples = locs.shape[0]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_locs, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_self->num_samples = __pyx_t_3;
+055: self.num_obs = locs.shape[1]
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_locs, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->num_obs = __pyx_t_3;
+056: self.num_kernels = locs.shape[2]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_locs, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_self->num_kernels = __pyx_t_3;
+057: self.lower_prob_bound = lower_prob_bound
__pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_lower_prob_bound); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L1_error) __pyx_v_self->lower_prob_bound = __pyx_t_4;
+058: self.inv_vol = inv_vol
__pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_inv_vol); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 58, __pyx_L1_error) __pyx_v_self->inv_vol = __pyx_t_4;
059:
+060: self.np_probs = np.zeros(self.num_obs, dtype = np.float64)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->num_obs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_float64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_7); __Pyx_GOTREF(__pyx_v_self->np_probs); __Pyx_DECREF(((PyObject *)__pyx_v_self->np_probs)); __pyx_v_self->np_probs = ((PyArrayObject *)__pyx_t_7); __pyx_t_7 = 0;
061:
062:
+063: cdef double [:] _probs(self, double [:] sample):
static __Pyx_memviewslice __pyx_f_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator__probs(struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *__pyx_v_self, __Pyx_memviewslice __pyx_v_sample) { int __pyx_v_sample_index; int __pyx_v_obs_index; int __pyx_v_kernel_index; double __pyx_v_total_prob; double __pyx_v_prec_prod; double __pyx_v_exp_arg_sum; __Pyx_memviewslice __pyx_v_locs = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_sqrt_precs = { 0, 0, { 0 }, { 0 }, { 0 } }; double __pyx_v_inv_sqrt_two_pi; __Pyx_memviewslice __pyx_v_probs = { 0, 0, { 0 }, { 0 }, { 0 } }; double __pyx_v_obs_probs; __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_probs", 0); /* … */ /* function exit code */ __pyx_L1_error:; __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); __pyx_r.data = NULL; __pyx_r.memview = NULL; __Pyx_AddTraceback("phoenics.BayesianNetwork.kernel_evaluations.KernelEvaluator._probs", __pyx_clineno, __pyx_lineno, __pyx_filename); goto __pyx_L2; __pyx_L0:; if (unlikely(!__pyx_r.memview)) { PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized"); } __pyx_L2:; __PYX_XDEC_MEMVIEW(&__pyx_v_locs, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_sqrt_precs, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_probs, 1); __Pyx_RefNannyFinishContext(); return __pyx_r; }
064:
065: cdef int sample_index, obs_index, kernel_index
066: cdef int num_indices
067: cdef double total_prob, prec_prod, exp_arg_sum
068:
+069: cdef double [:, :, :] locs = self.np_locs
__pyx_t_1 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(((PyObject *)__pyx_v_self->np_locs), PyBUF_WRITABLE); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(0, 69, __pyx_L1_error) __pyx_v_locs = __pyx_t_1; __pyx_t_1.memview = NULL; __pyx_t_1.data = NULL;
+070: cdef double [:, :, :] sqrt_precs = self.np_sqrt_precs
__pyx_t_1 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(((PyObject *)__pyx_v_self->np_sqrt_precs), PyBUF_WRITABLE); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(0, 70, __pyx_L1_error) __pyx_v_sqrt_precs = __pyx_t_1; __pyx_t_1.memview = NULL; __pyx_t_1.data = NULL;
+071: cdef double inv_sqrt_two_pi = 0.3989422804014327
__pyx_v_inv_sqrt_two_pi = 0.3989422804014327;
072:
+073: cdef double [:] probs = self.np_probs
__pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(((PyObject *)__pyx_v_self->np_probs), PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 73, __pyx_L1_error) __pyx_v_probs = __pyx_t_2; __pyx_t_2.memview = NULL; __pyx_t_2.data = NULL;
+074: for obs_index in range(self.num_obs):
__pyx_t_3 = __pyx_v_self->num_obs; __pyx_t_4 = __pyx_t_3; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_obs_index = __pyx_t_5;
+075: probs[obs_index] = 0.
__pyx_t_6 = __pyx_v_obs_index; __pyx_t_7 = -1; if (__pyx_t_6 < 0) { __pyx_t_6 += __pyx_v_probs.shape[0]; if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0; } else if (unlikely(__pyx_t_6 >= __pyx_v_probs.shape[0])) __pyx_t_7 = 0; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); __PYX_ERR(0, 75, __pyx_L1_error) } *((double *) ( /* dim=0 */ (__pyx_v_probs.data + __pyx_t_6 * __pyx_v_probs.strides[0]) )) = 0.; }
076:
077: cdef double obs_probs
078:
+079: for obs_index in range(self.num_obs):
__pyx_t_3 = __pyx_v_self->num_obs; __pyx_t_4 = __pyx_t_3; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_obs_index = __pyx_t_5;
+080: obs_probs = 0.
__pyx_v_obs_probs = 0.;
081:
+082: for sample_index in range(self.num_samples):
__pyx_t_7 = __pyx_v_self->num_samples; __pyx_t_8 = __pyx_t_7; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_sample_index = __pyx_t_9;
+083: total_prob = 1.
__pyx_v_total_prob = 1.;
+084: prec_prod = 1.
__pyx_v_prec_prod = 1.;
+085: exp_arg_sum = 0.
__pyx_v_exp_arg_sum = 0.;
+086: kernel_index = 0
__pyx_v_kernel_index = 0;
087:
+088: while kernel_index < self.num_kernels:
while (1) { __pyx_t_10 = ((__pyx_v_kernel_index < __pyx_v_self->num_kernels) != 0); if (!__pyx_t_10) break;
089:
+090: prec_prod = prec_prod * sqrt_precs[sample_index, obs_index, kernel_index]
__pyx_t_11 = __pyx_v_sample_index; __pyx_t_12 = __pyx_v_obs_index; __pyx_t_13 = __pyx_v_kernel_index; __pyx_t_14 = -1; if (__pyx_t_11 < 0) { __pyx_t_11 += __pyx_v_sqrt_precs.shape[0]; if (unlikely(__pyx_t_11 < 0)) __pyx_t_14 = 0; } else if (unlikely(__pyx_t_11 >= __pyx_v_sqrt_precs.shape[0])) __pyx_t_14 = 0; if (__pyx_t_12 < 0) { __pyx_t_12 += __pyx_v_sqrt_precs.shape[1]; if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 1; } else if (unlikely(__pyx_t_12 >= __pyx_v_sqrt_precs.shape[1])) __pyx_t_14 = 1; if (__pyx_t_13 < 0) { __pyx_t_13 += __pyx_v_sqrt_precs.shape[2]; if (unlikely(__pyx_t_13 < 0)) __pyx_t_14 = 2; } else if (unlikely(__pyx_t_13 >= __pyx_v_sqrt_precs.shape[2])) __pyx_t_14 = 2; if (unlikely(__pyx_t_14 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_14); __PYX_ERR(0, 90, __pyx_L1_error) } __pyx_v_prec_prod = (__pyx_v_prec_prod * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sqrt_precs.data + __pyx_t_11 * __pyx_v_sqrt_precs.strides[0]) ) + __pyx_t_12 * __pyx_v_sqrt_precs.strides[1]) ) + __pyx_t_13 * __pyx_v_sqrt_precs.strides[2]) ))));
+091: exp_arg_sum = exp_arg_sum + (sqrt_precs[sample_index, obs_index, kernel_index] * (sample[kernel_index] - locs[sample_index, obs_index, kernel_index]))**2
__pyx_t_15 = __pyx_v_sample_index; __pyx_t_16 = __pyx_v_obs_index; __pyx_t_17 = __pyx_v_kernel_index; __pyx_t_14 = -1; if (__pyx_t_15 < 0) { __pyx_t_15 += __pyx_v_sqrt_precs.shape[0]; if (unlikely(__pyx_t_15 < 0)) __pyx_t_14 = 0; } else if (unlikely(__pyx_t_15 >= __pyx_v_sqrt_precs.shape[0])) __pyx_t_14 = 0; if (__pyx_t_16 < 0) { __pyx_t_16 += __pyx_v_sqrt_precs.shape[1]; if (unlikely(__pyx_t_16 < 0)) __pyx_t_14 = 1; } else if (unlikely(__pyx_t_16 >= __pyx_v_sqrt_precs.shape[1])) __pyx_t_14 = 1; if (__pyx_t_17 < 0) { __pyx_t_17 += __pyx_v_sqrt_precs.shape[2]; if (unlikely(__pyx_t_17 < 0)) __pyx_t_14 = 2; } else if (unlikely(__pyx_t_17 >= __pyx_v_sqrt_precs.shape[2])) __pyx_t_14 = 2; if (unlikely(__pyx_t_14 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_14); __PYX_ERR(0, 91, __pyx_L1_error) } __pyx_t_18 = __pyx_v_kernel_index; __pyx_t_14 = -1; if (__pyx_t_18 < 0) { __pyx_t_18 += __pyx_v_sample.shape[0]; if (unlikely(__pyx_t_18 < 0)) __pyx_t_14 = 0; } else if (unlikely(__pyx_t_18 >= __pyx_v_sample.shape[0])) __pyx_t_14 = 0; if (unlikely(__pyx_t_14 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_14); __PYX_ERR(0, 91, __pyx_L1_error) } __pyx_t_19 = __pyx_v_sample_index; __pyx_t_20 = __pyx_v_obs_index; __pyx_t_21 = __pyx_v_kernel_index; __pyx_t_14 = -1; if (__pyx_t_19 < 0) { __pyx_t_19 += __pyx_v_locs.shape[0]; if (unlikely(__pyx_t_19 < 0)) __pyx_t_14 = 0; } else if (unlikely(__pyx_t_19 >= __pyx_v_locs.shape[0])) __pyx_t_14 = 0; if (__pyx_t_20 < 0) { __pyx_t_20 += __pyx_v_locs.shape[1]; if (unlikely(__pyx_t_20 < 0)) __pyx_t_14 = 1; } else if (unlikely(__pyx_t_20 >= __pyx_v_locs.shape[1])) __pyx_t_14 = 1; if (__pyx_t_21 < 0) { __pyx_t_21 += __pyx_v_locs.shape[2]; if (unlikely(__pyx_t_21 < 0)) __pyx_t_14 = 2; } else if (unlikely(__pyx_t_21 >= __pyx_v_locs.shape[2])) __pyx_t_14 = 2; if (unlikely(__pyx_t_14 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_14); __PYX_ERR(0, 91, __pyx_L1_error) } __pyx_v_exp_arg_sum = (__pyx_v_exp_arg_sum + pow(((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sqrt_precs.data + __pyx_t_15 * __pyx_v_sqrt_precs.strides[0]) ) + __pyx_t_16 * __pyx_v_sqrt_precs.strides[1]) ) + __pyx_t_17 * __pyx_v_sqrt_precs.strides[2]) ))) * ((*((double *) ( /* dim=0 */ (__pyx_v_sample.data + __pyx_t_18 * __pyx_v_sample.strides[0]) ))) - (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_locs.data + __pyx_t_19 * __pyx_v_locs.strides[0]) ) + __pyx_t_20 * __pyx_v_locs.strides[1]) ) + __pyx_t_21 * __pyx_v_locs.strides[2]) ))))), 2.0));
+092: kernel_index += 1
__pyx_v_kernel_index = (__pyx_v_kernel_index + 1); }
093:
+094: obs_probs += total_prob * prec_prod * exp( - 0.5 * exp_arg_sum)
__pyx_v_obs_probs = (__pyx_v_obs_probs + ((__pyx_v_total_prob * __pyx_v_prec_prod) * exp((-0.5 * __pyx_v_exp_arg_sum))));
095:
+096: if sample_index == 100:
__pyx_t_10 = ((__pyx_v_sample_index == 0x64) != 0); if (__pyx_t_10) { /* … */ } } /*else*/ {
+097: if 0.01 * obs_probs * inv_sqrt_two_pi**self.num_kernels < self.lower_prob_bound:
__pyx_t_10 = ((((0.01 * __pyx_v_obs_probs) * pow(__pyx_v_inv_sqrt_two_pi, ((double)__pyx_v_self->num_kernels))) < __pyx_v_self->lower_prob_bound) != 0); if (__pyx_t_10) { /* … */ }
+098: probs[obs_index] = 0.01 * obs_probs * inv_sqrt_two_pi**self.num_kernels / self.num_samples
__pyx_t_22 = ((0.01 * __pyx_v_obs_probs) * pow(__pyx_v_inv_sqrt_two_pi, ((double)__pyx_v_self->num_kernels))); if (unlikely(__pyx_v_self->num_samples == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 98, __pyx_L1_error) } __pyx_t_23 = __pyx_v_obs_index; __pyx_t_14 = -1; if (__pyx_t_23 < 0) { __pyx_t_23 += __pyx_v_probs.shape[0]; if (unlikely(__pyx_t_23 < 0)) __pyx_t_14 = 0; } else if (unlikely(__pyx_t_23 >= __pyx_v_probs.shape[0])) __pyx_t_14 = 0; if (unlikely(__pyx_t_14 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_14); __PYX_ERR(0, 98, __pyx_L1_error) } *((double *) ( /* dim=0 */ (__pyx_v_probs.data + __pyx_t_23 * __pyx_v_probs.strides[0]) )) = (__pyx_t_22 / __pyx_v_self->num_samples);
+099: break
goto __pyx_L8_break;
100: else:
+101: probs[obs_index] = obs_probs * inv_sqrt_two_pi**self.num_kernels / self.num_samples
__pyx_t_22 = (__pyx_v_obs_probs * pow(__pyx_v_inv_sqrt_two_pi, ((double)__pyx_v_self->num_kernels))); if (unlikely(__pyx_v_self->num_samples == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 101, __pyx_L1_error) } __pyx_t_24 = __pyx_v_obs_index; __pyx_t_9 = -1; if (__pyx_t_24 < 0) { __pyx_t_24 += __pyx_v_probs.shape[0]; if (unlikely(__pyx_t_24 < 0)) __pyx_t_9 = 0; } else if (unlikely(__pyx_t_24 >= __pyx_v_probs.shape[0])) __pyx_t_9 = 0; if (unlikely(__pyx_t_9 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_9); __PYX_ERR(0, 101, __pyx_L1_error) } *((double *) ( /* dim=0 */ (__pyx_v_probs.data + __pyx_t_24 * __pyx_v_probs.strides[0]) )) = (__pyx_t_22 / __pyx_v_self->num_samples); } __pyx_L8_break:; }
+102: return probs
__PYX_INC_MEMVIEW(&__pyx_v_probs, 0); __pyx_r = __pyx_v_probs; goto __pyx_L0;
103:
104:
105: # @cython.boundscheck(False)
+106: cpdef get_kernel(self, np.ndarray sample):
static PyObject *__pyx_pw_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_3get_kernel(PyObject *__pyx_v_self, PyObject *__pyx_v_sample); /*proto*/ static PyObject *__pyx_f_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_get_kernel(struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *__pyx_v_self, PyArrayObject *__pyx_v_sample, int __pyx_skip_dispatch) { int __pyx_v_obs_index; double __pyx_v_temp_0; double __pyx_v_temp_1; double __pyx_v_inv_den; __Pyx_memviewslice __pyx_v_sample_memview = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_v_probs_sample = NULL; double __pyx_v_num; double __pyx_v_den; __Pyx_memviewslice __pyx_v_objs = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_kernel", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_kernel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_3get_kernel)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_sample)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_sample)); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_AddTraceback("phoenics.BayesianNetwork.kernel_evaluations.KernelEvaluator.get_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_sample_memview, 1); __Pyx_XDECREF(__pyx_v_probs_sample); __PYX_XDEC_MEMVIEW(&__pyx_v_objs, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_3get_kernel(PyObject *__pyx_v_self, PyObject *__pyx_v_sample); /*proto*/ static PyObject *__pyx_pw_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_3get_kernel(PyObject *__pyx_v_self, PyObject *__pyx_v_sample) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_kernel (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample), __pyx_ptype_5numpy_ndarray, 1, "sample", 0))) __PYX_ERR(0, 106, __pyx_L1_error) __pyx_r = __pyx_pf_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_2get_kernel(((struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *)__pyx_v_self), ((PyArrayObject *)__pyx_v_sample)); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_2get_kernel(struct __pyx_obj_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *__pyx_v_self, PyArrayObject *__pyx_v_sample) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_kernel", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_8phoenics_15BayesianNetwork_18kernel_evaluations_15KernelEvaluator_get_kernel(__pyx_v_self, __pyx_v_sample, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("phoenics.BayesianNetwork.kernel_evaluations.KernelEvaluator.get_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
107:
108: cdef int obs_index
109: cdef double temp_0, temp_1
110: cdef double inv_den
111:
+112: cdef double [:] sample_memview = sample
__pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(((PyObject *)__pyx_v_sample), PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 112, __pyx_L1_error) __pyx_v_sample_memview = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
+113: probs_sample = self._probs(sample_memview)
__pyx_t_5 = ((struct __pyx_vtabstruct_8phoenics_15BayesianNetwork_18kernel_evaluations_KernelEvaluator *)__pyx_v_self->__pyx_vtab)->_probs(__pyx_v_self, __pyx_v_sample_memview); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 113, __pyx_L1_error) __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_t_5, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL; __pyx_v_probs_sample = __pyx_t_1; __pyx_t_1 = 0;
114:
115: # construct numerator and denominator of acquisition
+116: cdef double num = 0.
__pyx_v_num = 0.;
+117: cdef double den = 0.
__pyx_v_den = 0.;
+118: cdef double [:] objs = self.np_objs
__pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(((PyObject *)__pyx_v_self->np_objs), PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 118, __pyx_L1_error) __pyx_v_objs = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
119:
+120: for obs_index in range(self.num_obs):
__pyx_t_6 = __pyx_v_self->num_obs; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_obs_index = __pyx_t_8;
+121: temp_0 = objs[obs_index]
__pyx_t_9 = __pyx_v_obs_index; __pyx_t_10 = -1; if (__pyx_t_9 < 0) { __pyx_t_9 += __pyx_v_objs.shape[0]; if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 0; } else if (unlikely(__pyx_t_9 >= __pyx_v_objs.shape[0])) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); __PYX_ERR(0, 121, __pyx_L1_error) } __pyx_v_temp_0 = (*((double *) ( /* dim=0 */ (__pyx_v_objs.data + __pyx_t_9 * __pyx_v_objs.strides[0]) )));
+122: temp_1 = probs_sample[obs_index]
__pyx_t_1 = __Pyx_GetItemInt(__pyx_v_probs_sample, __pyx_v_obs_index, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_temp_1 = __pyx_t_11;
+123: num += temp_0 * temp_1
__pyx_v_num = (__pyx_v_num + (__pyx_v_temp_0 * __pyx_v_temp_1));
+124: den += temp_1
__pyx_v_den = (__pyx_v_den + __pyx_v_temp_1); }
125:
+126: inv_den = 1. / (self.inv_vol + den)
__pyx_t_11 = (__pyx_v_self->inv_vol + __pyx_v_den); if (unlikely(__pyx_t_11 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 126, __pyx_L1_error) } __pyx_v_inv_den = (1. / __pyx_t_11);
127:
+128: return num, inv_den, probs_sample
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_num); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyFloat_FromDouble(__pyx_v_inv_den); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_INCREF(__pyx_v_probs_sample); __Pyx_GIVEREF(__pyx_v_probs_sample); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_probs_sample); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
129:
130:
131:
132:
133:
134: