Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TST: find_starting_values() seems to fail for HLBA.

  • Loading branch information...
commit c17f6040326cf508ebff57a0e313c64733d393d3 1 parent d3340d9
@twiecki twiecki authored
View
3  clean_build.sh
@@ -1,3 +1,2 @@
rm src/*.c *.so -rf build
-python setup_cython.py build
-sudo python setupegg.py develop
+python setup.py build_ext --inplace
View
4 hddm/models/hddm_info.py
@@ -103,6 +103,10 @@ def __init__(self, *args, **kwargs):
self.slice_widths = {'a':1, 't':0.01, 'a_std': 1, 't_std': 0.15, 'sz': 1.1, 'v': 1.5,
'st': 0.1, 'sv': 3, 'z_trans': 0.2, 'z': 0.1,
'p_outlier':1., 'v_std': 1}
+ self.emcee_dispersions = {'a':1, 't': 0.1, 'a_std': 1, 't_std': 0.15, 'sz': 1.1, 'v': 1.5,
+ 'st': 0.1, 'sv': 3, 'z_trans': 0.2, 'z': 0.1,
+ 'p_outlier':1., 'v_std': 1}
+
self.is_informative = kwargs.pop('informative', True)
View
176 hddm/models/hlba_truncated.py
@@ -4,6 +4,7 @@
import numpy as np
from numpy.random import rand, randn
import pymc as pm
+import pandas as pd
import hddm
import kabuki
@@ -25,11 +26,15 @@ def pdf(self, x):#value, t, A, b, s, v, p_outlier, w_outlier=.1):
return np.exp(p)
-def lba_random(t, A, b, s, v, size=1):
+def lba_random(size=100, **params):
"""Generate RTs from LBA process.
"""
- v0 = v
- v1 = 1 - v
+ t = params['t']
+ A = params['A']
+ b = params['b']
+ s = params['s']
+ v0 = params['v']
+ v1 = 1 - v0
sampled_rts = np.empty(size)
for i_sample in xrange(size):
positive = False
@@ -53,22 +58,171 @@ def lba_random(t, A, b, s, v, size=1):
else:
sampled_rts[i_sample] = -rt1
- return sampled_rts
+ data = pd.DataFrame(sampled_rts, columns=['rt'])
+ data['response'] = 1.
+ data['response'][data['rt']<0] = 0.
+ data['rt'] = np.abs(data['rt'])
+
+ return data
+
lba_class = stochastic_from_dist(name='lba_like', logp=lba_like, random=lba_random)
lba_class.pdf = pdf
+def gen_single_params_set():
+ """Returns a dict of DDM parameters with random values for a singel conditin
+ the function is used by gen_rand_params.
+ """
+ params = {}
+ params['s'] = 2.5*rand()
+ params['b'] = 0.5+rand()*1.5
+ params['A'] = rand() * params['b']
+ params['v'] = rand()
+ params['t'] = 0.2+rand()*0.3
+
+ return params
+
+
+def gen_rand_params(cond_dict=None, seed=None):
+ """Returns a dict of DDM parameters with random values.
+
+ :Optional:
+ cond_dict : dictionary
+ cond_dict is used when multiple conditions are desired.
+ the dictionary has the form of {param1: [value_1, ... , value_n], param2: [value_1, ... , value_n]}
+ and the function will output n sets of parameters. each set with values from the
+ appropriate place in the dictionary
+ for instance if cond_dict={'v': [0, 0.5, 1]} then 3 parameters set will be created.
+ the first with v=0 the second with v=0.5 and the third with v=1.
+
+ seed: float
+ random seed
+
+ Output:
+ if conditions is None:
+ params: dictionary
+ a dictionary holding the parameters values
+ else:
+ cond_params: a dictionary holding the parameters for each one of the conditions,
+ that has the form {'c1': params1, 'c2': params2, ...}
+ it can be used directly as an argument in gen_rand_data.
+ merged_params:
+ a dictionary of parameters that can be used to validate the optimization
+ and learning algorithms.
+ """
+
+
+ #set seed
+ if seed is not None:
+ np.random.seed(seed)
+
+ #if there is only a single condition then we can use gen_single_params_set
+ if cond_dict is None:
+ return gen_single_params_set()
+
+ #generate original parameter set
+ org_params = gen_single_params_set()
+
+ #create a merged set
+ merged_params = org_params.copy()
+ for name in cond_dict.iterkeys():
+ del merged_params[name]
+
+ cond_params = {};
+ n_conds = len(cond_dict.values()[0])
+ for i in range(n_conds):
+ #create a set of parameters for condition i
+ #put them in i_params, and in cond_params[c#i]
+ i_params = org_params.copy()
+ for name in cond_dict.iterkeys():
+ i_params[name] = cond_dict[name][i]
+ cond_params['c%d' %i] = i_params
+
+ #update merged_params
+ merged_params['%s(c%d)' % (name, i)] = cond_dict[name][i]
+
+ return cond_params, merged_params
+
+
+def gen_rand_data(params=None, **kwargs):
+ """Generate simulated RTs with random parameters.
+
+ :Optional:
+ params : dict <default=generate randomly>
+ Either dictionary mapping param names to values.
+
+ Or dictionary mapping condition name to parameter
+ dictionary (see example below).
+
+ If not supplied, takes random values.
+
+ n_fast_outliers : int <default=0>
+ How many fast outliers to add (outlier_RT < ter)
+
+ n_slow_outliers : int <default=0>
+ How many late outliers to add.
+
+ The rest of the arguments are forwarded to kabuki.generate.gen_rand_data
+
+ :Returns:
+ data array with RTs
+ parameter values
+
+ :Example:
+ # Generate random data set
+ >>> data, params = hddm.generate.gen_rand_data({'v':0, 'a':2, 't':.3},
+ size=100, subjs=5)
+
+ # Generate 2 conditions
+ >>> data, params = hddm.generate.gen_rand_data({'cond1': {'v':0, 'a':2, 't':.3},
+ 'cond2': {'v':1, 'a':2, 't':.3}})
+
+ :Notes:
+ Wrapper function for kabuki.generate.gen_rand_data. See
+ the help doc of that function for more options.
+
+ """
+
+ if params is None:
+ params = gen_rand_lba_params()
+
+ from numpy import inf
+
+ # set valid param ranges
+ bounds = {'b': (0, inf),
+ 'A': (0, inf),
+ 'v': (0, 1),
+ 's': (0, inf),
+ 't': (0, inf)
+ }
+
+ if 'share_noise' not in kwargs:
+ kwargs['share_noise'] = set(['b','A','t','s','v'])
+
+ # Create RT data
+ data, subj_params = kabuki.generate.gen_rand_data(lba_random, params,
+ bounds=bounds, **kwargs)
+ return data, subj_params
+
class HLBA(AccumulatorModel):
def __init__(self, data, **kwargs):
self.informative = kwargs.pop('informative', True)
self.std_depends = kwargs.get('std_depends', False)
self.slice_widths = {'b': 1, 'b_std': .5,
'A':1, 'A_std': .5,
- 'v': 1., 'v_std': .5, 'v_certainty': 10,
+ 'v': 1., 'v_std': .5, 'v_certainty': 5,
+ 't': 0.05, 't_std': .1,
+ 'p_outlier':1.,
+ 's': .2, 's_std': .05}
+ self.emcee_dispersions = {'b': 1, 'b_std': .5,
+ 'A':.5, 'A_std': .5,
+ 'v': 1., 'v_std': .5, 'v_certainty': 2,
't': 0.05, 't_std': .1,
'p_outlier':1.,
's': .2, 's_std': .05}
self.p_outlier = kwargs.pop('p_outlier', 0.)
+ self.fix_A = kwargs.pop('fix_A', False)
+
if self.p_outlier is True:
self.include = ['p_outlier']
else:
@@ -130,8 +284,9 @@ def _create_knodes_informative(self):
knodes = OrderedDict()
knodes.update(self._create_family_gamma_gamma_hnormal('t', g_mean=.4, g_std=1., value=0.001, std_std=.5, std_value=0.2))
knodes.update(self._create_family_gamma_gamma_hnormal('b', g_mean=1.5, g_std=.75, std_std=2, std_value=0.1, value=1.5))
- knodes.update(self._create_family_gamma_gamma_hnormal('A', g_mean=.5, g_std=1, std_std=2, std_value=0.1, value=.2))
- knodes['s_bottom'] = Knode(pm.HalfNormal, 's', tau=0.3**-2, value=0.1, depends=self.depends['s'])
+ if self.fix_A is False:
+ knodes.update(self._create_family_gamma_gamma_hnormal('A', g_mean=.5, g_std=1, std_std=2, std_value=0.1, value=.2))
+ knodes['s_bottom'] = Knode(pm.HalfNormal, 's', tau=0.3**-2, value=1., depends=self.depends['s'])
#knodes.update(self._create_family_gamma_gamma_hnormal('s', g_mean=1, g_std=2, std_std=2, value=1.))
knodes.update(self._create_family_beta('v', value=.75, g_mean=.75, g_certainty=0.75**-2))
if 'p_outlier' in self.include:
@@ -145,7 +300,8 @@ def _create_knodes_noninformative(self):
"""
knodes = OrderedDict()
knodes.update(self._create_family_trunc_normal('t', lower=0, upper=1, value=.001))
- knodes.update(self._create_family_trunc_normal('A', lower=1e-3, upper=10, value=.2))
+ if self.fix_A is False:
+ knodes.update(self._create_family_trunc_normal('A', lower=1e-3, upper=10, value=.2))
knodes.update(self._create_family_trunc_normal('b', lower=1e-3, upper=10, value=1.5))
knodes['s_bottom'] = Knode(pm.Uniform, 's', lower=1e-6, upper=3, value=0.1, depends=self.depends['s'])
#knodes.update(self._create_family_trunc_normal('s', lower=0, upper=10, value=1.))
@@ -159,7 +315,7 @@ def _create_lba_knode(self, knodes):
lba_parents = OrderedDict()
lba_parents['t'] = knodes['t_bottom']
lba_parents['v'] = knodes['v_bottom']
- lba_parents['A'] = knodes['A_bottom']
+ lba_parents['A'] = knodes['A_bottom'] if self.fix_A is False else self.fix_A
lba_parents['b'] = knodes['b_bottom']
lba_parents['s'] = knodes['s_bottom']
lba_parents['p_outlier'] = knodes['p_outlier_bottom'] if 'p_outlier' in self.include else self.p_outlier
@@ -178,5 +334,5 @@ def create_knodes(self):
def plot_posterior_predictive(self, *args, **kwargs):
if 'value_range' not in kwargs:
- kwargs['value_range'] = np.linspace(-1.5, 1.5, 100)
+ kwargs['value_range'] = np.linspace(-5, 5, 100)
kabuki.analyze.plot_posterior_predictive(self, *args, **kwargs)
View
2  hddm/tests/test_models.py
@@ -62,7 +62,7 @@ def test_HLBA(self):
params = hddm.generate.gen_rand_params()
data, params_true = hddm.generate.gen_rand_data(params, size=10, subjs=10)
model = hddm.models.HLBA(data)
- model.find_starting_values()
+ #model.find_starting_values()
model.sample(self.iter, burn=self.burn)
def test_HDDM(self):
View
2  src/cdfdif_wrapper.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.19.1 on Mon Oct 7 17:45:11 2013 */
+/* Generated by Cython 0.19.1 on Mon Nov 4 10:08:09 2013 */
#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
View
885 src/lba.c
@@ -1,6 +1,18 @@
-/* Generated by Cython 0.18 on Wed Oct 9 11:02:08 2013 */
+/* Generated by Cython 0.19.1 on Mon Nov 4 10:08:20 2013 */
#define PY_SSIZE_T_CLEAN
+#ifndef CYTHON_USE_PYLONG_INTERNALS
+#ifdef PYLONG_BITS_IN_DIGIT
+#define CYTHON_USE_PYLONG_INTERNALS 0
+#else
+#include "pyconfig.h"
+#ifdef PYLONG_BITS_IN_DIGIT
+#define CYTHON_USE_PYLONG_INTERNALS 1
+#else
+#define CYTHON_USE_PYLONG_INTERNALS 0
+#endif
+#endif
+#endif
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
@@ -116,6 +128,9 @@
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
+#if PY_VERSION_HEX < 0x02060000
+ #define Py_TPFLAGS_HAVE_VERSION_TAG 0
+#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
@@ -155,6 +170,14 @@
#define PyBytes_Concat PyString_Concat
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
#endif
+#if PY_MAJOR_VERSION >= 3
+ #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
+ #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
+#else
+ #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
+ PyString_Check(obj) || PyUnicode_Check(obj))
+ #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type)
+#endif
#if PY_VERSION_HEX < 0x02060000
#define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
#define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
@@ -227,6 +250,40 @@
#define __Pyx_NAMESTR(n) (n)
#define __Pyx_DOCSTR(n) (n)
#endif
+#ifndef CYTHON_INLINE
+ #if defined(__GNUC__)
+ #define CYTHON_INLINE __inline__
+ #elif defined(_MSC_VER)
+ #define CYTHON_INLINE __inline
+ #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+ #define CYTHON_INLINE inline
+ #else
+ #define CYTHON_INLINE
+ #endif
+#endif
+#ifndef CYTHON_RESTRICT
+ #if defined(__GNUC__)
+ #define CYTHON_RESTRICT __restrict__
+ #elif defined(_MSC_VER)
+ #define CYTHON_RESTRICT __restrict
+ #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+ #define CYTHON_RESTRICT restrict
+ #else
+ #define CYTHON_RESTRICT
+ #endif
+#endif
+#ifdef NAN
+#define __PYX_NAN() ((float) NAN)
+#else
+static CYTHON_INLINE float __PYX_NAN() {
+ /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
+ a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
+ a quiet NaN. */
+ float value;
+ memset(&value, 0xFF, sizeof(value));
+ return value;
+}
+#endif
#if PY_MAJOR_VERSION >= 3
@@ -265,17 +322,6 @@
#define CYTHON_WITHOUT_ASSERTIONS
#endif
-#ifndef CYTHON_INLINE
- #if defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
@@ -289,10 +335,44 @@
# define CYTHON_UNUSED
# endif
#endif
-typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
-
-#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
-#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s))
+typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
+ const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
+
+#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
+#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
+#define __PYX_DEFAULT_STRING_ENCODING ""
+#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
+#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
+#define __Pyx_PyBytes_FromString PyBytes_FromString
+#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*);
+#if PY_MAJOR_VERSION < 3
+ #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
+ #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#else
+ #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
+ #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
+#endif
+#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s)
+#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s)
+#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s)
+#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s)
+#if PY_MAJOR_VERSION < 3
+static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
+{
+ const Py_UNICODE *u_end = u;
+ while (*u_end++) ;
+ return u_end - u - 1;
+}
+#else
+#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
+#endif
+#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
+#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
+#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
@@ -306,6 +386,78 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+static int __Pyx_sys_getdefaultencoding_not_ascii;
+static int __Pyx_init_sys_getdefaultencoding_params() {
+ PyObject* sys = NULL;
+ PyObject* default_encoding = NULL;
+ PyObject* ascii_chars_u = NULL;
+ PyObject* ascii_chars_b = NULL;
+ sys = PyImport_ImportModule("sys");
+ if (sys == NULL) goto bad;
+ default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
+ if (default_encoding == NULL) goto bad;
+ if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) {
+ __Pyx_sys_getdefaultencoding_not_ascii = 0;
+ } else {
+ const char* default_encoding_c = PyBytes_AS_STRING(default_encoding);
+ char ascii_chars[128];
+ int c;
+ for (c = 0; c < 128; c++) {
+ ascii_chars[c] = c;
+ }
+ __Pyx_sys_getdefaultencoding_not_ascii = 1;
+ ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
+ if (ascii_chars_u == NULL) goto bad;
+ ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
+ if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
+ PyErr_Format(
+ PyExc_ValueError,
+ "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.",
+ default_encoding_c);
+ goto bad;
+ }
+ }
+ Py_XDECREF(sys);
+ Py_XDECREF(default_encoding);
+ Py_XDECREF(ascii_chars_u);
+ Py_XDECREF(ascii_chars_b);
+ return 0;
+bad:
+ Py_XDECREF(sys);
+ Py_XDECREF(default_encoding);
+ Py_XDECREF(ascii_chars_u);
+ Py_XDECREF(ascii_chars_b);
+ return -1;
+}
+#endif
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
+#else
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+static char* __PYX_DEFAULT_STRING_ENCODING;
+static int __Pyx_init_sys_getdefaultencoding_params() {
+ PyObject* sys = NULL;
+ PyObject* default_encoding = NULL;
+ char* default_encoding_c;
+ sys = PyImport_ImportModule("sys");
+ if (sys == NULL) goto bad;
+ default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
+ if (default_encoding == NULL) goto bad;
+ default_encoding_c = PyBytes_AS_STRING(default_encoding);
+ __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
+ strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
+ Py_DECREF(sys);
+ Py_DECREF(default_encoding);
+ return 0;
+bad:
+ Py_XDECREF(sys);
+ Py_XDECREF(default_encoding);
+ return -1;
+}
+#endif
+#endif
#ifdef __GNUC__
@@ -321,8 +473,9 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
-
+
static PyObject *__pyx_m;
+static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
@@ -703,7 +856,22 @@ typedef npy_cdouble __pyx_t_5numpy_complex_t;
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
+ PyTypeObject* tp = Py_TYPE(obj);
+ if (likely(tp->tp_getattro))
+ return tp->tp_getattro(obj, attr_name);
+#if PY_MAJOR_VERSION < 3
+ if (likely(tp->tp_getattr))
+ return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
+#endif
+ return PyObject_GetAttr(obj, attr_name);
+}
+#else
+#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
+#endif
+
+static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
@@ -721,6 +889,8 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* o
__Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
+static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/
+
#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
@@ -1024,9 +1194,12 @@ static char __pyx_k__sum_logp[] = "sum_logp";
static char __pyx_k__p_outlier[] = "p_outlier";
static char __pyx_k__w_outlier[] = "w_outlier";
static char __pyx_k__ValueError[] = "ValueError";
+static char __pyx_k____import__[] = "__import__";
static char __pyx_k__wp_outlier[] = "wp_outlier";
static char __pyx_k__normalize_v[] = "normalize_v";
static char __pyx_k__RuntimeError[] = "RuntimeError";
+static char __pyx_k____pyx_getbuffer[] = "__pyx_getbuffer";
+static char __pyx_k____pyx_releasebuffer[] = "__pyx_releasebuffer";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_u_12;
static PyObject *__pyx_kp_s_16;
@@ -1039,7 +1212,10 @@ static PyObject *__pyx_n_s__DTYPE;
static PyObject *__pyx_n_s__Inf;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__ValueError;
+static PyObject *__pyx_n_s____import__;
static PyObject *__pyx_n_s____main__;
+static PyObject *__pyx_n_s____pyx_getbuffer;
+static PyObject *__pyx_n_s____pyx_releasebuffer;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__double;
@@ -1327,9 +1503,9 @@ static CYTHON_INLINE int __pyx_f_3lba_p_outlier_in_range(double __pyx_v_p_outlie
* return 1
* else:
*/
- __pyx_t_1 = (__pyx_v_p_outlier >= 0.0);
+ __pyx_t_1 = ((__pyx_v_p_outlier >= 0.0) != 0);
if (__pyx_t_1) {
- __pyx_t_2 = (__pyx_v_p_outlier <= 1.0);
+ __pyx_t_2 = ((__pyx_v_p_outlier <= 1.0) != 0);
__pyx_t_3 = __pyx_t_2;
} else {
__pyx_t_3 = __pyx_t_1;
@@ -1369,7 +1545,7 @@ static CYTHON_INLINE int __pyx_f_3lba_p_outlier_in_range(double __pyx_v_p_outlie
/* Python wrapper */
static PyObject *__pyx_pw_3lba_1lba_like(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_3lba_lba_like[] = "lba_like(ndarray value, double z, double a, double ter, double sv, double v0, double v1, int normalize_v=False, double p_outlier=0, double w_outlier=0)";
+static char __pyx_doc_3lba_lba_like[] = "lba_like(ndarray value, double z, double a, double ter, double sv, double v0, double v1, bool normalize_v=False, double p_outlier=0, double w_outlier=0)";
static PyMethodDef __pyx_mdef_3lba_1lba_like = {__Pyx_NAMESTR("lba_like"), (PyCFunction)__pyx_pw_3lba_1lba_like, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3lba_lba_like)};
static PyObject *__pyx_pw_3lba_1lba_like(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyArrayObject *__pyx_v_value = 0;
@@ -1382,6 +1558,9 @@ static PyObject *__pyx_pw_3lba_1lba_like(PyObject *__pyx_self, PyObject *__pyx_a
int __pyx_v_normalize_v;
double __pyx_v_p_outlier;
double __pyx_v_w_outlier;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lba_like (wrapper)", 0);
@@ -1610,7 +1789,7 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* if not p_outlier_in_range(p_outlier):
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!(__pyx_v_sv >= 0.0))) {
+ if (unlikely(!((__pyx_v_sv >= 0.0) != 0))) {
PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_1));
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
@@ -1623,7 +1802,7 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* return -np.inf
*
*/
- __pyx_t_1 = (!__pyx_f_3lba_p_outlier_in_range(__pyx_v_p_outlier));
+ __pyx_t_1 = ((!(__pyx_f_3lba_p_outlier_in_range(__pyx_v_p_outlier) != 0)) != 0);
if (__pyx_t_1) {
/* "lba.pyx":68
@@ -1634,9 +1813,9 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* if normalize_v == 1:
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyNumber_Negative(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -1656,7 +1835,7 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* v1 = 1 - v0
*
*/
- __pyx_t_1 = (__pyx_v_normalize_v == 1);
+ __pyx_t_1 = ((__pyx_v_normalize_v == 1) != 0);
if (__pyx_t_1) {
/* "lba.pyx":71
@@ -1678,7 +1857,7 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* #print "Starting point larger than threshold!"
* return -np.Inf
*/
- __pyx_t_1 = (__pyx_v_a <= __pyx_v_z);
+ __pyx_t_1 = ((__pyx_v_a <= __pyx_v_z) != 0);
if (__pyx_t_1) {
/* "lba.pyx":75
@@ -1689,9 +1868,9 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* #print "z: %f, a: %f, ter: %i, v: %f, sv: %f" % (z, a, ter, v[0], sv)
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__Inf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__Inf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyNumber_Negative(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -1732,7 +1911,7 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* p = 0
* elif value[i] > 0:
*/
- __pyx_t_1 = (__pyx_v_rt < 0.0);
+ __pyx_t_1 = ((__pyx_v_rt < 0.0) != 0);
if (__pyx_t_1) {
/* "lba.pyx":81
@@ -1751,16 +1930,16 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* p = 0
* elif value[i] > 0: # <<<<<<<<<<<<<<
* p = (1-fptcdf_single(rt, z, a, v1, sv)) * \
- * fptpdf_single(rt, z, a, v0, sv)
+ * fptpdf_single(rt, z, a, v0, sv)
*/
__pyx_t_7 = __pyx_v_i;
- __pyx_t_1 = ((*__Pyx_BufPtrStrided1d(__pyx_t_3lba_DTYPE_t *, __pyx_pybuffernd_value.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_value.diminfo[0].strides)) > 0.0);
+ __pyx_t_1 = (((*__Pyx_BufPtrStrided1d(__pyx_t_3lba_DTYPE_t *, __pyx_pybuffernd_value.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_value.diminfo[0].strides)) > 0.0) != 0);
if (__pyx_t_1) {
/* "lba.pyx":84
* elif value[i] > 0:
* p = (1-fptcdf_single(rt, z, a, v1, sv)) * \
- * fptpdf_single(rt, z, a, v0, sv) # <<<<<<<<<<<<<<
+ * fptpdf_single(rt, z, a, v0, sv) # <<<<<<<<<<<<<<
* elif value[i] < 0:
* p = (1-fptcdf_single(rt, z, a, v0, sv)) * \
*/
@@ -1770,19 +1949,19 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
/* "lba.pyx":85
* p = (1-fptcdf_single(rt, z, a, v1, sv)) * \
- * fptpdf_single(rt, z, a, v0, sv)
+ * fptpdf_single(rt, z, a, v0, sv)
* elif value[i] < 0: # <<<<<<<<<<<<<<
* p = (1-fptcdf_single(rt, z, a, v0, sv)) * \
- * fptpdf_single(rt, z, a, v1, sv)
+ * fptpdf_single(rt, z, a, v1, sv)
*/
__pyx_t_8 = __pyx_v_i;
- __pyx_t_1 = ((*__Pyx_BufPtrStrided1d(__pyx_t_3lba_DTYPE_t *, __pyx_pybuffernd_value.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_value.diminfo[0].strides)) < 0.0);
+ __pyx_t_1 = (((*__Pyx_BufPtrStrided1d(__pyx_t_3lba_DTYPE_t *, __pyx_pybuffernd_value.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_value.diminfo[0].strides)) < 0.0) != 0);
if (__pyx_t_1) {
/* "lba.pyx":87
* elif value[i] < 0:
* p = (1-fptcdf_single(rt, z, a, v0, sv)) * \
- * fptpdf_single(rt, z, a, v1, sv) # <<<<<<<<<<<<<<
+ * fptpdf_single(rt, z, a, v1, sv) # <<<<<<<<<<<<<<
*
* p = p * (1 - p_outlier) + wp_outlier
*/
@@ -1792,7 +1971,7 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
__pyx_L8:;
/* "lba.pyx":89
- * fptpdf_single(rt, z, a, v1, sv)
+ * fptpdf_single(rt, z, a, v1, sv)
*
* p = p * (1 - p_outlier) + wp_outlier # <<<<<<<<<<<<<<
* if p == 0:
@@ -1807,7 +1986,7 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* return -np.inf
*
*/
- __pyx_t_1 = (__pyx_v_p == 0.0);
+ __pyx_t_1 = ((__pyx_v_p == 0.0) != 0);
if (__pyx_t_1) {
/* "lba.pyx":91
@@ -1818,9 +1997,9 @@ static PyObject *__pyx_pf_3lba_lba_like(CYTHON_UNUSED PyObject *__pyx_self, PyAr
* sum_logp += log(p)
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyNumber_Negative(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -1932,7 +2111,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
*
* cdef int copy_shape, i, ndim
*/
- __pyx_t_1 = (__pyx_v_info == NULL);
+ __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
if (__pyx_t_1) {
__pyx_r = 0;
goto __pyx_L0;
@@ -1974,7 +2153,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* copy_shape = 1
* else:
*/
- __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
+ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
if (__pyx_t_1) {
/* "numpy.pxd":209
@@ -2007,7 +2186,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
* raise ValueError(u"ndarray is not C contiguous")
*/
- __pyx_t_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS);
+ __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
if (__pyx_t_1) {
/* "numpy.pxd":214
@@ -2017,7 +2196,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* raise ValueError(u"ndarray is not C contiguous")
*
*/
- __pyx_t_2 = (!PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS));
+ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0);
__pyx_t_3 = __pyx_t_2;
} else {
__pyx_t_3 = __pyx_t_1;
@@ -2047,7 +2226,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
* raise ValueError(u"ndarray is not Fortran contiguous")
*/
- __pyx_t_3 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS);
+ __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
if (__pyx_t_3) {
/* "numpy.pxd":218
@@ -2057,7 +2236,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* raise ValueError(u"ndarray is not Fortran contiguous")
*
*/
- __pyx_t_1 = (!PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS));
+ __pyx_t_1 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
__pyx_t_2 = __pyx_t_1;
} else {
__pyx_t_2 = __pyx_t_3;
@@ -2105,7 +2284,8 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* # Allocate new buffer for strides and shape info.
* # This is allocated as one block, strides first.
*/
- if (__pyx_v_copy_shape) {
+ __pyx_t_2 = (__pyx_v_copy_shape != 0);
+ if (__pyx_t_2) {
/* "numpy.pxd":226
* # Allocate new buffer for strides and shape info.
@@ -2203,7 +2383,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
*
* cdef int t
*/
- __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(__pyx_v_self));
+ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));
/* "numpy.pxd":239
*
@@ -2242,9 +2422,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* # do not call releasebuffer
* info.obj = None
*/
- __pyx_t_2 = (!__pyx_v_hasfields);
+ __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0);
if (__pyx_t_2) {
- __pyx_t_3 = (!__pyx_v_copy_shape);
+ __pyx_t_3 = ((!(__pyx_v_copy_shape != 0)) != 0);
__pyx_t_1 = __pyx_t_3;
} else {
__pyx_t_1 = __pyx_t_2;
@@ -2289,7 +2469,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* t = descr.type_num
* if ((descr.byteorder == c'>' and little_endian) or
*/
- __pyx_t_1 = (!__pyx_v_hasfields);
+ __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
if (__pyx_t_1) {
/* "numpy.pxd":254
@@ -2309,9 +2489,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* (descr.byteorder == c'<' and not little_endian)):
* raise ValueError(u"Non-native byte order not supported")
*/
- __pyx_t_1 = (__pyx_v_descr->byteorder == '>');
+ __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0);
if (__pyx_t_1) {
- __pyx_t_2 = __pyx_v_little_endian;
+ __pyx_t_2 = (__pyx_v_little_endian != 0);
} else {
__pyx_t_2 = __pyx_t_1;
}
@@ -2324,9 +2504,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* raise ValueError(u"Non-native byte order not supported")
* if t == NPY_BYTE: f = "b"
*/
- __pyx_t_1 = (__pyx_v_descr->byteorder == '<');
+ __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0);
if (__pyx_t_1) {
- __pyx_t_3 = (!__pyx_v_little_endian);
+ __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0);
__pyx_t_7 = __pyx_t_3;
} else {
__pyx_t_7 = __pyx_t_1;
@@ -2353,227 +2533,202 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
}
__pyx_L12:;
- /* "numpy.pxd":258
+ /* "numpy.pxd":274
+ * elif t == NPY_CDOUBLE: f = "Zd"
+ * elif t == NPY_CLONGDOUBLE: f = "Zg"
+ * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<<
+ * else:
+ * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
+ */
+ switch (__pyx_v_t) {
+
+ /* "numpy.pxd":258
* (descr.byteorder == c'<' and not little_endian)):
* raise ValueError(u"Non-native byte order not supported")
* if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<<
* elif t == NPY_UBYTE: f = "B"
* elif t == NPY_SHORT: f = "h"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_BYTE);
- if (__pyx_t_1) {
+ case NPY_BYTE:
__pyx_v_f = __pyx_k__b;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":259
+ /* "numpy.pxd":259
* raise ValueError(u"Non-native byte order not supported")
* if t == NPY_BYTE: f = "b"
* elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<<
* elif t == NPY_SHORT: f = "h"
* elif t == NPY_USHORT: f = "H"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_UBYTE);
- if (__pyx_t_1) {
+ case NPY_UBYTE:
__pyx_v_f = __pyx_k__B;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":260
+ /* "numpy.pxd":260
* if t == NPY_BYTE: f = "b"
* elif t == NPY_UBYTE: f = "B"
* elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<<
* elif t == NPY_USHORT: f = "H"
* elif t == NPY_INT: f = "i"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_SHORT);
- if (__pyx_t_1) {
+ case NPY_SHORT:
__pyx_v_f = __pyx_k__h;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":261
+ /* "numpy.pxd":261
* elif t == NPY_UBYTE: f = "B"
* elif t == NPY_SHORT: f = "h"
* elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<<
* elif t == NPY_INT: f = "i"
* elif t == NPY_UINT: f = "I"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_USHORT);
- if (__pyx_t_1) {
+ case NPY_USHORT:
__pyx_v_f = __pyx_k__H;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":262
+ /* "numpy.pxd":262
* elif t == NPY_SHORT: f = "h"
* elif t == NPY_USHORT: f = "H"
* elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<<
* elif t == NPY_UINT: f = "I"
* elif t == NPY_LONG: f = "l"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_INT);
- if (__pyx_t_1) {
+ case NPY_INT:
__pyx_v_f = __pyx_k__i;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":263
+ /* "numpy.pxd":263
* elif t == NPY_USHORT: f = "H"
* elif t == NPY_INT: f = "i"
* elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<<
* elif t == NPY_LONG: f = "l"
* elif t == NPY_ULONG: f = "L"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_UINT);
- if (__pyx_t_1) {
+ case NPY_UINT:
__pyx_v_f = __pyx_k__I;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":264
+ /* "numpy.pxd":264
* elif t == NPY_INT: f = "i"
* elif t == NPY_UINT: f = "I"
* elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<<
* elif t == NPY_ULONG: f = "L"
* elif t == NPY_LONGLONG: f = "q"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_LONG);
- if (__pyx_t_1) {
+ case NPY_LONG:
__pyx_v_f = __pyx_k__l;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":265
+ /* "numpy.pxd":265
* elif t == NPY_UINT: f = "I"
* elif t == NPY_LONG: f = "l"
* elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<<
* elif t == NPY_LONGLONG: f = "q"
* elif t == NPY_ULONGLONG: f = "Q"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_ULONG);
- if (__pyx_t_1) {
+ case NPY_ULONG:
__pyx_v_f = __pyx_k__L;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":266
+ /* "numpy.pxd":266
* elif t == NPY_LONG: f = "l"
* elif t == NPY_ULONG: f = "L"
* elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<<
* elif t == NPY_ULONGLONG: f = "Q"
* elif t == NPY_FLOAT: f = "f"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_LONGLONG);
- if (__pyx_t_1) {
+ case NPY_LONGLONG:
__pyx_v_f = __pyx_k__q;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":267
+ /* "numpy.pxd":267
* elif t == NPY_ULONG: f = "L"
* elif t == NPY_LONGLONG: f = "q"
* elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<<
* elif t == NPY_FLOAT: f = "f"
* elif t == NPY_DOUBLE: f = "d"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_ULONGLONG);
- if (__pyx_t_1) {
+ case NPY_ULONGLONG:
__pyx_v_f = __pyx_k__Q;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":268
+ /* "numpy.pxd":268
* elif t == NPY_LONGLONG: f = "q"
* elif t == NPY_ULONGLONG: f = "Q"
* elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<<
* elif t == NPY_DOUBLE: f = "d"
* elif t == NPY_LONGDOUBLE: f = "g"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_FLOAT);
- if (__pyx_t_1) {
+ case NPY_FLOAT:
__pyx_v_f = __pyx_k__f;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":269
+ /* "numpy.pxd":269
* elif t == NPY_ULONGLONG: f = "Q"
* elif t == NPY_FLOAT: f = "f"
* elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<<
* elif t == NPY_LONGDOUBLE: f = "g"
* elif t == NPY_CFLOAT: f = "Zf"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_DOUBLE);
- if (__pyx_t_1) {
+ case NPY_DOUBLE:
__pyx_v_f = __pyx_k__d;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":270
+ /* "numpy.pxd":270
* elif t == NPY_FLOAT: f = "f"
* elif t == NPY_DOUBLE: f = "d"
* elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<<
* elif t == NPY_CFLOAT: f = "Zf"
* elif t == NPY_CDOUBLE: f = "Zd"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_LONGDOUBLE);
- if (__pyx_t_1) {
+ case NPY_LONGDOUBLE:
__pyx_v_f = __pyx_k__g;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":271
+ /* "numpy.pxd":271
* elif t == NPY_DOUBLE: f = "d"
* elif t == NPY_LONGDOUBLE: f = "g"
* elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<<
* elif t == NPY_CDOUBLE: f = "Zd"
* elif t == NPY_CLONGDOUBLE: f = "Zg"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_CFLOAT);
- if (__pyx_t_1) {
+ case NPY_CFLOAT:
__pyx_v_f = __pyx_k__Zf;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":272
+ /* "numpy.pxd":272
* elif t == NPY_LONGDOUBLE: f = "g"
* elif t == NPY_CFLOAT: f = "Zf"
* elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<<
* elif t == NPY_CLONGDOUBLE: f = "Zg"
* elif t == NPY_OBJECT: f = "O"
*/
- __pyx_t_1 = (__pyx_v_t == NPY_CDOUBLE);
- if (__pyx_t_1) {
+ case NPY_CDOUBLE:
__pyx_v_f = __pyx_k__Zd;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":273
+ /* "numpy.pxd":273
* elif t == NPY_CFLOAT: f = "Zf"
* elif t == NPY_CDOUBLE: f = "Zd"
* elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<<
* elif t == NPY_OBJECT: f = "O"
* else:
*/
- __pyx_t_1 = (__pyx_v_t == NPY_CLONGDOUBLE);
- if (__pyx_t_1) {
+ case NPY_CLONGDOUBLE:
__pyx_v_f = __pyx_k__Zg;
- goto __pyx_L13;
- }
+ break;
- /* "numpy.pxd":274
+ /* "numpy.pxd":274
* elif t == NPY_CDOUBLE: f = "Zd"
* elif t == NPY_CLONGDOUBLE: f = "Zg"
* elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<<
* else:
* raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
*/
- __pyx_t_1 = (__pyx_v_t == NPY_OBJECT);
- if (__pyx_t_1) {
+ case NPY_OBJECT:
__pyx_v_f = __pyx_k__O;
- goto __pyx_L13;
- }
- /*else*/ {
+ break;
+ default:
/* "numpy.pxd":276
* elif t == NPY_OBJECT: f = "O"
@@ -2598,8 +2753,8 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
__Pyx_Raise(__pyx_t_8, 0, 0, 0);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ break;
}
- __pyx_L13:;
/* "numpy.pxd":277
* else:
@@ -2723,7 +2878,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s
* stdlib.free(info.format)
* if sizeof(npy_intp) != sizeof(Py_ssize_t):
*/
- __pyx_t_1 = PyArray_HASFIELDS(__pyx_v_self);
+ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
if (__pyx_t_1) {
/* "numpy.pxd":290
@@ -2745,7 +2900,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s
* stdlib.free(info.strides)
* # info.shape was stored after info.strides in the same block
*/
- __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
+ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
if (__pyx_t_1) {
/* "numpy.pxd":292
@@ -3176,9 +3331,9 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
* (child.byteorder == c'<' and not little_endian)):
* raise ValueError(u"Non-native byte order not supported")
*/
- __pyx_t_7 = (__pyx_v_child->byteorder == '>');
+ __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
if (__pyx_t_7) {
- __pyx_t_8 = __pyx_v_little_endian;
+ __pyx_t_8 = (__pyx_v_little_endian != 0);
} else {
__pyx_t_8 = __pyx_t_7;
}
@@ -3191,9 +3346,9 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
* raise ValueError(u"Non-native byte order not supported")
* # One could encode it in the format string and have Cython
*/
- __pyx_t_7 = (__pyx_v_child->byteorder == '<');
+ __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
if (__pyx_t_7) {
- __pyx_t_9 = (!__pyx_v_little_endian);
+ __pyx_t_9 = ((!(__pyx_v_little_endian != 0)) != 0);
__pyx_t_10 = __pyx_t_9;
} else {
__pyx_t_10 = __pyx_t_7;
@@ -3282,7 +3437,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
* t = child.type_num
* if end - f < 5:
*/
- __pyx_t_7 = (!PyDataType_HASFIELDS(__pyx_v_child));
+ __pyx_t_7 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
if (__pyx_t_7) {
/* "numpy.pxd":821
@@ -3305,7 +3460,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
* raise RuntimeError(u"Format string allocated too short.")
*
*/
- __pyx_t_7 = ((__pyx_v_end - __pyx_v_f) < 5);
+ __pyx_t_7 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
if (__pyx_t_7) {
/* "numpy.pxd":823
@@ -3727,6 +3882,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
PyObject *__pyx_v_baseptr;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
+ int __pyx_t_2;
__Pyx_RefNannySetupContext("set_array_base", 0);
/* "numpy.pxd":967
@@ -3737,7 +3893,8 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
* else:
*/
__pyx_t_1 = (__pyx_v_base == Py_None);
- if (__pyx_t_1) {
+ __pyx_t_2 = (__pyx_t_1 != 0);
+ if (__pyx_t_2) {
/* "numpy.pxd":968
* cdef PyObject* baseptr
@@ -3813,7 +3970,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py
* return None
* else:
*/
- __pyx_t_1 = (__pyx_v_arr->base == NULL);
+ __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
if (__pyx_t_1) {
/* "numpy.pxd":977
@@ -3885,7 +4042,10 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s__Inf, __pyx_k__Inf, sizeof(__pyx_k__Inf), 0, 0, 1, 1},
{&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
{&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
+ {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1},
{&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
+ {&__pyx_n_s____pyx_getbuffer, __pyx_k____pyx_getbuffer, sizeof(__pyx_k____pyx_getbuffer), 0, 0, 1, 1},
+ {&__pyx_n_s____pyx_releasebuffer, __pyx_k____pyx_releasebuffer, sizeof(__pyx_k____pyx_releasebuffer), 0, 0, 1, 1},
{&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
{&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
{&__pyx_n_s__double, __pyx_k__double, sizeof(__pyx_k__double), 0, 0, 1, 1},
@@ -3913,9 +4073,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
__pyx_L1_error:;
return -1;
@@ -4027,6 +4187,9 @@ PyMODINIT_FUNC PyInit_lba(void)
{
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannyDeclarations
#if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
@@ -4064,6 +4227,8 @@ PyMODINIT_FUNC PyInit_lba(void)
__pyx_m = PyModule_Create(&__pyx_moduledef);
#endif
if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ Py_INCREF(__pyx_d);
#if PY_MAJOR_VERSION >= 3
{
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -4079,6 +4244,9 @@ PyMODINIT_FUNC PyInit_lba(void)
if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
/*--- Initialize various global constants etc. ---*/
if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
+ if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
if (__pyx_module_is_main_lba) {
if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
}
@@ -4116,7 +4284,7 @@ PyMODINIT_FUNC PyInit_lba(void)
*/
__pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_d, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "lba.pyx":13
@@ -4126,12 +4294,12 @@ PyMODINIT_FUNC PyInit_lba(void)
* ctypedef np.double_t DTYPE_t
*
*/
- __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__double); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__double); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_d, __pyx_n_s__DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "lba.pyx":57
@@ -4143,7 +4311,7 @@ PyMODINIT_FUNC PyInit_lba(void)
*/
__pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3lba_1lba_like, NULL, __pyx_n_s__lba); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__lba_like, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_d, __pyx_n_s__lba_like, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "lba.pyx":1
@@ -4153,7 +4321,7 @@ PyMODINIT_FUNC PyInit_lba(void)
*/
__pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
/* "numpy.pxd":975
@@ -4199,17 +4367,15 @@ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
}
#endif /* CYTHON_REFNANNY */
-static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
- PyObject *result;
- result = PyObject_GetAttr(dict, name);
- if (!result) {
- if (dict != __pyx_b) {
- PyErr_Clear();
- result = PyObject_GetAttr(__pyx_b, name);
- }
- if (!result) {
- PyErr_SetObject(PyExc_NameError, name);
- }
+static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
+ PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
+ if (unlikely(!result)) {
+ PyErr_Format(PyExc_NameError,
+#if PY_MAJOR_VERSION >= 3
+ "name '%U' is not defined", name);
+#else
+ "name '%s' is not defined", PyString_AS_STRING(name));
+#endif
}
return result;
}
@@ -4916,6 +5082,23 @@ static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
__Pyx_ReleaseBuffer(info);
}
+static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
+ PyObject *result;
+#if CYTHON_COMPILING_IN_CPYTHON
+ result = PyDict_GetItem(__pyx_d, name);
+ if (result) {
+ Py_INCREF(result);
+ } else {
+#else
+ result = PyObject_GetItem(__pyx_d, name);
+ if (!result) {
+ PyErr_Clear();
+#endif
+ result = __Pyx_GetBuiltinName(name);
+ }
+ return result;
+}
+
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
@@ -4985,24 +5168,23 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
}
value = type;
#if PY_VERSION_HEX < 0x02050000
- if (PyInstance_Check(type)) {
- type = (PyObject*) ((PyInstanceObject*)type)->in_class;
- Py_INCREF(type);
- }
- else {
- type = 0;
- PyErr_SetString(PyExc_TypeError,
- "raise: exception must be an old-style class or instance");
- goto raise_error;
- }
- #else
- type = (PyObject*) Py_TYPE(type);
+ if (PyInstance_Check(type)) {
+ type = (PyObject*) ((PyInstanceObject*)type)->in_class;
Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
+ } else {
+ type = 0;
+ PyErr_SetString(PyExc_TypeError,
+ "raise: exception must be an old-style class or instance");
+ goto raise_error;
+ }
+ #else
+ type = (PyObject*) Py_TYPE(type);
+ Py_INCREF(type);
+ if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+ PyErr_SetString(PyExc_TypeError,
+ "raise: exception class must be a subclass of BaseException");
+ goto raise_error;
+ }
#endif
}
__Pyx_ErrRestore(type, value, tb);
@@ -5040,8 +5222,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject
else if (PyTuple_Check(value)) {
Py_INCREF(value);
args = value;
- }
- else
+ } else
args = PyTuple_Pack(1, value);
if (!args)
goto bad;
@@ -5062,18 +5243,22 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject
"raise: exception class must be a subclass of BaseException");
goto bad;
}
+#if PY_VERSION_HEX >= 0x03030000
+ if (cause) {
+#else
if (cause && cause != Py_None) {
+#endif
PyObject *fixed_cause;
- if (PyExceptionClass_Check(cause)) {
+ if (cause == Py_None) {
+ fixed_cause = NULL;
+ } else if (PyExceptionClass_Check(cause)) {
fixed_cause = PyObject_CallObject(cause, NULL);
if (fixed_cause == NULL)
goto bad;
- }
- else if (PyExceptionInstance_Check(cause)) {
+ } else if (PyExceptionInstance_Check(cause)) {
fixed_cause = cause;
Py_INCREF(fixed_cause);
- }
- else {
+ } else {
PyErr_SetString(PyExc_TypeError,
"exception causes must derive from "
"BaseException");
@@ -5171,27 +5356,23 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
- CYTHON_UNUSED PyObject *getbuffer_cobj;
#if PY_VERSION_HEX >= 0x02060000
if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
#endif
if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
#if PY_VERSION_HEX < 0x02060000
- if (obj->ob_type->tp_dict &&
- (getbuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict,
- "__pyx_getbuffer"))) {
- getbufferproc func;
- #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0)
- func = (getbufferproc) PyCapsule_GetPointer(getbuffer_cobj, "getbuffer(obj, view, flags)");
- #else
- func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj);
- #endif
- Py_DECREF(getbuffer_cobj);
- if (!func)
- goto fail;
- return func(obj, view, flags);
- } else {
- PyErr_Clear();
+ if (obj->ob_type->tp_dict) {
+ PyObject *getbuffer_cobj = PyObject_GetItem(
+ obj->ob_type->tp_dict, __pyx_n_s____pyx_getbuffer);
+ if (getbuffer_cobj) {
+ getbufferproc func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj);
+ Py_DECREF(getbuffer_cobj);
+ if (!func)
+ goto fail;
+ return func(obj, view, flags);
+ } else {
+ PyErr_Clear();
+ }
}
#endif
PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
@@ -5202,7 +5383,6 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
PyObject *obj = view->obj;
- CYTHON_UNUSED PyObject *releasebuffer_cobj;
if (!obj) return;
#if PY_VERSION_HEX >= 0x02060000
if (PyObject_CheckBuffer(obj)) {
@@ -5212,22 +5392,19 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) {
#endif
if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; }
#if PY_VERSION_HEX < 0x02060000
- if (obj->ob_type->tp_dict &&
- (releasebuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict,
- "__pyx_releasebuffer"))) {
- releasebufferproc func;
- #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0)
- func = (releasebufferproc) PyCapsule_GetPointer(releasebuffer_cobj, "releasebuffer(obj, view)");
- #else
- func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj);
- #endif
- Py_DECREF(releasebuffer_cobj);
- if (!func)
- goto fail;
- func(obj, view);
- return;
- } else {
- PyErr_Clear();
+ if (obj->ob_type->tp_dict) {
+ PyObject *releasebuffer_cobj = PyObject_GetItem(
+ obj->ob_type->tp_dict, __pyx_n_s____pyx_releasebuffer);
+ if (releasebuffer_cobj) {
+ releasebufferproc func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj);
+ Py_DECREF(releasebuffer_cobj);
+ if (!func)
+ goto fail;
+ func(obj, view);
+ return;
+ } else {
+ PyErr_Clear();
+ }
}
#endif
goto nofail;
@@ -5242,15 +5419,15 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) {
#endif /* PY_MAJOR_VERSION < 3 */
- static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
+ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
PyObject *empty_list = 0;
PyObject *module = 0;
PyObject *global_dict = 0;
PyObject *empty_dict = 0;
PyObject *list;
#if PY_VERSION_HEX < 0x03030000
- PyObject *py_import = 0;
- py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
+ PyObject *py_import;
+ py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__);
if (!py_import)
goto bad;
#endif
@@ -5754,10 +5931,15 @@ static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
return (int)__Pyx_PyInt_AsLong(x);
}
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+#include "longintrepr.h"
+#endif
+#endif
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
@@ -5770,6 +5952,16 @@ static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(unsigned long)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
if (unlikely(Py_SIZE(x) < 0)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to unsigned long");
@@ -5777,6 +5969,17 @@ static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
}
return (unsigned long)PyLong_AsUnsignedLong(x);
} else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(unsigned long)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0];
+ case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
return (unsigned long)PyLong_AsLong(x);
}
} else {
@@ -5789,10 +5992,15 @@ static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
}
}
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+#include "longintrepr.h"
+#endif
+#endif
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
@@ -5805,6 +6013,16 @@ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObje
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
if (unlikely(Py_SIZE(x) < 0)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to unsigned PY_LONG_LONG");
@@ -5812,6 +6030,17 @@ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObje
}
return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
} else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
}
} else {
@@ -5824,10 +6053,15 @@ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObje
}
}
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+#include "longintrepr.h"
+#endif
+#endif
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
const long neg_one = (long)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
@@ -5840,6 +6074,16 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(long)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return (long) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
if (unlikely(Py_SIZE(x) < 0)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to long");
@@ -5847,6 +6091,17 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
}
return (long)PyLong_AsUnsignedLong(x);
} else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(long)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return +(long) ((PyLongObject*)x)->ob_digit[0];
+ case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
return (long)PyLong_AsLong(x);
}
} else {
@@ -5859,10 +6114,15 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
}
}
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+#include "longintrepr.h"
+#endif
+#endif
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
@@ -5875,6 +6135,16 @@ static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(PY_LONG_LONG)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
if (unlikely(Py_SIZE(x) < 0)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to PY_LONG_LONG");
@@ -5882,6 +6152,17 @@ static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
}
return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
} else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(PY_LONG_LONG)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
return (PY_LONG_LONG)PyLong_AsLongLong(x);
}
} else {
@@ -5894,10 +6175,15 @@ static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
}
}
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+#include "longintrepr.h"
+#endif
+#endif
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
const signed long neg_one = (signed long)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
@@ -5910,6 +6196,16 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(signed long)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
if (unlikely(Py_SIZE(x) < 0)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to signed long");
@@ -5917,6 +6213,17 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
}
return (signed long)PyLong_AsUnsignedLong(x);
} else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(signed long)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0];
+ case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
return (signed long)PyLong_AsLong(x);
}
} else {
@@ -5929,10 +6236,15 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
}
}
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+#include "longintrepr.h"
+#endif
+#endif
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
@@ -5945,6 +6257,16 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject*
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
if (unlikely(Py_SIZE(x) < 0)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to signed PY_LONG_LONG");
@@ -5952,6 +6274,17 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject*
}
return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
} else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+#if CYTHON_USE_PYLONG_INTERNALS
+ if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) {
+ switch (Py_SIZE(x)) {
+ case 0: return 0;
+ case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
+ }
+ }
+#endif
+#endif
return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
}
} else {
@@ -6260,6 +6593,65 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
return 0;
}
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) {
+ return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
+ Py_ssize_t ignore;
+ return __Pyx_PyObject_AsStringAndSize(o, &ignore);
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+ if (
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+ __Pyx_sys_getdefaultencoding_not_ascii &&
+#endif
+ PyUnicode_Check(o)) {
+#if PY_VERSION_HEX < 0x03030000
+ char* defenc_c;
+ PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
+ if (!defenc) return NULL;
+ defenc_c = PyBytes_AS_STRING(defenc);
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+ {
+ char* end = defenc_c + PyBytes_GET_SIZE(defenc);
+ char* c;
+ for (c = defenc_c; c < end; c++) {
+ if ((unsigned char) (*c) >= 128) {
+ PyUnicode_AsASCIIString(o);
+ return NULL;
+ }
+ }
+ }
+#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
+ *length = PyBytes_GET_SIZE(defenc);
+ return defenc_c;
+#else /* PY_VERSION_HEX < 0x03030000 */
+ if (PyUnicode_READY(o) == -1) return NULL;
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+ if (PyUnicode_IS_ASCII(o)) {
+ *length = PyUnicode_GET_DATA_SIZE(o);
+ return PyUnicode_AsUTF8(o);
+ } else {
+ PyUnicode_AsASCIIString(o);
+ return NULL;
+ }
+#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
+ return PyUnicode_AsUTF8AndSize(o, length);
+#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
+#endif /* PY_VERSION_HEX < 0x03030000 */
+ } else
+#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
+ {
+ char* result;
+ int r = PyBytes_AsStringAndSize(o, &result, length);
+ if (r < 0) {
+ return NULL;
+ } else {
+ return result;
+ }
+ }
+}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
int is_true = x == Py_True;
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
@@ -6269,14 +6661,14 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
PyNumberMethods *m;
const char *name = NULL;
PyObject *res = NULL;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (PyInt_Check(x) || PyLong_Check(x))
#else
if (PyLong_Check(x))
#endif
return Py_INCREF(x), x;
m = Py_TYPE(x)->tp_as_number;
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (m && m->nb_int) {
name = "int";
res = PyNumber_Int(x);
@@ -6292,7 +6684,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
}
#endif
if (res) {
-#if PY_VERSION_HEX < 0x03000000
+#if PY_MAJOR_VERSION < 3
if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
if (!PyLong_Check(res)) {
@@ -6333,11 +6725,10 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
}
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
- if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
- return (size_t)-1;
- } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to size_t");
+ if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
+ if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred())
+ PyErr_SetString(PyExc_OverflowError,
+ "value too large to convert to size_t");
return (size_t)-1;
}
return (size_t)val;
View
44 src/wfpt.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.19.1 on Mon Oct 7 17:45:20 2013 */
+/* Generated by Cython 0.19.1 on Mon Nov 4 10:08:20 2013 */
#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
@@ -3984,7 +3984,7 @@ static PyObject *__pyx_pf_4wfpt_2pdf_array(CYTHON_UNUSED PyObject *__pyx_self, P
if (__pyx_t_9 > 0)
{
#ifdef _OPENMP
- #pragma omp parallel private(__pyx_t_11, __pyx_t_10, __pyx_t_13, __pyx_t_12)
+ #pragma omp parallel private(__pyx_t_10, __pyx_t_13, __pyx_t_12, __pyx_t_11)
#endif /* _OPENMP */
{
#ifdef _OPENMP
@@ -4520,9 +4520,9 @@ static PyObject *__pyx_pf_4wfpt_4wiener_like(CYTHON_UNUSED PyObject *__pyx_self,
__pyx_t_4 = __pyx_v_size;
if (1 == 0) abort();
{
- Py_ssize_t __pyx_parallel_temp0 = 0xbad0bad0;
+ double __pyx_parallel_temp0 = __PYX_NAN();
double __pyx_parallel_temp1 = __PYX_NAN();
- double __pyx_parallel_temp2 = __PYX_NAN();
+ Py_ssize_t __pyx_parallel_temp2 = 0xbad0bad0;
const char *__pyx_parallel_filename = NULL; int __pyx_parallel_lineno = 0, __pyx_parallel_clineno = 0;
PyObject *__pyx_parallel_exc_type = NULL, *__pyx_parallel_exc_value = NULL, *__pyx_parallel_exc_tb = NULL;
int __pyx_parallel_why;
@@ -4537,7 +4537,7 @@ static PyObject *__pyx_pf_4wfpt_4wiener_like(CYTHON_UNUSED PyObject *__pyx_self,
if (__pyx_t_6 > 0)
{
#ifdef _OPENMP
- #pragma omp parallel reduction(+:__pyx_v_sum_logp) private(__pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_1) firstprivate(__pyx_t_3, __pyx_t_2) private(__pyx_filename, __pyx_lineno, __pyx_clineno) shared(__pyx_parallel_why, __pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb)
+ #pragma omp parallel reduction(+:__pyx_v_sum_logp) private(__pyx_t_8, __pyx_t_7, __pyx_t_1, __pyx_t_9) firstprivate(__pyx_t_3, __pyx_t_2) private(__pyx_filename, __pyx_lineno, __pyx_clineno) shared(__pyx_parallel_why, __pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb)
#endif /* _OPENMP */
{
#ifdef _OPENMP
@@ -4547,7 +4547,7 @@ static PyObject *__pyx_pf_4wfpt_4wiener_like(CYTHON_UNUSED PyObject *__pyx_self,
Py_BEGIN_ALLOW_THREADS
#endif /* _OPENMP */
#ifdef _OPENMP
- #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_p) schedule(dynamic)
+ #pragma omp for lastprivate(__pyx_v_p) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) schedule(dynamic)
#endif /* _OPENMP */
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_6; __pyx_t_5++){
if (__pyx_parallel_why < 2)
@@ -4687,9 +4687,9 @@ static PyObject *__pyx_pf_4wfpt_4wiener_like(CYTHON_UNUSED PyObject *__pyx_self,
#pragma omp critical(__pyx_parallel_lastprivates0)
#endif /* _OPENMP */
{
- __pyx_parallel_temp0 = __pyx_v_i;
- __pyx_parallel_temp1 = __pyx_v_p;
- __pyx_parallel_temp2 = __pyx_v_sum_logp;
+ __pyx_parallel_temp0 = __pyx_v_p;
+ __pyx_parallel_temp1 = __pyx_v_sum_logp;
+ __pyx_parallel_temp2 = __pyx_v_i;
}
__pyx_L19:;
#ifdef _OPENMP
@@ -4723,9 +4723,9 @@ static PyObject *__pyx_pf_4wfpt_4wiener_like(CYTHON_UNUSED PyObject *__pyx_self,
__pyx_parallel_why = 4;
}
if (__pyx_parallel_why) {
- __pyx_v_i = __pyx_parallel_temp0;
- __pyx_v_p = __pyx_parallel_temp1;
- __pyx_v_sum_logp = __pyx_parallel_temp2;
+ __pyx_v_p = __pyx_parallel_temp0;
+ __pyx_v_sum_logp = __pyx_parallel_temp1;
+ __pyx_v_i = __pyx_parallel_temp2;
switch (__pyx_parallel_why) {
case 3: goto __pyx_L4;
case 4:
@@ -6554,9 +6554,9 @@ static PyObject *__pyx_pf_4wfpt_10wiener_like_contaminant(CYTHON_UNUSED PyObject
__pyx_t_5 = __pyx_v_size;
if (1 == 0) abort();
{
- double __pyx_parallel_temp0 = __PYX_NAN();
+ Py_ssize_t __pyx_parallel_temp0 = 0xbad0bad0;
double __pyx_parallel_temp1 = __PYX_NAN();
- Py_ssize_t __pyx_parallel_temp2 = 0xbad0bad0;
+ double __pyx_parallel_temp2 = __PYX_NAN();
const char *__pyx_parallel_filename = NULL; int __pyx_parallel_lineno = 0, __pyx_parallel_clineno = 0;
PyObject *__pyx_parallel_exc_type = NULL, *__pyx_parallel_exc_value = NULL, *__pyx_parallel_exc_tb = NULL;
int __pyx_parallel_why;
@@ -6571,7 +6571,7 @@ static PyObject *__pyx_pf_4wfpt_10wiener_like_contaminant(CYTHON_UNUSED PyObject
if (__pyx_t_7 > 0)
{
#ifdef _OPENMP
- #pragma omp parallel reduction(+:__pyx_v_sum_logp) private(__pyx_t_12, __pyx_t_8, __pyx_t_10, __pyx_t_9, __pyx_t_11) firstprivate(__pyx_t_1, __pyx_t_3) private(__pyx_filename, __pyx_lineno, __pyx_clineno) shared(__pyx_parallel_why, __pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb)
+ #pragma omp parallel reduction(+:__pyx_v_sum_logp) private(__pyx_t_12, __pyx_t_10, __pyx_t_9, __pyx_t_8, __pyx_t_11) firstprivate(__pyx_t_1, __pyx_t_3) private(__pyx_filename, __pyx_lineno, __pyx_clineno) shared(__pyx_parallel_why, __pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb)
#endif /* _OPENMP */